diff --git a/pom.xml b/pom.xml
index 327ba8be7a9..a396fa4f8c9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -226,7 +226,14 @@
com.carrotsearch
hppc
- 0.6.0
+ 0.7.1
+
+
+
+ com.carrotsearch
+ hppc
+ 0.7.1
+ esoteric
diff --git a/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java b/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java
index d55374cd5b9..c3e768c5ea3 100644
--- a/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java
+++ b/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java
@@ -827,10 +827,7 @@ public class MapperQueryParser extends QueryParser {
private void applyBoost(String field, Query q) {
if (settings.boosts() != null) {
- float boost = 1f;
- if (settings.boosts().containsKey(field)) {
- boost = settings.boosts().lget();
- }
+ float boost = settings.boosts().getOrDefault(field, 1f);
q.setBoost(boost);
}
}
diff --git a/src/main/java/org/apache/lucene/queryparser/classic/QueryParserSettings.java b/src/main/java/org/apache/lucene/queryparser/classic/QueryParserSettings.java
index 4c9225d1fa7..ca364e486e1 100644
--- a/src/main/java/org/apache/lucene/queryparser/classic/QueryParserSettings.java
+++ b/src/main/java/org/apache/lucene/queryparser/classic/QueryParserSettings.java
@@ -19,7 +19,7 @@
package org.apache.lucene.queryparser.classic;
-import com.carrotsearch.hppc.ObjectFloatOpenHashMap;
+import com.carrotsearch.hppc.ObjectFloatHashMap;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.search.FuzzyQuery;
@@ -69,7 +69,7 @@ public class QueryParserSettings {
List fields = null;
Collection queryTypes = null;
- ObjectFloatOpenHashMap boosts = null;
+ ObjectFloatHashMap boosts = null;
float tieBreaker = 0.0f;
boolean useDisMax = true;
@@ -286,11 +286,11 @@ public class QueryParserSettings {
this.queryTypes = queryTypes;
}
- public ObjectFloatOpenHashMap boosts() {
+ public ObjectFloatHashMap boosts() {
return boosts;
}
- public void boosts(ObjectFloatOpenHashMap boosts) {
+ public void boosts(ObjectFloatHashMap boosts) {
this.boosts = boosts;
}
diff --git a/src/main/java/org/apache/lucene/search/suggest/analyzing/XAnalyzingSuggester.java b/src/main/java/org/apache/lucene/search/suggest/analyzing/XAnalyzingSuggester.java
index 38d8edf8735..ec26fffb228 100644
--- a/src/main/java/org/apache/lucene/search/suggest/analyzing/XAnalyzingSuggester.java
+++ b/src/main/java/org/apache/lucene/search/suggest/analyzing/XAnalyzingSuggester.java
@@ -18,7 +18,7 @@
*/
package org.apache.lucene.search.suggest.analyzing;
-import com.carrotsearch.hppc.ObjectIntOpenHashMap;
+import com.carrotsearch.hppc.ObjectIntHashMap;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
@@ -1008,7 +1008,7 @@ public long ramBytesUsed() {
private BytesRefBuilder analyzed = new BytesRefBuilder();
private final SurfaceFormAndPayload[] surfaceFormsAndPayload;
private int count;
- private ObjectIntOpenHashMap seenSurfaceForms = HppcMaps.Object.Integer.ensureNoNullKeys(256, 0.75f);
+ private ObjectIntHashMap seenSurfaceForms = HppcMaps.Object.Integer.ensureNoNullKeys(256, 0.75f);
private int payloadSep;
public XBuilder(int maxSurfaceFormsPerAnalyzedForm, boolean hasPayloads, int payloadSep) {
@@ -1061,9 +1061,11 @@ public long ramBytesUsed() {
// dups: skip the rest:
return;
}
+
BytesRef surfaceCopy;
- if (count > 0 && seenSurfaceForms.containsKey(surface)) {
- surfaceIndex = seenSurfaceForms.lget();
+ final int keySlot;
+ if (count > 0 && (keySlot = seenSurfaceForms.indexOf(surface)) >= 0) {
+ surfaceIndex = seenSurfaceForms.indexGet(keySlot);
SurfaceFormAndPayload surfaceFormAndPayload = surfaceFormsAndPayload[surfaceIndex];
if (encodedWeight >= surfaceFormAndPayload.weight) {
return;
diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIndices.java b/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIndices.java
index d2395abf5f8..ccf4969bf5e 100644
--- a/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIndices.java
+++ b/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIndices.java
@@ -19,7 +19,7 @@
package org.elasticsearch.action.admin.cluster.stats;
-import com.carrotsearch.hppc.ObjectObjectOpenHashMap;
+import com.carrotsearch.hppc.ObjectObjectHashMap;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import org.elasticsearch.action.admin.indices.stats.CommonStats;
@@ -57,7 +57,7 @@ public class ClusterStatsIndices implements ToXContent, Streamable {
}
public ClusterStatsIndices(ClusterStatsNodeResponse[] nodeResponses) {
- ObjectObjectOpenHashMap countsPerIndex = new ObjectObjectOpenHashMap<>();
+ ObjectObjectHashMap countsPerIndex = new ObjectObjectHashMap<>();
this.docs = new DocsStats();
this.store = new StoreStats();
diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsNodes.java b/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsNodes.java
index 20517fa6801..536d8aecad7 100644
--- a/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsNodes.java
+++ b/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsNodes.java
@@ -19,7 +19,7 @@
package org.elasticsearch.action.admin.cluster.stats;
-import com.carrotsearch.hppc.ObjectIntOpenHashMap;
+import com.carrotsearch.hppc.ObjectIntHashMap;
import com.carrotsearch.hppc.cursors.ObjectIntCursor;
import org.elasticsearch.Version;
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
@@ -303,10 +303,10 @@ public class ClusterStatsNodes implements ToXContent, Streamable {
int availableProcessors;
long availableMemory;
- ObjectIntOpenHashMap cpus;
+ ObjectIntHashMap cpus;
public OsStats() {
- cpus = new ObjectIntOpenHashMap<>();
+ cpus = new ObjectIntHashMap<>();
}
public void addNodeInfo(NodeInfo nodeInfo) {
@@ -330,7 +330,7 @@ public class ClusterStatsNodes implements ToXContent, Streamable {
return new ByteSizeValue(availableMemory);
}
- public ObjectIntOpenHashMap getCpus() {
+ public ObjectIntHashMap getCpus() {
return cpus;
}
@@ -339,7 +339,7 @@ public class ClusterStatsNodes implements ToXContent, Streamable {
availableProcessors = in.readVInt();
availableMemory = in.readLong();
int size = in.readVInt();
- cpus = new ObjectIntOpenHashMap<>(size);
+ cpus = new ObjectIntHashMap<>(size);
for (; size > 0; size--) {
cpus.addTo(OsInfo.Cpu.readCpu(in), in.readVInt());
}
@@ -496,21 +496,21 @@ public class ClusterStatsNodes implements ToXContent, Streamable {
public static class JvmStats implements Streamable, ToXContent {
- ObjectIntOpenHashMap versions;
+ ObjectIntHashMap versions;
long threads;
long maxUptime;
long heapUsed;
long heapMax;
JvmStats() {
- versions = new ObjectIntOpenHashMap<>();
+ versions = new ObjectIntHashMap<>();
threads = 0;
maxUptime = 0;
heapMax = 0;
heapUsed = 0;
}
- public ObjectIntOpenHashMap getVersions() {
+ public ObjectIntHashMap getVersions() {
return versions;
}
@@ -561,7 +561,7 @@ public class ClusterStatsNodes implements ToXContent, Streamable {
@Override
public void readFrom(StreamInput in) throws IOException {
int size = in.readVInt();
- versions = new ObjectIntOpenHashMap<>(size);
+ versions = new ObjectIntHashMap<>(size);
for (; size > 0; size--) {
versions.addTo(JvmVersion.readJvmVersion(in), in.readVInt());
}
diff --git a/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java
index a2f28a9bcfc..3c751c67675 100644
--- a/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java
+++ b/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java
@@ -19,7 +19,7 @@
package org.elasticsearch.action.admin.indices.mapping.put;
-import com.carrotsearch.hppc.ObjectOpenHashSet;
+import com.carrotsearch.hppc.ObjectHashSet;
import org.elasticsearch.ElasticsearchGenerationException;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
@@ -51,7 +51,7 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
*/
public class PutMappingRequest extends AcknowledgedRequest implements IndicesRequest.Replaceable {
- private static ObjectOpenHashSet RESERVED_FIELDS = ObjectOpenHashSet.from(
+ private static ObjectHashSet RESERVED_FIELDS = ObjectHashSet.from(
"_uid", "_id", "_type", "_source", "_all", "_analyzer", "_parent", "_routing", "_index",
"_size", "_timestamp", "_ttl"
);
diff --git a/src/main/java/org/elasticsearch/action/termvectors/TermVectorsFields.java b/src/main/java/org/elasticsearch/action/termvectors/TermVectorsFields.java
index 74abe26422f..e7157cf506f 100644
--- a/src/main/java/org/elasticsearch/action/termvectors/TermVectorsFields.java
+++ b/src/main/java/org/elasticsearch/action/termvectors/TermVectorsFields.java
@@ -19,7 +19,7 @@
package org.elasticsearch.action.termvectors;
-import com.carrotsearch.hppc.ObjectLongOpenHashMap;
+import com.carrotsearch.hppc.ObjectLongHashMap;
import com.carrotsearch.hppc.cursors.ObjectLongCursor;
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.PostingsEnum;
@@ -113,7 +113,7 @@ import static org.apache.lucene.util.ArrayUtil.grow;
public final class TermVectorsFields extends Fields {
- private final ObjectLongOpenHashMap fieldMap;
+ private final ObjectLongHashMap fieldMap;
private final BytesReference termVectors;
final boolean hasTermStatistic;
final boolean hasFieldStatistic;
@@ -126,7 +126,7 @@ public final class TermVectorsFields extends Fields {
*/
public TermVectorsFields(BytesReference headerRef, BytesReference termVectors) throws IOException {
BytesStreamInput header = new BytesStreamInput(headerRef);
- fieldMap = new ObjectLongOpenHashMap<>();
+ fieldMap = new ObjectLongHashMap<>();
// here we read the header to fill the field offset map
String headerString = header.readString();
@@ -170,10 +170,11 @@ public final class TermVectorsFields extends Fields {
public Terms terms(String field) throws IOException {
// first, find where in the termVectors bytes the actual term vector for
// this field is stored
- if (!fieldMap.containsKey(field)) {
+ final int keySlot = fieldMap.indexOf(field);
+ if (keySlot < 0) {
return null; // we don't have it.
}
- long readOffset = fieldMap.lget();
+ long readOffset = fieldMap.indexGet(keySlot);
return new TermVector(termVectors, readOffset);
}
diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java b/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java
index b11c5fbab7d..8696800f882 100644
--- a/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java
+++ b/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java
@@ -20,11 +20,13 @@
package org.elasticsearch.cluster.metadata;
import com.carrotsearch.hppc.ObjectArrayList;
-import com.carrotsearch.hppc.ObjectOpenHashSet;
+import com.carrotsearch.hppc.ObjectHashSet;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import com.google.common.base.Predicate;
import com.google.common.collect.*;
+
+import org.apache.lucene.util.CollectionUtil;
import org.elasticsearch.cluster.*;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.cluster.DiffableUtils.KeyedReader;
@@ -295,7 +297,7 @@ public class MetaData implements Iterable, Diffable {
boolean matchAllAliases = matchAllAliases(aliases);
ImmutableOpenMap.Builder> mapBuilder = ImmutableOpenMap.builder();
- Iterable intersection = HppcMaps.intersection(ObjectOpenHashSet.from(concreteIndices), indices.keys());
+ Iterable intersection = HppcMaps.intersection(ObjectHashSet.from(concreteIndices), indices.keys());
for (String index : intersection) {
IndexMetaData indexMetaData = indices.get(index);
List filteredValues = Lists.newArrayList();
@@ -307,6 +309,13 @@ public class MetaData implements Iterable, Diffable {
}
if (!filteredValues.isEmpty()) {
+ // Make the list order deterministic
+ CollectionUtil.timSort(filteredValues, new Comparator() {
+ @Override
+ public int compare(AliasMetaData o1, AliasMetaData o2) {
+ return o1.alias().compareTo(o2.alias());
+ }
+ });
mapBuilder.put(index, ImmutableList.copyOf(filteredValues));
}
}
@@ -337,7 +346,7 @@ public class MetaData implements Iterable, Diffable {
return false;
}
- Iterable intersection = HppcMaps.intersection(ObjectOpenHashSet.from(concreteIndices), indices.keys());
+ Iterable intersection = HppcMaps.intersection(ObjectHashSet.from(concreteIndices), indices.keys());
for (String index : intersection) {
IndexMetaData indexMetaData = indices.get(index);
List filteredValues = Lists.newArrayList();
@@ -368,7 +377,7 @@ public class MetaData implements Iterable, Diffable {
}
ImmutableOpenMap.Builder> indexMapBuilder = ImmutableOpenMap.builder();
- Iterable intersection = HppcMaps.intersection(ObjectOpenHashSet.from(concreteIndices), indices.keys());
+ Iterable intersection = HppcMaps.intersection(ObjectHashSet.from(concreteIndices), indices.keys());
for (String index : intersection) {
IndexMetaData indexMetaData = indices.get(index);
ImmutableOpenMap.Builder filteredMappings;
@@ -400,7 +409,7 @@ public class MetaData implements Iterable, Diffable {
final String[] warmers = Strings.isAllOrWildcard(uncheckedWarmers) ? Strings.EMPTY_ARRAY : uncheckedWarmers;
ImmutableOpenMap.Builder> mapBuilder = ImmutableOpenMap.builder();
- Iterable intersection = HppcMaps.intersection(ObjectOpenHashSet.from(concreteIndices), indices.keys());
+ Iterable intersection = HppcMaps.intersection(ObjectHashSet.from(concreteIndices), indices.keys());
for (String index : intersection) {
IndexMetaData indexMetaData = indices.get(index);
IndexWarmersMetaData indexWarmersMetaData = indexMetaData.custom(IndexWarmersMetaData.TYPE);
diff --git a/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java b/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java
index 8692e5fb006..4d8b4b6bce0 100644
--- a/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java
+++ b/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java
@@ -19,7 +19,7 @@
package org.elasticsearch.cluster.node;
-import com.carrotsearch.hppc.ObjectOpenHashSet;
+import com.carrotsearch.hppc.ObjectHashSet;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import com.google.common.collect.ImmutableList;
@@ -334,7 +334,7 @@ public class DiscoveryNodes extends AbstractDiffable implements
}
return nodesIds;
} else {
- ObjectOpenHashSet resolvedNodesIds = new ObjectOpenHashSet<>(nodesIds.length);
+ ObjectHashSet resolvedNodesIds = new ObjectHashSet<>(nodesIds.length);
for (String nodeId : nodesIds) {
if (nodeId.equals("_local")) {
String localNodeId = localNodeId();
diff --git a/src/main/java/org/elasticsearch/cluster/routing/IndexRoutingTable.java b/src/main/java/org/elasticsearch/cluster/routing/IndexRoutingTable.java
index 6aaa260c4b5..7531e8052a9 100644
--- a/src/main/java/org/elasticsearch/cluster/routing/IndexRoutingTable.java
+++ b/src/main/java/org/elasticsearch/cluster/routing/IndexRoutingTable.java
@@ -25,6 +25,8 @@ import com.carrotsearch.hppc.cursors.IntObjectCursor;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import com.google.common.collect.UnmodifiableIterator;
+
+import org.apache.lucene.util.CollectionUtil;
import org.elasticsearch.cluster.AbstractDiffable;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
@@ -35,11 +37,13 @@ import org.elasticsearch.index.shard.ShardId;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
-import static com.google.common.collect.Lists.newArrayList;
+import static com.google.common.collect.Lists.*;
/**
* The {@link IndexRoutingTable} represents routing information for a single
@@ -540,7 +544,26 @@ public class IndexRoutingTable extends AbstractDiffable imple
public String prettyPrint() {
StringBuilder sb = new StringBuilder("-- index [" + index + "]\n");
+
+ List ordered = new ArrayList<>();
for (IndexShardRoutingTable indexShard : this) {
+ ordered.add(indexShard);
+ }
+
+ CollectionUtil.timSort(ordered, new Comparator() {
+ @Override
+ public int compare(IndexShardRoutingTable o1, IndexShardRoutingTable o2) {
+ int v = o1.shardId().index().name().compareTo(
+ o2.shardId().index().name());
+ if (v == 0) {
+ v = Integer.compare(o1.shardId().id(),
+ o2.shardId().id());
+ }
+ return v;
+ }
+ });
+
+ for (IndexShardRoutingTable indexShard : ordered) {
sb.append("----shard_id [").append(indexShard.shardId().index().name()).append("][").append(indexShard.shardId().id()).append("]\n");
for (ShardRouting shard : indexShard) {
sb.append("--------").append(shard.shortSummary()).append("\n");
diff --git a/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java b/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java
index e2088929f3c..6dd005ca74d 100644
--- a/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java
+++ b/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java
@@ -19,7 +19,7 @@
package org.elasticsearch.cluster.routing;
-import com.carrotsearch.hppc.ObjectIntOpenHashMap;
+import com.carrotsearch.hppc.ObjectIntHashMap;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.google.common.base.Predicate;
import com.google.common.collect.*;
@@ -64,7 +64,7 @@ public class RoutingNodes implements Iterable {
private Set clearPostAllocationFlag;
- private final Map> nodesPerAttributeNames = new HashMap<>();
+ private final Map> nodesPerAttributeNames = new HashMap<>();
public RoutingNodes(ClusterState clusterState) {
this.metaData = clusterState.metaData();
@@ -208,12 +208,12 @@ public class RoutingNodes implements Iterable {
return nodesToShards.get(nodeId);
}
- public ObjectIntOpenHashMap nodesPerAttributesCounts(String attributeName) {
- ObjectIntOpenHashMap nodesPerAttributesCounts = nodesPerAttributeNames.get(attributeName);
+ public ObjectIntHashMap nodesPerAttributesCounts(String attributeName) {
+ ObjectIntHashMap nodesPerAttributesCounts = nodesPerAttributeNames.get(attributeName);
if (nodesPerAttributesCounts != null) {
return nodesPerAttributesCounts;
}
- nodesPerAttributesCounts = new ObjectIntOpenHashMap<>();
+ nodesPerAttributesCounts = new ObjectIntHashMap<>();
for (RoutingNode routingNode : this) {
String attrValue = routingNode.node().attributes().get(attributeName);
nodesPerAttributesCounts.addTo(attrValue, 1);
diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AwarenessAllocationDecider.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AwarenessAllocationDecider.java
index 77f1668c51e..e8f033b25fd 100644
--- a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AwarenessAllocationDecider.java
+++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AwarenessAllocationDecider.java
@@ -19,7 +19,7 @@
package org.elasticsearch.cluster.routing.allocation.decider;
-import com.carrotsearch.hppc.ObjectIntOpenHashMap;
+import com.carrotsearch.hppc.ObjectIntHashMap;
import com.google.common.collect.Maps;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.routing.MutableShardRouting;
@@ -182,10 +182,10 @@ public class AwarenessAllocationDecider extends AllocationDecider {
}
// build attr_value -> nodes map
- ObjectIntOpenHashMap nodesPerAttribute = allocation.routingNodes().nodesPerAttributesCounts(awarenessAttribute);
+ ObjectIntHashMap nodesPerAttribute = allocation.routingNodes().nodesPerAttributesCounts(awarenessAttribute);
// build the count of shards per attribute value
- ObjectIntOpenHashMap shardPerAttribute = new ObjectIntOpenHashMap<>();
+ ObjectIntHashMap shardPerAttribute = new ObjectIntHashMap<>();
for (MutableShardRouting assignedShard : allocation.routingNodes().assignedShards(shardRouting)) {
// if the shard is relocating, then make sure we count it as part of the node it is relocating to
if (assignedShard.relocating()) {
diff --git a/src/main/java/org/elasticsearch/common/ContextHolder.java b/src/main/java/org/elasticsearch/common/ContextHolder.java
index 6841b72525f..c7676e90b74 100644
--- a/src/main/java/org/elasticsearch/common/ContextHolder.java
+++ b/src/main/java/org/elasticsearch/common/ContextHolder.java
@@ -20,7 +20,7 @@
package org.elasticsearch.common;
import com.carrotsearch.hppc.ObjectObjectAssociativeContainer;
-import com.carrotsearch.hppc.ObjectObjectOpenHashMap;
+import com.carrotsearch.hppc.ObjectObjectHashMap;
import org.elasticsearch.common.collect.ImmutableOpenMap;
/**
@@ -28,7 +28,7 @@ import org.elasticsearch.common.collect.ImmutableOpenMap;
*/
public class ContextHolder {
- private ObjectObjectOpenHashMap