Skip to content

Commit d11b521

Browse files
cleanup
1 parent 2dd8ac2 commit d11b521

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

server/src/main/java/org/elasticsearch/cluster/metadata/ProjectMetadata.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1770,6 +1770,9 @@ static SortedMap<String, IndexAbstraction> buildIndicesLookup(
17701770
collectIndices(indices, indexToDataStreamLookup, indicesLookup, aliasToIndices);
17711771
collectAliases(aliasToIndices, indicesLookup);
17721772

1773+
// We do a ton of lookups on this map but also need its sorted properties at times.
1774+
// Using this hybrid of a sorted and a hash-map trades some heap overhead relative to just using a TreeMap
1775+
// for much faster O(1) lookups in large clusters.
17731776
return new SortedMap<>() {
17741777

17751778
private final SortedMap<String, IndexAbstraction> map = new TreeMap<>(indicesLookup);
@@ -1816,7 +1819,7 @@ public Collection<IndexAbstraction> values() {
18161819

18171820
@Override
18181821
public Set<Entry<String, IndexAbstraction>> entrySet() {
1819-
return Collections.unmodifiableSet(map.entrySet());
1822+
return Collections.unmodifiableSortedMap(map).entrySet();
18201823
}
18211824

18221825
@Override

0 commit comments

Comments
 (0)