Skip to content

Commit

Permalink
Remove ImmutableOpenMap from Engine
Browse files Browse the repository at this point in the history
SegmentStats was changed to use Map, but the method in Engine which
computes files sizes for segment stats was never converted. This commit
removes that final usage from Engine.

relates elastic#86239
  • Loading branch information
rjernst committed Jul 5, 2022
1 parent a9d1986 commit 6fec303
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions server/src/main/java/org/elasticsearch/index/engine/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.common.lucene.index.ElasticsearchDirectoryReader;
Expand Down Expand Up @@ -66,6 +65,7 @@
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -843,9 +843,9 @@ protected void fillSegmentStats(SegmentReader segmentReader, boolean includeSegm
}
}

private ImmutableOpenMap<String, SegmentsStats.FileStats> getSegmentFileSizes(SegmentReader segmentReader) {
private Map<String, SegmentsStats.FileStats> getSegmentFileSizes(SegmentReader segmentReader) {
try {
final ImmutableOpenMap.Builder<String, SegmentsStats.FileStats> files = ImmutableOpenMap.builder();
Map<String, SegmentsStats.FileStats> files = new HashMap<>();
final SegmentCommitInfo segmentCommitInfo = segmentReader.getSegmentInfo();
for (String fileName : segmentCommitInfo.files()) {
String fileExtension = IndexFileNames.getExtension(fileName);
Expand All @@ -857,11 +857,11 @@ private ImmutableOpenMap<String, SegmentsStats.FileStats> getSegmentFileSizes(Se
logger.warn(() -> "Error when retrieving file length for [" + fileName + "]", ioe);
} catch (AlreadyClosedException ace) {
logger.warn(() -> "Error when retrieving file length for [" + fileName + "], directory is closed", ace);
return ImmutableOpenMap.of();
return Map.of();
}
}
}
return files.build();
return Collections.unmodifiableMap(files);
} catch (IOException e) {
logger.warn(
() -> format(
Expand All @@ -871,7 +871,7 @@ private ImmutableOpenMap<String, SegmentsStats.FileStats> getSegmentFileSizes(Se
),
e
);
return ImmutableOpenMap.of();
return Map.of();
}
}

Expand Down

0 comments on commit 6fec303

Please sign in to comment.