Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ImmutableOpenMap from Engine #88291

Merged
merged 1 commit into from
Jul 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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