diff --git a/server/src/main/java/org/opensearch/common/collect/ImmutableOpenIntMap.java b/server/src/main/java/org/opensearch/common/collect/ImmutableOpenIntMap.java index a5ebb19423732..75082802a6b3d 100644 --- a/server/src/main/java/org/opensearch/common/collect/ImmutableOpenIntMap.java +++ b/server/src/main/java/org/opensearch/common/collect/ImmutableOpenIntMap.java @@ -390,6 +390,11 @@ public void indexInsert(int index, int key, VType value) { map.indexInsert(index, key, value); } + @Override + public VType indexRemove(int index) { + return map.indexRemove(index); + } + @Override public void release() { map.release(); diff --git a/server/src/main/java/org/opensearch/common/collect/ImmutableOpenMap.java b/server/src/main/java/org/opensearch/common/collect/ImmutableOpenMap.java index 82b9afd1d3c08..546c676f4ecff 100644 --- a/server/src/main/java/org/opensearch/common/collect/ImmutableOpenMap.java +++ b/server/src/main/java/org/opensearch/common/collect/ImmutableOpenMap.java @@ -409,6 +409,11 @@ public void indexInsert(int index, KType key, VType value) { map.indexInsert(index, key, value); } + @Override + public VType indexRemove(int index) { + return map.indexRemove(index); + } + @Override public void release() { map.release(); diff --git a/server/src/main/java/org/opensearch/common/lucene/search/function/RandomScoreFunction.java b/server/src/main/java/org/opensearch/common/lucene/search/function/RandomScoreFunction.java index f4fcda47b0078..081743f2e3cec 100644 --- a/server/src/main/java/org/opensearch/common/lucene/search/function/RandomScoreFunction.java +++ b/server/src/main/java/org/opensearch/common/lucene/search/function/RandomScoreFunction.java @@ -75,7 +75,7 @@ public RandomScoreFunction(int seed, int salt, IndexFieldData uidFieldData) { public RandomScoreFunction(int seed, int salt, IndexFieldData uidFieldData, @Nullable String functionName) { super(CombineFunction.MULTIPLY); this.originalSeed = seed; - this.saltedSeed = BitMixer.mix(seed, salt); + this.saltedSeed = BitMixer.mix(seed ^ salt); this.fieldData = uidFieldData; this.functionName = functionName; } @@ -97,7 +97,7 @@ public LeafScoreFunction getLeafScoreFunction(LeafReaderContext ctx) { public double score(int docId, float subQueryScore) throws IOException { int hash; if (values == null) { - hash = BitMixer.mix(ctx.docBase + docId, saltedSeed); + hash = BitMixer.mix((ctx.docBase + docId) ^ saltedSeed); } else if (values.advanceExact(docId)) { hash = StringHelper.murmurhash3_x86_32(values.nextValue(), saltedSeed); } else { diff --git a/server/src/main/java/org/opensearch/rest/action/cat/RestAllocationAction.java b/server/src/main/java/org/opensearch/rest/action/cat/RestAllocationAction.java index b9c414e320adc..d8062604a3e33 100644 --- a/server/src/main/java/org/opensearch/rest/action/cat/RestAllocationAction.java +++ b/server/src/main/java/org/opensearch/rest/action/cat/RestAllocationAction.java @@ -32,7 +32,6 @@ package org.opensearch.rest.action.cat; -import com.carrotsearch.hppc.ObjectIntScatterMap; import org.opensearch.action.admin.cluster.node.stats.NodeStats; import org.opensearch.action.admin.cluster.node.stats.NodesStatsRequest; import org.opensearch.action.admin.cluster.node.stats.NodesStatsResponse; @@ -51,7 +50,9 @@ import org.opensearch.rest.action.RestActionListener; import org.opensearch.rest.action.RestResponseListener; +import java.util.HashMap; import java.util.List; +import java.util.Map; import static java.util.Arrays.asList; import static java.util.Collections.unmodifiableList; @@ -129,7 +130,7 @@ protected Table getTableWithHeader(final RestRequest request) { } private Table buildTable(RestRequest request, final ClusterStateResponse state, final NodesStatsResponse stats) { - final ObjectIntScatterMap allocs = new ObjectIntScatterMap<>(); + final Map allocs = new HashMap<>(); for (ShardRouting shard : state.getState().routingTable().allShards()) { String nodeId = "UNASSIGNED"; @@ -138,7 +139,7 @@ private Table buildTable(RestRequest request, final ClusterStateResponse state, nodeId = shard.currentNodeId(); } - allocs.addTo(nodeId, 1); + allocs.merge(nodeId, 1, Integer::sum); } Table table = getTableWithHeader(request);