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 context; + private ObjectObjectHashMap context; /** * Attaches the given value to the context. @@ -39,7 +39,7 @@ public class ContextHolder { @SuppressWarnings("unchecked") public final synchronized V putInContext(Object key, Object value) { if (context == null) { - context = new ObjectObjectOpenHashMap<>(2); + context = new ObjectObjectHashMap<>(2); } return (V) context.put(key, value); } @@ -52,7 +52,7 @@ public class ContextHolder { return; } if (context == null) { - context = new ObjectObjectOpenHashMap<>(map); + context = new ObjectObjectHashMap<>(map); } else { context.putAll(map); } @@ -120,7 +120,7 @@ public class ContextHolder { return; } if (context == null) { - context = new ObjectObjectOpenHashMap<>(other.context); + context = new ObjectObjectHashMap<>(other.context); } else { context.putAll(other.context); } diff --git a/src/main/java/org/elasticsearch/common/collect/HppcMaps.java b/src/main/java/org/elasticsearch/common/collect/HppcMaps.java index 594b93df6a2..5dc17bedb39 100644 --- a/src/main/java/org/elasticsearch/common/collect/HppcMaps.java +++ b/src/main/java/org/elasticsearch/common/collect/HppcMaps.java @@ -19,9 +19,9 @@ package org.elasticsearch.common.collect; -import com.carrotsearch.hppc.ObjectIntOpenHashMap; +import com.carrotsearch.hppc.ObjectIntHashMap; import com.carrotsearch.hppc.ObjectLookupContainer; -import com.carrotsearch.hppc.ObjectObjectOpenHashMap; +import com.carrotsearch.hppc.ObjectObjectHashMap; import com.carrotsearch.hppc.cursors.ObjectCursor; import java.util.Iterator; @@ -34,40 +34,50 @@ public final class HppcMaps { } /** - * Returns a new map with the given initial capacity + * Returns a new map with the given number of expected elements. + * + * @param expectedElements + * The expected number of elements guaranteed not to cause buffer + * expansion (inclusive). */ - public static ObjectObjectOpenHashMap newMap(int capacity) { - return new ObjectObjectOpenHashMap<>(capacity); + public static ObjectObjectHashMap newMap(int expectedElements) { + return new ObjectObjectHashMap<>(expectedElements); } /** - * Returns a new map with a default initial capacity of - * {@value com.carrotsearch.hppc.HashContainerUtils#DEFAULT_CAPACITY} + * Returns a new map with a default initial capacity. */ - public static ObjectObjectOpenHashMap newMap() { + public static ObjectObjectHashMap newMap() { return newMap(16); } /** * Returns a map like {@link #newMap()} that does not accept null keys */ - public static ObjectObjectOpenHashMap newNoNullKeysMap() { + public static ObjectObjectHashMap newNoNullKeysMap() { return ensureNoNullKeys(16); } /** * Returns a map like {@link #newMap(int)} that does not accept null keys + * + * @param expectedElements + * The expected number of elements guaranteed not to cause buffer + * expansion (inclusive). */ - public static ObjectObjectOpenHashMap newNoNullKeysMap(int capacity) { - return ensureNoNullKeys(capacity); + public static ObjectObjectHashMap newNoNullKeysMap(int expectedElements) { + return ensureNoNullKeys(expectedElements); } /** * Wraps the given map and prevent adding of null keys. + * + * @param expectedElements + * The expected number of elements guaranteed not to cause buffer + * expansion (inclusive). */ - public static ObjectObjectOpenHashMap ensureNoNullKeys(int capacity) { - return new ObjectObjectOpenHashMap(capacity) { - + public static ObjectObjectHashMap ensureNoNullKeys(int expectedElements) { + return new ObjectObjectHashMap(expectedElements) { @Override public V put(K key, V value) { if (key == null) { @@ -75,12 +85,11 @@ public final class HppcMaps { } return super.put(key, value); } - }; } /** - * @return an intersection view over the two specified containers (which can be KeyContainer or ObjectOpenHashSet). + * @return an intersection view over the two specified containers (which can be KeyContainer or ObjectHashSet). */ // Hppc has forEach, but this means we need to build an intermediate set, with this method we just iterate // over each unique value without creating a third set. @@ -124,12 +133,9 @@ public final class HppcMaps { } public final static class Object { - public final static class Integer { - - public static ObjectIntOpenHashMap ensureNoNullKeys(int capacity, float loadFactor) { - return new ObjectIntOpenHashMap(capacity, loadFactor) { - + public static ObjectIntHashMap ensureNoNullKeys(int capacity, float loadFactor) { + return new ObjectIntHashMap(capacity, loadFactor) { @Override public int put(V key, int value) { if (key == null) { @@ -139,9 +145,6 @@ public final class HppcMaps { } }; } - } - } - } diff --git a/src/main/java/org/elasticsearch/common/collect/ImmutableOpenIntMap.java b/src/main/java/org/elasticsearch/common/collect/ImmutableOpenIntMap.java index ac60cb89831..eda83a1505b 100644 --- a/src/main/java/org/elasticsearch/common/collect/ImmutableOpenIntMap.java +++ b/src/main/java/org/elasticsearch/common/collect/ImmutableOpenIntMap.java @@ -23,6 +23,7 @@ import com.carrotsearch.hppc.*; import com.carrotsearch.hppc.cursors.IntCursor; import com.carrotsearch.hppc.cursors.IntObjectCursor; import com.carrotsearch.hppc.cursors.ObjectCursor; +import com.carrotsearch.hppc.predicates.IntObjectPredicate; import com.carrotsearch.hppc.predicates.IntPredicate; import com.carrotsearch.hppc.procedures.IntObjectProcedure; import com.google.common.collect.UnmodifiableIterator; @@ -38,9 +39,9 @@ import java.util.Map; */ public final class ImmutableOpenIntMap implements Iterable> { - private final IntObjectOpenHashMap map; + private final IntObjectHashMap map; - private ImmutableOpenIntMap(IntObjectOpenHashMap map) { + private ImmutableOpenIntMap(IntObjectHashMap map) { this.map = map; } @@ -175,7 +176,7 @@ public final class ImmutableOpenIntMap implements Iterable ImmutableOpenIntMap of() { @@ -196,7 +197,7 @@ public final class ImmutableOpenIntMap implements Iterable implements IntObjectMap { - private IntObjectOpenHashMap map; + private IntObjectHashMap map; public Builder() { //noinspection unchecked @@ -204,7 +205,7 @@ public final class ImmutableOpenIntMap implements Iterable(size); + this.map = new IntObjectHashMap<>(size); } public Builder(ImmutableOpenIntMap map) { @@ -215,7 +216,7 @@ public final class ImmutableOpenIntMap implements Iterable build() { - IntObjectOpenHashMap map = this.map; + IntObjectHashMap map = this.map; this.map = null; // nullify the map, so any operation post build will fail! (hackish, but safest) return new ImmutableOpenIntMap<>(map); } @@ -325,5 +326,50 @@ public final class ImmutableOpenIntMap implements Iterable values() { return map.values(); } + + @Override + public int removeAll(IntObjectPredicate predicate) { + return map.removeAll(predicate); + } + + @Override + public > T forEach(T predicate) { + return map.forEach(predicate); + } + + @Override + public int indexOf(int key) { + return map.indexOf(key); + } + + @Override + public boolean indexExists(int index) { + return map.indexExists(index); + } + + @Override + public VType indexGet(int index) { + return map.indexGet(index); + } + + @Override + public VType indexReplace(int index, VType newValue) { + return map.indexReplace(index, newValue); + } + + @Override + public void indexInsert(int index, int key, VType value) { + map.indexInsert(index, key, value); + } + + @Override + public void release() { + map.release(); + } + + @Override + public String visualizeKeyDistribution(int characters) { + return map.visualizeKeyDistribution(characters); + } } } diff --git a/src/main/java/org/elasticsearch/common/collect/ImmutableOpenLongMap.java b/src/main/java/org/elasticsearch/common/collect/ImmutableOpenLongMap.java index 5b19aea8f0f..571b54ebeeb 100644 --- a/src/main/java/org/elasticsearch/common/collect/ImmutableOpenLongMap.java +++ b/src/main/java/org/elasticsearch/common/collect/ImmutableOpenLongMap.java @@ -23,6 +23,8 @@ import com.carrotsearch.hppc.*; import com.carrotsearch.hppc.cursors.LongCursor; import com.carrotsearch.hppc.cursors.LongObjectCursor; import com.carrotsearch.hppc.cursors.ObjectCursor; +import com.carrotsearch.hppc.predicates.IntObjectPredicate; +import com.carrotsearch.hppc.predicates.LongObjectPredicate; import com.carrotsearch.hppc.predicates.LongPredicate; import com.carrotsearch.hppc.procedures.LongObjectProcedure; import com.google.common.collect.UnmodifiableIterator; @@ -38,9 +40,9 @@ import java.util.Map; */ public final class ImmutableOpenLongMap implements Iterable> { - private final LongObjectOpenHashMap map; + private final LongObjectHashMap map; - private ImmutableOpenLongMap(LongObjectOpenHashMap map) { + private ImmutableOpenLongMap(LongObjectHashMap map) { this.map = map; } @@ -175,7 +177,7 @@ public final class ImmutableOpenLongMap implements Iterable ImmutableOpenLongMap of() { @@ -196,7 +198,7 @@ public final class ImmutableOpenLongMap implements Iterable implements LongObjectMap { - private LongObjectOpenHashMap map; + private LongObjectHashMap map; public Builder() { //noinspection unchecked @@ -204,7 +206,7 @@ public final class ImmutableOpenLongMap implements Iterable(size); + this.map = new LongObjectHashMap<>(size); } public Builder(ImmutableOpenLongMap map) { @@ -215,7 +217,7 @@ public final class ImmutableOpenLongMap implements Iterable build() { - LongObjectOpenHashMap map = this.map; + LongObjectHashMap map = this.map; this.map = null; // nullify the map, so any operation post build will fail! (hackish, but safest) return new ImmutableOpenLongMap<>(map); } @@ -311,11 +313,6 @@ public final class ImmutableOpenLongMap implements Iterable> T forEach(T procedure) { - return map.forEach(procedure); - } - @Override public LongCollection keys() { return map.keys(); @@ -325,5 +322,55 @@ public final class ImmutableOpenLongMap implements Iterable values() { return map.values(); } + + @Override + public > T forEach(T procedure) { + return map.forEach(procedure); + } + + @Override + public int indexOf(long key) { + return map.indexOf(key); + } + + @Override + public boolean indexExists(int index) { + return map.indexExists(index); + } + + @Override + public VType indexGet(int index) { + return map.indexGet(index); + } + + @Override + public VType indexReplace(int index, VType newValue) { + return map.indexReplace(index, newValue); + } + + @Override + public void indexInsert(int index, long key, VType value) { + map.indexInsert(index, key, value); + } + + @Override + public void release() { + map.release(); + } + + @Override + public String visualizeKeyDistribution(int characters) { + return map.visualizeKeyDistribution(characters); + } + + @Override + public int removeAll(LongObjectPredicate predicate) { + return map.removeAll(predicate); + } + + @Override + public > T forEach(T predicate) { + return map.forEach(predicate); + } } } diff --git a/src/main/java/org/elasticsearch/common/collect/ImmutableOpenMap.java b/src/main/java/org/elasticsearch/common/collect/ImmutableOpenMap.java index cefbeae7253..0effca361f4 100644 --- a/src/main/java/org/elasticsearch/common/collect/ImmutableOpenMap.java +++ b/src/main/java/org/elasticsearch/common/collect/ImmutableOpenMap.java @@ -22,6 +22,7 @@ package org.elasticsearch.common.collect; import com.carrotsearch.hppc.*; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; +import com.carrotsearch.hppc.predicates.ObjectObjectPredicate; import com.carrotsearch.hppc.predicates.ObjectPredicate; import com.carrotsearch.hppc.procedures.ObjectObjectProcedure; import com.google.common.collect.UnmodifiableIterator; @@ -37,9 +38,9 @@ import java.util.Map; */ public final class ImmutableOpenMap implements Iterable> { - private final ObjectObjectOpenHashMap map; + private final ObjectObjectHashMap map; - private ImmutableOpenMap(ObjectObjectOpenHashMap map) { + private ImmutableOpenMap(ObjectObjectHashMap map) { this.map = map; } @@ -182,7 +183,7 @@ public final class ImmutableOpenMap implements Iterable ImmutableOpenMap of() { @@ -211,8 +212,7 @@ public final class ImmutableOpenMap implements Iterable implements ObjectObjectMap { - - private ObjectObjectOpenHashMap map; + private ObjectObjectHashMap map; public Builder() { //noinspection unchecked @@ -220,7 +220,7 @@ public final class ImmutableOpenMap implements Iterable(size); + this.map = new ObjectObjectHashMap<>(size); } public Builder(ImmutableOpenMap map) { @@ -231,11 +231,13 @@ public final class ImmutableOpenMap implements Iterable build() { - ObjectObjectOpenHashMap map = this.map; + ObjectObjectHashMap map = this.map; this.map = null; // nullify the map, so any operation post build will fail! (hackish, but safest) return new ImmutableOpenMap<>(map); } + + /** * Puts all the entries in the map to the builder. */ @@ -313,7 +315,7 @@ public final class ImmutableOpenMap implements Iterable container) { + public int removeAll(ObjectContainer container) { return map.removeAll(container); } @@ -347,5 +349,49 @@ public final class ImmutableOpenMap implements Iterable predicate) { + return map.removeAll(predicate); + } + + @Override + public > T forEach(T predicate) { + return map.forEach(predicate); + } + + @Override + public int indexOf(KType key) { + return map.indexOf(key); + } + + @Override + public boolean indexExists(int index) { + return map.indexExists(index); + } + + @Override + public VType indexGet(int index) { + return map.indexGet(index); + } + + @Override + public VType indexReplace(int index, VType newValue) { + return map.indexReplace(index, newValue); + } + + @Override + public void indexInsert(int index, KType key, VType value) { + map.indexInsert(index, key, value); + } + + @Override + public void release() { + map.release(); + } + + @Override + public String visualizeKeyDistribution(int characters) { + return map.visualizeKeyDistribution(characters); + } } } diff --git a/src/main/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQuery.java b/src/main/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQuery.java index 1b9492889a6..543aa9c81b9 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQuery.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQuery.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.lucene.search; -import com.carrotsearch.hppc.ObjectOpenHashSet; +import com.carrotsearch.hppc.ObjectHashSet; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; @@ -149,7 +149,7 @@ public class MultiPhrasePrefixQuery extends Query { } Term[] suffixTerms = termArrays.get(sizeMinus1); int position = positions.get(sizeMinus1); - ObjectOpenHashSet terms = new ObjectOpenHashSet<>(); + ObjectHashSet terms = new ObjectHashSet<>(); for (Term term : suffixTerms) { getPrefixTerms(terms, term, reader); if (terms.size() > maxExpansions) { @@ -163,7 +163,7 @@ public class MultiPhrasePrefixQuery extends Query { return query.rewrite(reader); } - private void getPrefixTerms(ObjectOpenHashSet terms, final Term prefix, final IndexReader reader) throws IOException { + private void getPrefixTerms(ObjectHashSet terms, final Term prefix, final IndexReader reader) throws IOException { // SlowCompositeReaderWrapper could be used... but this would merge all terms from each segment into one terms // instance, which is very expensive. Therefore I think it is better to iterate over each leaf individually. List leaves = reader.leaves(); diff --git a/src/main/java/org/elasticsearch/common/recycler/Recyclers.java b/src/main/java/org/elasticsearch/common/recycler/Recyclers.java index 4344a0689c1..daff885733a 100644 --- a/src/main/java/org/elasticsearch/common/recycler/Recyclers.java +++ b/src/main/java/org/elasticsearch/common/recycler/Recyclers.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.recycler; -import com.carrotsearch.hppc.hash.MurmurHash3; +import com.carrotsearch.hppc.BitMixer; import com.google.common.collect.Queues; import org.elasticsearch.ElasticsearchException; @@ -173,7 +173,7 @@ public enum Recyclers { final int slot() { final long id = Thread.currentThread().getId(); // don't trust Thread.hashCode to have equiprobable low bits - int slot = (int) MurmurHash3.hash(id); + int slot = (int) BitMixer.mix64(id); // make positive, otherwise % may return negative numbers slot &= 0x7FFFFFFF; slot %= concurrencyLevel; diff --git a/src/main/java/org/elasticsearch/common/util/AbstractPagedHashMap.java b/src/main/java/org/elasticsearch/common/util/AbstractPagedHashMap.java index 0793da83f7f..b48155776ed 100644 --- a/src/main/java/org/elasticsearch/common/util/AbstractPagedHashMap.java +++ b/src/main/java/org/elasticsearch/common/util/AbstractPagedHashMap.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.util; -import com.carrotsearch.hppc.hash.MurmurHash3; +import com.carrotsearch.hppc.BitMixer; import com.google.common.base.Preconditions; import org.elasticsearch.common.lease.Releasable; @@ -35,7 +35,7 @@ abstract class AbstractPagedHashMap implements Releasable { static long hash(long value) { // Don't use the value directly. Under some cases eg dates, it could be that the low bits don't carry much value and we would like // all bits of the hash to carry as much value - return MurmurHash3.hash(value); + return BitMixer.mix64(value); } static long hash(double value) { diff --git a/src/main/java/org/elasticsearch/common/util/BytesRefHash.java b/src/main/java/org/elasticsearch/common/util/BytesRefHash.java index fc3cb285416..3e5dac597ca 100644 --- a/src/main/java/org/elasticsearch/common/util/BytesRefHash.java +++ b/src/main/java/org/elasticsearch/common/util/BytesRefHash.java @@ -19,7 +19,8 @@ package org.elasticsearch.common.util; -import com.carrotsearch.hppc.hash.MurmurHash3; +import com.carrotsearch.hppc.BitMixer; + import org.apache.lucene.util.BytesRef; import org.elasticsearch.common.lease.Releasable; import org.elasticsearch.common.lease.Releasables; @@ -56,7 +57,7 @@ public final class BytesRefHash extends AbstractHash { // BytesRef has a weak hashCode function so we try to improve it by rehashing using Murmur3 // Feel free to remove rehashing if BytesRef gets a better hash function private static int rehash(int hash) { - return MurmurHash3.hash(hash); + return BitMixer.mix32(hash); } /** diff --git a/src/main/java/org/elasticsearch/gateway/Gateway.java b/src/main/java/org/elasticsearch/gateway/Gateway.java index 139b5763489..291002706be 100644 --- a/src/main/java/org/elasticsearch/gateway/Gateway.java +++ b/src/main/java/org/elasticsearch/gateway/Gateway.java @@ -19,8 +19,8 @@ package org.elasticsearch.gateway; -import com.carrotsearch.hppc.ObjectFloatOpenHashMap; -import com.carrotsearch.hppc.ObjectOpenHashSet; +import com.carrotsearch.hppc.ObjectFloatHashMap; +import com.carrotsearch.hppc.ObjectHashSet; import com.carrotsearch.hppc.cursors.ObjectCursor; import org.apache.lucene.util.IOUtils; import org.elasticsearch.action.FailedNodeException; @@ -68,7 +68,7 @@ public class Gateway extends AbstractComponent implements ClusterStateListener { } public void performStateRecovery(final GatewayStateRecoveredListener listener) throws GatewayException { - ObjectOpenHashSet nodesIds = ObjectOpenHashSet.from(clusterService.state().nodes().masterNodes().keys()); + ObjectHashSet nodesIds = new ObjectHashSet<>(clusterService.state().nodes().masterNodes().keys()); logger.trace("performing state recovery from {}", nodesIds); TransportNodesListGatewayMetaState.NodesGatewayMetaState nodesState = listGatewayMetaState.list(nodesIds.toArray(String.class), null).actionGet(); @@ -104,7 +104,7 @@ public class Gateway extends AbstractComponent implements ClusterStateListener { } } - ObjectFloatOpenHashMap indices = new ObjectFloatOpenHashMap<>(); + ObjectFloatHashMap indices = new ObjectFloatHashMap<>(); MetaData electedGlobalState = null; int found = 0; for (TransportNodesListGatewayMetaState.NodeGatewayMetaState nodeState : nodesState) { @@ -127,10 +127,11 @@ public class Gateway extends AbstractComponent implements ClusterStateListener { } // update the global state, and clean the indices, we elect them in the next phase MetaData.Builder metaDataBuilder = MetaData.builder(electedGlobalState).removeAllIndices(); - final boolean[] states = indices.allocated; + + assert !indices.containsKey(null); final Object[] keys = indices.keys; - for (int i = 0; i < states.length; i++) { - if (states[i]) { + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null) { String index = (String) keys[i]; IndexMetaData electedIndexMetaData = null; int indexMetaDataCount = 0; diff --git a/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java b/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java index def54a45b35..f77eeb253ac 100644 --- a/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java +++ b/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java @@ -19,8 +19,8 @@ package org.elasticsearch.gateway; -import com.carrotsearch.hppc.ObjectLongOpenHashMap; -import com.carrotsearch.hppc.ObjectOpenHashSet; +import com.carrotsearch.hppc.ObjectLongHashMap; +import com.carrotsearch.hppc.ObjectHashSet; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.predicates.ObjectPredicate; import com.google.common.collect.Maps; @@ -68,7 +68,7 @@ public class GatewayAllocator extends AbstractComponent { private final ConcurrentMap> cachedStores = ConcurrentCollections.newConcurrentMap(); - private final ConcurrentMap> cachedShardsState = ConcurrentCollections.newConcurrentMap(); + private final ConcurrentMap> cachedShardsState = ConcurrentCollections.newConcurrentMap(); private final TimeValue listTimeout; @@ -121,16 +121,17 @@ public class GatewayAllocator extends AbstractComponent { continue; } - ObjectLongOpenHashMap nodesState = buildShardStates(nodes, shard, metaData.index(shard.index())); + ObjectLongHashMap nodesState = buildShardStates(nodes, shard, metaData.index(shard.index())); int numberOfAllocationsFound = 0; long highestVersion = -1; Set nodesWithHighestVersion = Sets.newHashSet(); - final boolean[] states = nodesState.allocated; + + assert !nodesState.containsKey(null); final Object[] keys = nodesState.keys; final long[] values = nodesState.values; - for (int i = 0; i < states.length; i++) { - if (!states[i]) { + for (int i = 0; i < keys.length; i++) { + if (keys[i] == null) { continue; } @@ -380,13 +381,13 @@ public class GatewayAllocator extends AbstractComponent { * A shard on shared storage will return at least shard state 0 for all * nodes, indicating that the shard can be allocated to any node. */ - private ObjectLongOpenHashMap buildShardStates(final DiscoveryNodes nodes, MutableShardRouting shard, IndexMetaData indexMetaData) { - ObjectLongOpenHashMap shardStates = cachedShardsState.get(shard.shardId()); - ObjectOpenHashSet nodeIds; + private ObjectLongHashMap buildShardStates(final DiscoveryNodes nodes, MutableShardRouting shard, IndexMetaData indexMetaData) { + ObjectLongHashMap shardStates = cachedShardsState.get(shard.shardId()); + ObjectHashSet nodeIds; if (shardStates == null) { - shardStates = new ObjectLongOpenHashMap<>(); + shardStates = new ObjectLongHashMap<>(); cachedShardsState.put(shard.shardId(), shardStates); - nodeIds = ObjectOpenHashSet.from(nodes.dataNodes().keys()); + nodeIds = new ObjectHashSet<>(nodes.dataNodes().keys()); } else { // clean nodes that have failed shardStates.keys().removeAll(new ObjectPredicate() { @@ -395,7 +396,7 @@ public class GatewayAllocator extends AbstractComponent { return !nodes.nodeExists(node.id()); } }); - nodeIds = ObjectOpenHashSet.newInstance(); + nodeIds = new ObjectHashSet<>(); // we have stored cached from before, see if the nodes changed, if they have, go fetch again for (ObjectCursor cursor : nodes.dataNodes().values()) { DiscoveryNode node = cursor.value; @@ -442,13 +443,13 @@ public class GatewayAllocator extends AbstractComponent { private Map buildShardStores(DiscoveryNodes nodes, MutableShardRouting shard) { Map shardStores = cachedStores.get(shard.shardId()); - ObjectOpenHashSet nodesIds; + ObjectHashSet nodesIds; if (shardStores == null) { shardStores = Maps.newHashMap(); cachedStores.put(shard.shardId(), shardStores); - nodesIds = ObjectOpenHashSet.from(nodes.dataNodes().keys()); + nodesIds = new ObjectHashSet<>(nodes.dataNodes().keys()); } else { - nodesIds = ObjectOpenHashSet.newInstance(); + nodesIds = new ObjectHashSet<>(); // clean nodes that have failed for (Iterator it = shardStores.keySet().iterator(); it.hasNext(); ) { DiscoveryNode node = it.next(); diff --git a/src/main/java/org/elasticsearch/index/analysis/NumericDateAnalyzer.java b/src/main/java/org/elasticsearch/index/analysis/NumericDateAnalyzer.java index 6860e6560b0..8b6184c4f2c 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NumericDateAnalyzer.java +++ b/src/main/java/org/elasticsearch/index/analysis/NumericDateAnalyzer.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.analysis; -import com.carrotsearch.hppc.IntObjectOpenHashMap; +import com.carrotsearch.hppc.IntObjectHashMap; import com.google.common.collect.Maps; import org.elasticsearch.common.joda.FormatDateTimeFormatter; import org.joda.time.format.DateTimeFormatter; @@ -32,12 +32,12 @@ import java.util.Map; */ public class NumericDateAnalyzer extends NumericAnalyzer { - private static final Map> globalAnalyzers = Maps.newHashMap(); + private static final Map> globalAnalyzers = Maps.newHashMap(); public static synchronized NamedAnalyzer buildNamedAnalyzer(FormatDateTimeFormatter formatter, int precisionStep) { - IntObjectOpenHashMap precisionMap = globalAnalyzers.get(formatter.format()); + IntObjectHashMap precisionMap = globalAnalyzers.get(formatter.format()); if (precisionMap == null) { - precisionMap = new IntObjectOpenHashMap<>(); + precisionMap = new IntObjectHashMap<>(); globalAnalyzers.put(formatter.format(), precisionMap); } NamedAnalyzer namedAnalyzer = precisionMap.get(precisionStep); diff --git a/src/main/java/org/elasticsearch/index/analysis/NumericDoubleAnalyzer.java b/src/main/java/org/elasticsearch/index/analysis/NumericDoubleAnalyzer.java index 1067aa8efcb..e90409421d2 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NumericDoubleAnalyzer.java +++ b/src/main/java/org/elasticsearch/index/analysis/NumericDoubleAnalyzer.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.analysis; -import com.carrotsearch.hppc.IntObjectOpenHashMap; +import com.carrotsearch.hppc.IntObjectHashMap; import java.io.IOException; @@ -28,10 +28,10 @@ import java.io.IOException; */ public class NumericDoubleAnalyzer extends NumericAnalyzer { - private final static IntObjectOpenHashMap builtIn; + private final static IntObjectHashMap builtIn; static { - builtIn = new IntObjectOpenHashMap<>(); + builtIn = new IntObjectHashMap<>(); builtIn.put(Integer.MAX_VALUE, new NamedAnalyzer("_double/max", AnalyzerScope.GLOBAL, new NumericDoubleAnalyzer(Integer.MAX_VALUE))); for (int i = 0; i <= 64; i += 4) { builtIn.put(i, new NamedAnalyzer("_double/" + i, AnalyzerScope.GLOBAL, new NumericDoubleAnalyzer(i))); diff --git a/src/main/java/org/elasticsearch/index/analysis/NumericFloatAnalyzer.java b/src/main/java/org/elasticsearch/index/analysis/NumericFloatAnalyzer.java index 64085e99caa..85344830fbf 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NumericFloatAnalyzer.java +++ b/src/main/java/org/elasticsearch/index/analysis/NumericFloatAnalyzer.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.analysis; -import com.carrotsearch.hppc.IntObjectOpenHashMap; +import com.carrotsearch.hppc.IntObjectHashMap; import java.io.IOException; @@ -28,10 +28,10 @@ import java.io.IOException; */ public class NumericFloatAnalyzer extends NumericAnalyzer { - private final static IntObjectOpenHashMap builtIn; + private final static IntObjectHashMap builtIn; static { - builtIn = new IntObjectOpenHashMap<>(); + builtIn = new IntObjectHashMap<>(); builtIn.put(Integer.MAX_VALUE, new NamedAnalyzer("_float/max", AnalyzerScope.GLOBAL, new NumericFloatAnalyzer(Integer.MAX_VALUE))); for (int i = 0; i <= 64; i += 4) { builtIn.put(i, new NamedAnalyzer("_float/" + i, AnalyzerScope.GLOBAL, new NumericFloatAnalyzer(i))); diff --git a/src/main/java/org/elasticsearch/index/analysis/NumericIntegerAnalyzer.java b/src/main/java/org/elasticsearch/index/analysis/NumericIntegerAnalyzer.java index 6dff17cdb6f..87cbca6f594 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NumericIntegerAnalyzer.java +++ b/src/main/java/org/elasticsearch/index/analysis/NumericIntegerAnalyzer.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.analysis; -import com.carrotsearch.hppc.IntObjectOpenHashMap; +import com.carrotsearch.hppc.IntObjectHashMap; import java.io.IOException; @@ -28,10 +28,10 @@ import java.io.IOException; */ public class NumericIntegerAnalyzer extends NumericAnalyzer { - private final static IntObjectOpenHashMap builtIn; + private final static IntObjectHashMap builtIn; static { - builtIn = new IntObjectOpenHashMap<>(); + builtIn = new IntObjectHashMap<>(); builtIn.put(Integer.MAX_VALUE, new NamedAnalyzer("_int/max", AnalyzerScope.GLOBAL, new NumericIntegerAnalyzer(Integer.MAX_VALUE))); for (int i = 0; i <= 64; i += 4) { builtIn.put(i, new NamedAnalyzer("_int/" + i, AnalyzerScope.GLOBAL, new NumericIntegerAnalyzer(i))); diff --git a/src/main/java/org/elasticsearch/index/analysis/NumericLongAnalyzer.java b/src/main/java/org/elasticsearch/index/analysis/NumericLongAnalyzer.java index fd76c988342..ab112396392 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NumericLongAnalyzer.java +++ b/src/main/java/org/elasticsearch/index/analysis/NumericLongAnalyzer.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.analysis; -import com.carrotsearch.hppc.IntObjectOpenHashMap; +import com.carrotsearch.hppc.IntObjectHashMap; import java.io.IOException; @@ -28,10 +28,10 @@ import java.io.IOException; */ public class NumericLongAnalyzer extends NumericAnalyzer { - private final static IntObjectOpenHashMap builtIn; + private final static IntObjectHashMap builtIn; static { - builtIn = new IntObjectOpenHashMap<>(); + builtIn = new IntObjectHashMap<>(); builtIn.put(Integer.MAX_VALUE, new NamedAnalyzer("_long/max", AnalyzerScope.GLOBAL, new NumericLongAnalyzer(Integer.MAX_VALUE))); for (int i = 0; i <= 64; i += 4) { builtIn.put(i, new NamedAnalyzer("_long/" + i, AnalyzerScope.GLOBAL, new NumericLongAnalyzer(i))); diff --git a/src/main/java/org/elasticsearch/index/fielddata/FieldDataStats.java b/src/main/java/org/elasticsearch/index/fielddata/FieldDataStats.java index 5db1a52f172..ec55ae9d59f 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/FieldDataStats.java +++ b/src/main/java/org/elasticsearch/index/fielddata/FieldDataStats.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.fielddata; -import com.carrotsearch.hppc.ObjectLongOpenHashMap; +import com.carrotsearch.hppc.ObjectLongHashMap; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -38,13 +38,13 @@ public class FieldDataStats implements Streamable, ToXContent { long memorySize; long evictions; @Nullable - ObjectLongOpenHashMap fields; + ObjectLongHashMap fields; public FieldDataStats() { } - public FieldDataStats(long memorySize, long evictions, @Nullable ObjectLongOpenHashMap fields) { + public FieldDataStats(long memorySize, long evictions, @Nullable ObjectLongHashMap fields) { this.memorySize = memorySize; this.evictions = evictions; this.fields = fields; @@ -54,13 +54,16 @@ public class FieldDataStats implements Streamable, ToXContent { this.memorySize += stats.memorySize; this.evictions += stats.evictions; if (stats.fields != null) { - if (fields == null) fields = new ObjectLongOpenHashMap<>(); - final boolean[] states = stats.fields.allocated; - final Object[] keys = stats.fields.keys; - final long[] values = stats.fields.values; - for (int i = 0; i < states.length; i++) { - if (states[i]) { - fields.addTo((String) keys[i], values[i]); + if (fields == null) { + fields = stats.fields.clone(); + } else { + assert !stats.fields.containsKey(null); + final Object[] keys = stats.fields.keys; + final long[] values = stats.fields.values; + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null) { + fields.addTo((String) keys[i], values[i]); + } } } } @@ -79,7 +82,7 @@ public class FieldDataStats implements Streamable, ToXContent { } @Nullable - public ObjectLongOpenHashMap getFields() { + public ObjectLongHashMap getFields() { return fields; } @@ -95,7 +98,7 @@ public class FieldDataStats implements Streamable, ToXContent { evictions = in.readVLong(); if (in.readBoolean()) { int size = in.readVInt(); - fields = new ObjectLongOpenHashMap<>(size); + fields = new ObjectLongHashMap<>(size); for (int i = 0; i < size; i++) { fields.put(in.readString(), in.readVLong()); } @@ -111,11 +114,11 @@ public class FieldDataStats implements Streamable, ToXContent { } else { out.writeBoolean(true); out.writeVInt(fields.size()); - final boolean[] states = fields.allocated; + assert !fields.containsKey(null); final Object[] keys = fields.keys; final long[] values = fields.values; - for (int i = 0; i < states.length; i++) { - if (states[i]) { + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null) { out.writeString((String) keys[i]); out.writeVLong(values[i]); } @@ -130,11 +133,11 @@ public class FieldDataStats implements Streamable, ToXContent { builder.field(Fields.EVICTIONS, getEvictions()); if (fields != null) { builder.startObject(Fields.FIELDS); - final boolean[] states = fields.allocated; + assert !fields.containsKey(null); final Object[] keys = fields.keys; final long[] values = fields.values; - for (int i = 0; i < states.length; i++) { - if (states[i]) { + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null) { builder.startObject((String) keys[i], XContentBuilder.FieldCaseConversion.NONE); builder.byteSizeField(Fields.MEMORY_SIZE_IN_BYTES, Fields.MEMORY_SIZE, values[i]); builder.endObject(); diff --git a/src/main/java/org/elasticsearch/index/fielddata/ShardFieldData.java b/src/main/java/org/elasticsearch/index/fielddata/ShardFieldData.java index 5c7fd2a9ca8..7db73e2359c 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/ShardFieldData.java +++ b/src/main/java/org/elasticsearch/index/fielddata/ShardFieldData.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.fielddata; -import com.carrotsearch.hppc.ObjectLongOpenHashMap; +import com.carrotsearch.hppc.ObjectLongHashMap; import org.apache.lucene.util.Accountable; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.metrics.CounterMetric; @@ -50,9 +50,9 @@ public class ShardFieldData extends AbstractIndexShardComponent implements Index } public FieldDataStats stats(String... fields) { - ObjectLongOpenHashMap fieldTotals = null; + ObjectLongHashMap fieldTotals = null; if (fields != null && fields.length > 0) { - fieldTotals = new ObjectLongOpenHashMap<>(); + fieldTotals = new ObjectLongHashMap<>(); for (Map.Entry entry : perFieldTotals.entrySet()) { if (Regex.simpleMatch(fields, entry.getKey())) { fieldTotals.put(entry.getKey(), entry.getValue().count()); diff --git a/src/main/java/org/elasticsearch/index/fielddata/plain/ParentChildIndexFieldData.java b/src/main/java/org/elasticsearch/index/fielddata/plain/ParentChildIndexFieldData.java index 6b4fea41894..4d34bafddde 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/plain/ParentChildIndexFieldData.java +++ b/src/main/java/org/elasticsearch/index/fielddata/plain/ParentChildIndexFieldData.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.fielddata.plain; -import com.carrotsearch.hppc.ObjectObjectOpenHashMap; +import com.carrotsearch.hppc.ObjectObjectHashMap; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import com.google.common.collect.ImmutableSortedSet; @@ -132,7 +132,7 @@ public class ParentChildIndexFieldData extends AbstractIndexFieldData typeBuilders = ObjectObjectOpenHashMap.newInstance(); + ObjectObjectHashMap typeBuilders = new ObjectObjectHashMap<>(); try { try { PostingsEnum docsEnum = null; diff --git a/src/main/java/org/elasticsearch/index/mapper/MapperService.java b/src/main/java/org/elasticsearch/index/mapper/MapperService.java index 809ea291ed7..4c76b30d65e 100755 --- a/src/main/java/org/elasticsearch/index/mapper/MapperService.java +++ b/src/main/java/org/elasticsearch/index/mapper/MapperService.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.mapper; -import com.carrotsearch.hppc.ObjectOpenHashSet; +import com.carrotsearch.hppc.ObjectHashSet; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -79,7 +79,7 @@ import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder; public class MapperService extends AbstractIndexComponent { public static final String DEFAULT_MAPPING = "_default_"; - private static ObjectOpenHashSet META_FIELDS = ObjectOpenHashSet.from( + private static ObjectHashSet META_FIELDS = ObjectHashSet.from( "_uid", "_id", "_type", "_all", "_parent", "_routing", "_index", "_size", "_timestamp", "_ttl" ); diff --git a/src/main/java/org/elasticsearch/index/mapper/ParseContext.java b/src/main/java/org/elasticsearch/index/mapper/ParseContext.java index b608cf8a551..eb41183ed34 100644 --- a/src/main/java/org/elasticsearch/index/mapper/ParseContext.java +++ b/src/main/java/org/elasticsearch/index/mapper/ParseContext.java @@ -20,7 +20,7 @@ package org.elasticsearch.index.mapper; import com.carrotsearch.hppc.ObjectObjectMap; -import com.carrotsearch.hppc.ObjectObjectOpenHashMap; +import com.carrotsearch.hppc.ObjectObjectHashMap; import com.google.common.collect.Lists; import org.apache.lucene.document.Field; @@ -106,7 +106,7 @@ public abstract class ParseContext { /** Add fields so that they can later be fetched using {@link #getByKey(Object)}. */ public void addWithKey(Object key, IndexableField field) { if (keyedFields == null) { - keyedFields = new ObjectObjectOpenHashMap<>(); + keyedFields = new ObjectObjectHashMap<>(); } else if (keyedFields.containsKey(key)) { throw new IllegalStateException("Only one field can be stored per key"); } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java index 425007219e3..c8482e7ed17 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java @@ -19,6 +19,7 @@ package org.elasticsearch.index.mapper.core; +import com.carrotsearch.hppc.ObjectHashSet; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import com.google.common.base.Function; diff --git a/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java index 05f4044d142..088be23c111 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java @@ -19,7 +19,9 @@ package org.elasticsearch.index.mapper.core; +import com.carrotsearch.hppc.DoubleHashSet; import com.carrotsearch.hppc.LongArrayList; +import com.carrotsearch.hppc.LongHashSet; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.NumericTokenStream; diff --git a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java index c04c3f14af3..ccc5d4d6d8a 100644 --- a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.mapper.geo; -import com.carrotsearch.hppc.ObjectOpenHashSet; +import com.carrotsearch.hppc.ObjectHashSet; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.google.common.base.Objects; import com.google.common.collect.Iterators; @@ -748,11 +748,11 @@ public class GeoPointFieldMapper extends AbstractFieldMapper implement TYPE.freeze(); } - private final ObjectOpenHashSet points; + private final ObjectHashSet points; public CustomGeoPointDocValuesField(String name, double lat, double lon) { super(name); - points = new ObjectOpenHashSet<>(2); + points = new ObjectHashSet<>(2); points.add(new GeoPoint(lat, lon)); } diff --git a/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java index e7bb3d7d215..d07f6d56c32 100644 --- a/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.query; -import com.carrotsearch.hppc.ObjectFloatOpenHashMap; +import com.carrotsearch.hppc.ObjectFloatHashMap; import com.google.common.collect.Lists; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.ParseField; @@ -41,7 +41,7 @@ public class MultiMatchQueryBuilder extends BaseQueryBuilder implements Boostabl private final Object text; private final List fields; - private ObjectFloatOpenHashMap fieldsBoosts; + private ObjectFloatHashMap fieldsBoosts; private MultiMatchQueryBuilder.Type type; @@ -176,7 +176,7 @@ public class MultiMatchQueryBuilder extends BaseQueryBuilder implements Boostabl public MultiMatchQueryBuilder field(String field, float boost) { fields.add(field); if (fieldsBoosts == null) { - fieldsBoosts = new ObjectFloatOpenHashMap<>(); + fieldsBoosts = new ObjectFloatHashMap<>(); } fieldsBoosts.put(field, boost); return this; @@ -336,8 +336,9 @@ public class MultiMatchQueryBuilder extends BaseQueryBuilder implements Boostabl builder.field("query", text); builder.startArray("fields"); for (String field : fields) { - if (fieldsBoosts != null && fieldsBoosts.containsKey(field)) { - field += "^" + fieldsBoosts.lget(); + final int keySlot; + if (fieldsBoosts != null && ((keySlot = fieldsBoosts.indexOf(field)) >= 0)) { + field += "^" + fieldsBoosts.indexGet(keySlot); } builder.value(field); } diff --git a/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java index d939a4654a2..7eb0de6b52a 100644 --- a/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.query; -import com.carrotsearch.hppc.ObjectFloatOpenHashMap; +import com.carrotsearch.hppc.ObjectFloatHashMap; import org.elasticsearch.common.unit.Fuzziness; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -80,7 +80,7 @@ public class QueryStringQueryBuilder extends BaseQueryBuilder implements Boostab private List fields; - private ObjectFloatOpenHashMap fieldsBoosts; + private ObjectFloatHashMap fieldsBoosts; private Boolean useDisMax; @@ -132,7 +132,7 @@ public class QueryStringQueryBuilder extends BaseQueryBuilder implements Boostab } fields.add(field); if (fieldsBoosts == null) { - fieldsBoosts = new ObjectFloatOpenHashMap<>(); + fieldsBoosts = new ObjectFloatHashMap<>(); } fieldsBoosts.put(field, boost); return this; diff --git a/src/main/java/org/elasticsearch/index/query/QueryStringQueryParser.java b/src/main/java/org/elasticsearch/index/query/QueryStringQueryParser.java index 402080789f4..63024d25200 100644 --- a/src/main/java/org/elasticsearch/index/query/QueryStringQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/QueryStringQueryParser.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.query; -import com.carrotsearch.hppc.ObjectFloatOpenHashMap; +import com.carrotsearch.hppc.ObjectFloatHashMap; import com.google.common.collect.Lists; import org.apache.lucene.queryparser.classic.MapperQueryParser; @@ -110,7 +110,7 @@ public class QueryStringQueryParser implements QueryParser { qpSettings.fields().add(field); if (fBoost != -1) { if (qpSettings.boosts() == null) { - qpSettings.boosts(new ObjectFloatOpenHashMap()); + qpSettings.boosts(new ObjectFloatHashMap()); } qpSettings.boosts().put(field, fBoost); } @@ -119,7 +119,7 @@ public class QueryStringQueryParser implements QueryParser { qpSettings.fields().add(fField); if (fBoost != -1) { if (qpSettings.boosts() == null) { - qpSettings.boosts(new ObjectFloatOpenHashMap()); + qpSettings.boosts(new ObjectFloatHashMap()); } qpSettings.boosts().put(fField, fBoost); } diff --git a/src/main/java/org/elasticsearch/indices/cache/query/IndicesQueryCache.java b/src/main/java/org/elasticsearch/indices/cache/query/IndicesQueryCache.java index 1f7486de4ac..06b2480f008 100644 --- a/src/main/java/org/elasticsearch/indices/cache/query/IndicesQueryCache.java +++ b/src/main/java/org/elasticsearch/indices/cache/query/IndicesQueryCache.java @@ -19,7 +19,7 @@ package org.elasticsearch.indices.cache.query; -import com.carrotsearch.hppc.ObjectOpenHashSet; +import com.carrotsearch.hppc.ObjectHashSet; import com.carrotsearch.hppc.ObjectSet; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; @@ -386,8 +386,8 @@ public class IndicesQueryCache extends AbstractComponent implements RemovalListe private class Reaper implements Runnable { - private final ObjectSet currentKeysToClean = ObjectOpenHashSet.newInstance(); - private final ObjectSet currentFullClean = ObjectOpenHashSet.newInstance(); + private final ObjectSet currentKeysToClean = new ObjectHashSet<>(); + private final ObjectSet currentFullClean = new ObjectHashSet<>(); private volatile boolean closed; diff --git a/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java b/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java index ca3b7e73744..e95715ddd1f 100644 --- a/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java +++ b/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java @@ -19,7 +19,7 @@ package org.elasticsearch.indices.cluster; -import com.carrotsearch.hppc.IntOpenHashSet; +import com.carrotsearch.hppc.IntHashSet; import com.carrotsearch.hppc.ObjectContainer; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.google.common.base.Predicate; @@ -262,7 +262,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent percolatorTypes; + private final ByteObjectHashMap percolatorTypes; private final PageCacheRecycler pageCacheRecycler; private final BigArrays bigArrays; private final ClusterService clusterService; @@ -153,7 +153,7 @@ public class PercolatorService extends AbstractComponent { single = new SingleDocumentPercolatorIndex(cache); multi = new MultiDocumentPercolatorIndex(cache); - percolatorTypes = new ByteObjectOpenHashMap<>(6); + percolatorTypes = new ByteObjectHashMap<>(6); percolatorTypes.put(countPercolator.id(), countPercolator); percolatorTypes.put(queryCountPercolator.id(), queryCountPercolator); percolatorTypes.put(matchPercolator.id(), matchPercolator); diff --git a/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java b/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java index 2334dc80bb3..c15e8c28c8c 100644 --- a/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java +++ b/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java @@ -19,7 +19,9 @@ package org.elasticsearch.rest.action.cat; -import com.carrotsearch.hppc.ObjectIntOpenHashMap; +import com.carrotsearch.hppc.ObjectIntHashMap; +import com.carrotsearch.hppc.ObjectIntScatterMap; + import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; @@ -98,7 +100,7 @@ public class RestAllocationAction extends AbstractCatAction { } private Table buildTable(RestRequest request, final ClusterStateResponse state, final NodesStatsResponse stats) { - final ObjectIntOpenHashMap allocs = new ObjectIntOpenHashMap<>(); + final ObjectIntScatterMap allocs = new ObjectIntScatterMap<>(); for (ShardRouting shard : state.getState().routingTable().allShards()) { String nodeId = "UNASSIGNED"; @@ -115,10 +117,7 @@ public class RestAllocationAction extends AbstractCatAction { for (NodeStats nodeStats : stats.getNodes()) { DiscoveryNode node = nodeStats.getNode(); - int shardCount = 0; - if (allocs.containsKey(node.id())) { - shardCount = allocs.lget(); - } + int shardCount = allocs.getOrDefault(node.id(), 0); ByteSizeValue total = nodeStats.getFs().getTotal().getTotal(); ByteSizeValue avail = nodeStats.getFs().getTotal().getAvailable(); @@ -144,16 +143,17 @@ public class RestAllocationAction extends AbstractCatAction { table.endRow(); } - if (allocs.containsKey("UNASSIGNED")) { + final String UNASSIGNED = "UNASSIGNED"; + if (allocs.containsKey(UNASSIGNED)) { table.startRow(); - table.addCell(allocs.lget()); + table.addCell(allocs.get(UNASSIGNED)); table.addCell(null); table.addCell(null); table.addCell(null); table.addCell(null); table.addCell(null); table.addCell(null); - table.addCell("UNASSIGNED"); + table.addCell(UNASSIGNED); table.endRow(); } diff --git a/src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java b/src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java index ed6c186a6dd..716074e6ff3 100644 --- a/src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java +++ b/src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.cat; import com.carrotsearch.hppc.ObjectLongMap; -import com.carrotsearch.hppc.ObjectLongOpenHashMap; +import com.carrotsearch.hppc.ObjectLongHashMap; import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; @@ -94,7 +94,7 @@ public class RestFielddataAction extends AbstractCatAction { // Collect all the field names so a new table can be built for (NodeStats ns : nodeStatses.getNodes()) { - ObjectLongOpenHashMap fields = ns.getIndices().getFieldData().getFields(); + ObjectLongHashMap fields = ns.getIndices().getFieldData().getFields(); nodesFields.put(ns, fields); if (fields != null) { for (String key : fields.keys().toArray(String.class)) { diff --git a/src/main/java/org/elasticsearch/search/SearchService.java b/src/main/java/org/elasticsearch/search/SearchService.java index 057b92a5912..e3eacef0160 100644 --- a/src/main/java/org/elasticsearch/search/SearchService.java +++ b/src/main/java/org/elasticsearch/search/SearchService.java @@ -19,7 +19,7 @@ package org.elasticsearch.search; -import com.carrotsearch.hppc.ObjectOpenHashSet; +import com.carrotsearch.hppc.ObjectHashSet; import com.carrotsearch.hppc.ObjectSet; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.google.common.base.Charsets; @@ -837,7 +837,7 @@ public class SearchService extends AbstractLifecycleComponent { public TerminationHandle warmNewReaders(final IndexShard indexShard, IndexMetaData indexMetaData, final WarmerContext context, ThreadPool threadPool) { final Loading defaultLoading = Loading.parse(indexMetaData.settings().get(NORMS_LOADING_KEY), Loading.LAZY); final MapperService mapperService = indexShard.mapperService(); - final ObjectSet warmUp = new ObjectOpenHashSet<>(); + final ObjectSet warmUp = new ObjectHashSet<>(); for (DocumentMapper docMapper : mapperService.docMappers(false)) { for (FieldMapper fieldMapper : docMapper.mappers()) { final String indexName = fieldMapper.names().indexName(); diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedAggregator.java index a81aae9eef6..43b0d4e2634 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedAggregator.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.search.aggregations.bucket.nested; -import com.carrotsearch.hppc.LongIntOpenHashMap; +import com.carrotsearch.hppc.LongIntHashMap; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.DocIdSetIterator; @@ -77,22 +77,24 @@ public class ReverseNestedAggregator extends SingleBucketAggregator { } else { parentDocs = docIdSet.bits(); } - final LongIntOpenHashMap bucketOrdToLastCollectedParentDoc = new LongIntOpenHashMap(32); + final LongIntHashMap bucketOrdToLastCollectedParentDoc = new LongIntHashMap(32); return new LeafBucketCollectorBase(sub, null) { @Override public void collect(int childDoc, long bucket) throws IOException { // fast forward to retrieve the parentDoc this childDoc belongs to final int parentDoc = parentDocs.nextSetBit(childDoc); assert childDoc <= parentDoc && parentDoc != DocIdSetIterator.NO_MORE_DOCS; - if (bucketOrdToLastCollectedParentDoc.containsKey(bucket)) { - int lastCollectedParentDoc = bucketOrdToLastCollectedParentDoc.lget(); + + int keySlot = bucketOrdToLastCollectedParentDoc.indexOf(bucket); + if (bucketOrdToLastCollectedParentDoc.indexExists(keySlot)) { + int lastCollectedParentDoc = bucketOrdToLastCollectedParentDoc.indexGet(keySlot); if (parentDoc > lastCollectedParentDoc) { collectBucket(sub, parentDoc, bucket); - bucketOrdToLastCollectedParentDoc.lset(parentDoc); + bucketOrdToLastCollectedParentDoc.indexReplace(keySlot, parentDoc); } } else { collectBucket(sub, parentDoc, bucket); - bucketOrdToLastCollectedParentDoc.put(bucket, parentDoc); + bucketOrdToLastCollectedParentDoc.indexInsert(keySlot, bucket, parentDoc); } } }; diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/support/IncludeExclude.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/support/IncludeExclude.java index c0488011a35..fb255e45373 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/support/IncludeExclude.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/support/IncludeExclude.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.search.aggregations.bucket.terms.support; -import com.carrotsearch.hppc.LongOpenHashSet; +import com.carrotsearch.hppc.LongHashSet; import com.carrotsearch.hppc.LongSet; import org.apache.lucene.index.RandomAccessOrds; @@ -59,10 +59,10 @@ public class IncludeExclude { private LongFilter(int numValids, int numInvalids) { if (numValids > 0) { - valids = new LongOpenHashSet(numValids); + valids = new LongHashSet(numValids); } if (numInvalids > 0) { - invalids = new LongOpenHashSet(numInvalids); + invalids = new LongHashSet(numInvalids); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/CardinalityAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/CardinalityAggregator.java index e00782687c9..c00acc4d626 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/CardinalityAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/CardinalityAggregator.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.aggregations.metrics.cardinality; -import com.carrotsearch.hppc.hash.MurmurHash3; +import com.carrotsearch.hppc.BitMixer; import com.google.common.base.Preconditions; import org.apache.lucene.index.LeafReaderContext; @@ -375,7 +375,7 @@ public class CardinalityAggregator extends NumericMetricsAggregator.SingleValue @Override public long valueAt(int index) { - return MurmurHash3.hash(values.valueAt(index)); + return BitMixer.mix64(values.valueAt(index)); } } @@ -399,7 +399,7 @@ public class CardinalityAggregator extends NumericMetricsAggregator.SingleValue @Override public long valueAt(int index) { - return MurmurHash3.hash(java.lang.Double.doubleToLongBits(values.valueAt(index))); + return BitMixer.mix64(java.lang.Double.doubleToLongBits(values.valueAt(index))); } } diff --git a/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java index 6974e7f0bb0..c56016d9464 100644 --- a/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java +++ b/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.builder; -import com.carrotsearch.hppc.ObjectFloatOpenHashMap; +import com.carrotsearch.hppc.ObjectFloatHashMap; import com.google.common.base.Charsets; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; @@ -117,7 +117,7 @@ public class SearchSourceBuilder implements ToXContent { private List rescoreBuilders; private Integer defaultRescoreWindowSize; - private ObjectFloatOpenHashMap indexBoost = null; + private ObjectFloatHashMap indexBoost = null; private String[] stats; @@ -653,7 +653,7 @@ public class SearchSourceBuilder implements ToXContent { */ public SearchSourceBuilder indexBoost(String index, float indexBoost) { if (this.indexBoost == null) { - this.indexBoost = new ObjectFloatOpenHashMap<>(); + this.indexBoost = new ObjectFloatHashMap<>(); } this.indexBoost.put(index, indexBoost); return this; @@ -809,11 +809,11 @@ public class SearchSourceBuilder implements ToXContent { if (indexBoost != null) { builder.startObject("indices_boost"); - final boolean[] states = indexBoost.allocated; + assert !indexBoost.containsKey(null); final Object[] keys = indexBoost.keys; final float[] values = indexBoost.values; - for (int i = 0; i < states.length; i++) { - if (states[i]) { + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null) { builder.field((String) keys[i], values[i]); } } diff --git a/src/main/java/org/elasticsearch/search/controller/SearchPhaseController.java b/src/main/java/org/elasticsearch/search/controller/SearchPhaseController.java index 4489d98c2c8..63eaf8189c0 100644 --- a/src/main/java/org/elasticsearch/search/controller/SearchPhaseController.java +++ b/src/main/java/org/elasticsearch/search/controller/SearchPhaseController.java @@ -20,7 +20,7 @@ package org.elasticsearch.search.controller; import com.carrotsearch.hppc.IntArrayList; -import com.carrotsearch.hppc.ObjectObjectOpenHashMap; +import com.carrotsearch.hppc.ObjectObjectHashMap; import com.google.common.collect.Lists; import org.apache.lucene.index.Term; @@ -102,8 +102,8 @@ public class SearchPhaseController extends AbstractComponent { } public AggregatedDfs aggregateDfs(AtomicArray results) { - ObjectObjectOpenHashMap termStatistics = HppcMaps.newNoNullKeysMap(); - ObjectObjectOpenHashMap fieldStatistics = HppcMaps.newNoNullKeysMap(); + ObjectObjectHashMap termStatistics = HppcMaps.newNoNullKeysMap(); + ObjectObjectHashMap fieldStatistics = HppcMaps.newNoNullKeysMap(); long aggMaxDoc = 0; for (AtomicArray.Entry lEntry : results.asList()) { final Term[] terms = lEntry.value.terms(); @@ -124,11 +124,12 @@ public class SearchPhaseController extends AbstractComponent { } } - final boolean[] states = lEntry.value.fieldStatistics().allocated; + + assert !lEntry.value.fieldStatistics().containsKey(null); final Object[] keys = lEntry.value.fieldStatistics().keys; final Object[] values = lEntry.value.fieldStatistics().values; - for (int i = 0; i < states.length; i++) { - if (states[i]) { + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null) { String key = (String) keys[i]; CollectionStatistics value = (CollectionStatistics) values[i]; assert key != null; diff --git a/src/main/java/org/elasticsearch/search/dfs/AggregatedDfs.java b/src/main/java/org/elasticsearch/search/dfs/AggregatedDfs.java index 9a817a85538..d8330e5ec15 100644 --- a/src/main/java/org/elasticsearch/search/dfs/AggregatedDfs.java +++ b/src/main/java/org/elasticsearch/search/dfs/AggregatedDfs.java @@ -20,7 +20,9 @@ package org.elasticsearch.search.dfs; -import com.carrotsearch.hppc.ObjectObjectOpenHashMap; +import com.carrotsearch.hppc.ObjectObjectHashMap; +import com.carrotsearch.hppc.cursors.ObjectObjectCursor; + import org.apache.lucene.index.Term; import org.apache.lucene.search.CollectionStatistics; import org.apache.lucene.search.TermStatistics; @@ -33,24 +35,24 @@ import java.io.IOException; public class AggregatedDfs implements Streamable { - private ObjectObjectOpenHashMap termStatistics; - private ObjectObjectOpenHashMap fieldStatistics; + private ObjectObjectHashMap termStatistics; + private ObjectObjectHashMap fieldStatistics; private long maxDoc; private AggregatedDfs() { } - public AggregatedDfs(ObjectObjectOpenHashMap termStatistics, ObjectObjectOpenHashMap fieldStatistics, long maxDoc) { + public AggregatedDfs(ObjectObjectHashMap termStatistics, ObjectObjectHashMap fieldStatistics, long maxDoc) { this.termStatistics = termStatistics; this.fieldStatistics = fieldStatistics; this.maxDoc = maxDoc; } - public ObjectObjectOpenHashMap termStatistics() { + public ObjectObjectHashMap termStatistics() { return termStatistics; } - public ObjectObjectOpenHashMap fieldStatistics() { + public ObjectObjectHashMap fieldStatistics() { return fieldStatistics; } @@ -82,20 +84,17 @@ public class AggregatedDfs implements Streamable { @Override public void writeTo(final StreamOutput out) throws IOException { out.writeVInt(termStatistics.size()); - final boolean[] states = termStatistics.allocated; - final Object[] keys = termStatistics.keys; - final Object[] values = termStatistics.values; - for (int i = 0; i < states.length; i++) { - if (states[i]) { - Term term = (Term) keys[i]; - out.writeString(term.field()); - out.writeBytesRef(term.bytes()); - TermStatistics stats = (TermStatistics) values[i]; - out.writeBytesRef(stats.term()); - out.writeVLong(stats.docFreq()); - out.writeVLong(DfsSearchResult.addOne(stats.totalTermFreq())); - } + + for (ObjectObjectCursor c : termStatistics()) { + Term term = (Term) c.key; + out.writeString(term.field()); + out.writeBytesRef(term.bytes()); + TermStatistics stats = (TermStatistics) c.value; + out.writeBytesRef(stats.term()); + out.writeVLong(stats.docFreq()); + out.writeVLong(DfsSearchResult.addOne(stats.totalTermFreq())); } + DfsSearchResult.writeFieldStats(out, fieldStatistics); out.writeVLong(maxDoc); } diff --git a/src/main/java/org/elasticsearch/search/dfs/DfsPhase.java b/src/main/java/org/elasticsearch/search/dfs/DfsPhase.java index 85a7d490373..3a87979c719 100644 --- a/src/main/java/org/elasticsearch/search/dfs/DfsPhase.java +++ b/src/main/java/org/elasticsearch/search/dfs/DfsPhase.java @@ -19,8 +19,8 @@ package org.elasticsearch.search.dfs; -import com.carrotsearch.hppc.ObjectObjectOpenHashMap; -import com.carrotsearch.hppc.ObjectOpenHashSet; +import com.carrotsearch.hppc.ObjectObjectHashMap; +import com.carrotsearch.hppc.ObjectHashSet; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.google.common.collect.ImmutableMap; import org.apache.lucene.index.IndexReaderContext; @@ -55,7 +55,7 @@ public class DfsPhase implements SearchPhase { @Override public void execute(SearchContext context) { - final ObjectOpenHashSet termsSet = new ObjectOpenHashSet<>(); + final ObjectHashSet termsSet = new ObjectHashSet<>(); try { if (!context.queryRewritten()) { context.updateRewriteQuery(context.searcher().rewrite(context.query())); @@ -75,7 +75,7 @@ public class DfsPhase implements SearchPhase { termStatistics[i] = context.searcher().termStatistics(terms[i], termContext); } - ObjectObjectOpenHashMap fieldStatistics = HppcMaps.newNoNullKeysMap(); + ObjectObjectHashMap fieldStatistics = HppcMaps.newNoNullKeysMap(); for (Term term : terms) { assert term.field() != null : "field is null"; if (!fieldStatistics.containsKey(term.field())) { @@ -97,9 +97,9 @@ public class DfsPhase implements SearchPhase { // We need to bridge to JCF world, b/c of Query#extractTerms private static class DelegateSet extends AbstractSet { - private final ObjectOpenHashSet delegate; + private final ObjectHashSet delegate; - private DelegateSet(ObjectOpenHashSet delegate) { + private DelegateSet(ObjectHashSet delegate) { this.delegate = delegate; } diff --git a/src/main/java/org/elasticsearch/search/dfs/DfsSearchResult.java b/src/main/java/org/elasticsearch/search/dfs/DfsSearchResult.java index c55572e7d2f..c86af528bfc 100644 --- a/src/main/java/org/elasticsearch/search/dfs/DfsSearchResult.java +++ b/src/main/java/org/elasticsearch/search/dfs/DfsSearchResult.java @@ -19,7 +19,9 @@ package org.elasticsearch.search.dfs; -import com.carrotsearch.hppc.ObjectObjectOpenHashMap; +import com.carrotsearch.hppc.ObjectObjectHashMap; +import com.carrotsearch.hppc.cursors.ObjectObjectCursor; + import org.apache.lucene.index.Term; import org.apache.lucene.search.CollectionStatistics; import org.apache.lucene.search.TermStatistics; @@ -45,7 +47,7 @@ public class DfsSearchResult extends TransportResponse implements SearchPhaseRes private long id; private Term[] terms; private TermStatistics[] termStatistics; - private ObjectObjectOpenHashMap fieldStatistics = HppcMaps.newNoNullKeysMap(); + private ObjectObjectHashMap fieldStatistics = HppcMaps.newNoNullKeysMap(); private int maxDoc; public DfsSearchResult() { @@ -87,7 +89,7 @@ public class DfsSearchResult extends TransportResponse implements SearchPhaseRes return this; } - public DfsSearchResult fieldStatistics(ObjectObjectOpenHashMap fieldStatistics) { + public DfsSearchResult fieldStatistics(ObjectObjectHashMap fieldStatistics) { this.fieldStatistics = fieldStatistics; return this; } @@ -100,7 +102,7 @@ public class DfsSearchResult extends TransportResponse implements SearchPhaseRes return termStatistics; } - public ObjectObjectOpenHashMap fieldStatistics() { + public ObjectObjectHashMap fieldStatistics() { return fieldStatistics; } @@ -145,21 +147,17 @@ public class DfsSearchResult extends TransportResponse implements SearchPhaseRes out.writeVInt(maxDoc); } - public static void writeFieldStats(StreamOutput out, ObjectObjectOpenHashMap fieldStatistics) throws IOException { + public static void writeFieldStats(StreamOutput out, ObjectObjectHashMap fieldStatistics) throws IOException { out.writeVInt(fieldStatistics.size()); - final boolean[] states = fieldStatistics.allocated; - Object[] keys = fieldStatistics.keys; - Object[] values = fieldStatistics.values; - for (int i = 0; i < states.length; i++) { - if (states[i]) { - out.writeString((String) keys[i]); - CollectionStatistics statistics = (CollectionStatistics) values[i]; - assert statistics.maxDoc() >= 0; - out.writeVLong(statistics.maxDoc()); - out.writeVLong(addOne(statistics.docCount())); - out.writeVLong(addOne(statistics.sumTotalTermFreq())); - out.writeVLong(addOne(statistics.sumDocFreq())); - } + + for (ObjectObjectCursor c : fieldStatistics) { + out.writeString(c.key); + CollectionStatistics statistics = c.value; + assert statistics.maxDoc() >= 0; + out.writeVLong(statistics.maxDoc()); + out.writeVLong(addOne(statistics.docCount())); + out.writeVLong(addOne(statistics.sumTotalTermFreq())); + out.writeVLong(addOne(statistics.sumDocFreq())); } } @@ -176,11 +174,11 @@ public class DfsSearchResult extends TransportResponse implements SearchPhaseRes out.writeVLong(addOne(termStatistic.totalTermFreq())); } - public static ObjectObjectOpenHashMap readFieldStats(StreamInput in) throws IOException { + public static ObjectObjectHashMap readFieldStats(StreamInput in) throws IOException { return readFieldStats(in, null); } - public static ObjectObjectOpenHashMap readFieldStats(StreamInput in, ObjectObjectOpenHashMap fieldStatistics) throws IOException { + public static ObjectObjectHashMap readFieldStats(StreamInput in, ObjectObjectHashMap fieldStatistics) throws IOException { final int numFieldStatistics = in.readVInt(); if (fieldStatistics == null) { fieldStatistics = HppcMaps.newNoNullKeysMap(numFieldStatistics); diff --git a/src/main/java/org/elasticsearch/search/internal/InternalSearchHits.java b/src/main/java/org/elasticsearch/search/internal/InternalSearchHits.java index 107609566cf..393b7b6ad8c 100644 --- a/src/main/java/org/elasticsearch/search/internal/InternalSearchHits.java +++ b/src/main/java/org/elasticsearch/search/internal/InternalSearchHits.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.internal; -import com.carrotsearch.hppc.IntObjectOpenHashMap; +import com.carrotsearch.hppc.IntObjectHashMap; import com.google.common.collect.Iterators; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -51,7 +51,7 @@ public class InternalSearchHits implements SearchHits { } private IdentityHashMap shardHandleLookup = new IdentityHashMap<>(); - private IntObjectOpenHashMap handleShardLookup = new IntObjectOpenHashMap<>(); + private IntObjectHashMap handleShardLookup = new IntObjectHashMap<>(); private ShardTargetType streamShardTarget = ShardTargetType.STREAM; public StreamContext reset() { @@ -65,7 +65,7 @@ public class InternalSearchHits implements SearchHits { return shardHandleLookup; } - public IntObjectOpenHashMap handleShardLookup() { + public IntObjectHashMap handleShardLookup() { return handleShardLookup; } diff --git a/src/main/java/org/elasticsearch/search/suggest/completion/AnalyzingCompletionLookupProvider.java b/src/main/java/org/elasticsearch/search/suggest/completion/AnalyzingCompletionLookupProvider.java index c06ae487aa0..b95d7200d08 100644 --- a/src/main/java/org/elasticsearch/search/suggest/completion/AnalyzingCompletionLookupProvider.java +++ b/src/main/java/org/elasticsearch/search/suggest/completion/AnalyzingCompletionLookupProvider.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.suggest.completion; -import com.carrotsearch.hppc.ObjectLongOpenHashMap; +import com.carrotsearch.hppc.ObjectLongHashMap; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.codecs.CodecUtil; @@ -283,9 +283,9 @@ public class AnalyzingCompletionLookupProvider extends CompletionLookupProvider @Override public CompletionStats stats(String... fields) { long sizeInBytes = 0; - ObjectLongOpenHashMap completionFields = null; + ObjectLongHashMap completionFields = null; if (fields != null && fields.length > 0) { - completionFields = new ObjectLongOpenHashMap<>(fields.length); + completionFields = new ObjectLongHashMap<>(fields.length); } for (Map.Entry entry : lookupMap.entrySet()) { diff --git a/src/main/java/org/elasticsearch/search/suggest/completion/CompletionStats.java b/src/main/java/org/elasticsearch/search/suggest/completion/CompletionStats.java index 60857d67a35..5ec517dd8d0 100644 --- a/src/main/java/org/elasticsearch/search/suggest/completion/CompletionStats.java +++ b/src/main/java/org/elasticsearch/search/suggest/completion/CompletionStats.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.search.suggest.completion; -import com.carrotsearch.hppc.ObjectLongOpenHashMap; +import com.carrotsearch.hppc.ObjectLongHashMap; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -38,12 +38,12 @@ public class CompletionStats implements Streamable, ToXContent { private long sizeInBytes; @Nullable - private ObjectLongOpenHashMap fields; + private ObjectLongHashMap fields; public CompletionStats() { } - public CompletionStats(long size, @Nullable ObjectLongOpenHashMap fields) { + public CompletionStats(long size, @Nullable ObjectLongHashMap fields) { this.sizeInBytes = size; this.fields = fields; } @@ -56,7 +56,7 @@ public class CompletionStats implements Streamable, ToXContent { return new ByteSizeValue(sizeInBytes); } - public ObjectLongOpenHashMap getFields() { + public ObjectLongHashMap getFields() { return fields; } @@ -65,7 +65,7 @@ public class CompletionStats implements Streamable, ToXContent { sizeInBytes = in.readVLong(); if (in.readBoolean()) { int size = in.readVInt(); - fields = new ObjectLongOpenHashMap<>(size); + fields = new ObjectLongHashMap<>(size); for (int i = 0; i < size; i++) { fields.put(in.readString(), in.readVLong()); } @@ -80,11 +80,12 @@ public class CompletionStats implements Streamable, ToXContent { } else { out.writeBoolean(true); out.writeVInt(fields.size()); - final boolean[] states = fields.allocated; + + assert !fields.containsKey(null); final Object[] keys = fields.keys; final long[] values = fields.values; - for (int i = 0; i < states.length; i++) { - if (states[i]) { + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null) { out.writeString((String) keys[i]); out.writeVLong(values[i]); } @@ -98,11 +99,12 @@ public class CompletionStats implements Streamable, ToXContent { builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, sizeInBytes); if (fields != null) { builder.startObject(Fields.FIELDS); - final boolean[] states = fields.allocated; + + assert !fields.containsKey(null); final Object[] keys = fields.keys; final long[] values = fields.values; - for (int i = 0; i < states.length; i++) { - if (states[i]) { + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null) { builder.startObject((String) keys[i], XContentBuilder.FieldCaseConversion.NONE); builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, values[i]); builder.endObject(); @@ -135,14 +137,16 @@ public class CompletionStats implements Streamable, ToXContent { sizeInBytes += completion.getSizeInBytes(); if (completion.fields != null) { - if (fields == null) fields = new ObjectLongOpenHashMap<>(); - - final boolean[] states = completion.fields.allocated; - final Object[] keys = completion.fields.keys; - final long[] values = completion.fields.values; - for (int i = 0; i < states.length; i++) { - if (states[i]) { - fields.addTo((String) keys[i], values[i]); + if (fields == null) { + fields = completion.fields.clone(); + } else { + assert !completion.fields.containsKey(null); + final Object[] keys = completion.fields.keys; + final long[] values = completion.fields.values; + for (int i = 0; i < keys.length; i++) { + if (keys[i] != null) { + fields.addTo((String) keys[i], values[i]); + } } } } diff --git a/src/main/java/org/elasticsearch/search/suggest/context/GeolocationContextMapping.java b/src/main/java/org/elasticsearch/search/suggest/context/GeolocationContextMapping.java index b67f655d40a..cfa0c750ee6 100644 --- a/src/main/java/org/elasticsearch/search/suggest/context/GeolocationContextMapping.java +++ b/src/main/java/org/elasticsearch/search/suggest/context/GeolocationContextMapping.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.suggest.context; -import com.carrotsearch.hppc.IntOpenHashSet; +import com.carrotsearch.hppc.IntHashSet; import com.google.common.collect.Lists; import org.apache.lucene.analysis.PrefixAnalyzer.PrefixTokenFilter; import org.apache.lucene.analysis.TokenStream; @@ -368,7 +368,7 @@ public class GeolocationContextMapping extends ContextMapping { } } else if (FIELD_PRECISION.equals(fieldName)) { if(parser.nextToken() == Token.START_ARRAY) { - IntOpenHashSet precisions = new IntOpenHashSet(); + IntHashSet precisions = new IntHashSet(); while(parser.nextToken() != Token.END_ARRAY) { precisions.add(parsePrecision(parser)); } @@ -448,7 +448,7 @@ public class GeolocationContextMapping extends ContextMapping { public static class Builder extends ContextBuilder { - private IntOpenHashSet precisions = new IntOpenHashSet(); + private IntHashSet precisions = new IntHashSet(); private boolean neighbors; // take neighbor cell on the lowest level into account private HashSet defaultLocations = new HashSet<>(); private String fieldName = null; diff --git a/src/main/java/org/elasticsearch/snapshots/RestoreService.java b/src/main/java/org/elasticsearch/snapshots/RestoreService.java index b544922e0f8..f37e9c1d272 100644 --- a/src/main/java/org/elasticsearch/snapshots/RestoreService.java +++ b/src/main/java/org/elasticsearch/snapshots/RestoreService.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.snapshots; -import com.carrotsearch.hppc.IntOpenHashSet; +import com.carrotsearch.hppc.IntHashSet; import com.carrotsearch.hppc.IntSet; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; @@ -185,7 +185,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis snapshotIndexMetaData = updateIndexSettings(snapshotIndexMetaData, request.indexSettings, request.ignoreIndexSettings); // Check that the index is closed or doesn't exist IndexMetaData currentIndexMetaData = currentState.metaData().index(renamedIndex); - IntSet ignoreShards = new IntOpenHashSet(); + IntSet ignoreShards = new IntHashSet(); if (currentIndexMetaData == null) { // Index doesn't exist - create it and start recovery // Make sure that the index we are about to create has a validate name diff --git a/src/main/java/org/elasticsearch/transport/TransportMessage.java b/src/main/java/org/elasticsearch/transport/TransportMessage.java index 5a82bd10e35..5e9755013e0 100644 --- a/src/main/java/org/elasticsearch/transport/TransportMessage.java +++ b/src/main/java/org/elasticsearch/transport/TransportMessage.java @@ -19,7 +19,6 @@ package org.elasticsearch.transport; -import com.carrotsearch.hppc.ObjectObjectOpenHashMap; import org.elasticsearch.common.ContextHolder; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; diff --git a/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsTests.java b/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsTests.java index 5828f644670..492e91289d4 100644 --- a/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsTests.java +++ b/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.action.termvectors; -import com.carrotsearch.hppc.ObjectIntOpenHashMap; +import com.carrotsearch.hppc.ObjectIntHashMap; import org.apache.lucene.analysis.payloads.PayloadHelper; import org.apache.lucene.document.FieldType; @@ -493,7 +493,7 @@ public class GetTermVectorsTests extends AbstractTermVectorsTests { private String createString(String[] tokens, Map> payloads, int encoding, char delimiter) { String resultString = ""; - ObjectIntOpenHashMap payloadCounter = new ObjectIntOpenHashMap<>(); + ObjectIntHashMap payloadCounter = new ObjectIntHashMap<>(); for (String token : tokens) { if (!payloadCounter.containsKey(token)) { payloadCounter.putIfAbsent(token, 0); diff --git a/src/test/java/org/elasticsearch/aliases/IndexAliasesTests.java b/src/test/java/org/elasticsearch/aliases/IndexAliasesTests.java index b033fa812cc..922dda803d5 100644 --- a/src/test/java/org/elasticsearch/aliases/IndexAliasesTests.java +++ b/src/test/java/org/elasticsearch/aliases/IndexAliasesTests.java @@ -601,12 +601,12 @@ public class IndexAliasesTests extends ElasticsearchIntegrationTest { assertThat(getResponse.getAliases().size(), equalTo(1)); assertThat(getResponse.getAliases().get("foobar").size(), equalTo(2)); assertThat(getResponse.getAliases().get("foobar").get(0), notNullValue()); - assertThat(getResponse.getAliases().get("foobar").get(0).alias(), equalTo("alias2")); + assertThat(getResponse.getAliases().get("foobar").get(0).alias(), equalTo("alias1")); assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue()); assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue()); assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue()); assertThat(getResponse.getAliases().get("foobar").get(1), notNullValue()); - assertThat(getResponse.getAliases().get("foobar").get(1).alias(), equalTo("alias1")); + assertThat(getResponse.getAliases().get("foobar").get(1).alias(), equalTo("alias2")); assertThat(getResponse.getAliases().get("foobar").get(1).getFilter(), nullValue()); assertThat(getResponse.getAliases().get("foobar").get(1).getIndexRouting(), nullValue()); assertThat(getResponse.getAliases().get("foobar").get(1).getSearchRouting(), nullValue()); diff --git a/src/test/java/org/elasticsearch/benchmark/hppc/StringMapAdjustOrPutBenchmark.java b/src/test/java/org/elasticsearch/benchmark/hppc/StringMapAdjustOrPutBenchmark.java index 6555b1789ec..e51ba31b6d1 100644 --- a/src/test/java/org/elasticsearch/benchmark/hppc/StringMapAdjustOrPutBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/hppc/StringMapAdjustOrPutBenchmark.java @@ -19,10 +19,10 @@ package org.elasticsearch.benchmark.hppc; -import com.carrotsearch.hppc.IntIntOpenHashMap; -import com.carrotsearch.hppc.IntObjectOpenHashMap; -import com.carrotsearch.hppc.ObjectIntOpenHashMap; -import com.carrotsearch.hppc.ObjectObjectOpenHashMap; +import com.carrotsearch.hppc.IntIntHashMap; +import com.carrotsearch.hppc.IntObjectHashMap; +import com.carrotsearch.hppc.ObjectIntHashMap; +import com.carrotsearch.hppc.ObjectObjectHashMap; import com.carrotsearch.randomizedtesting.generators.RandomStrings; import org.elasticsearch.common.StopWatch; import org.elasticsearch.common.unit.SizeValue; @@ -31,6 +31,12 @@ import java.util.HashMap; import java.util.IdentityHashMap; import java.util.concurrent.ThreadLocalRandom; +// TODO: these benchmarks aren't too good and may be easily skewed by jit doing +// escape analysis/ side-effects/ local +// optimisations. Proper benchmarks with JMH (bulk ops, single-shot mode) +// should be better here. +// https://github.com/carrotsearch/hppc/blob/master/hppc-benchmarks/src/main/java/com/carrotsearch/hppc/benchmarks/B003_HashSet_Contains.java + public class StringMapAdjustOrPutBenchmark { public static void main(String[] args) { @@ -50,12 +56,12 @@ public class StringMapAdjustOrPutBenchmark { StopWatch stopWatch; stopWatch = new StopWatch().start(); - ObjectIntOpenHashMap map = new ObjectIntOpenHashMap<>(); + ObjectIntHashMap map = new ObjectIntHashMap<>(); for (long iter = 0; iter < ITERATIONS; iter++) { if (REUSE) { map.clear(); } else { - map = new ObjectIntOpenHashMap<>(); + map = new ObjectIntHashMap<>(); } for (long i = 0; i < PUT_OPERATIONS; i++) { map.addTo(values[(int) (i % NUMBER_OF_KEYS)], 1); @@ -69,12 +75,12 @@ public class StringMapAdjustOrPutBenchmark { stopWatch = new StopWatch().start(); // TObjectIntCustomHashMap iMap = new TObjectIntCustomHashMap(new StringIdentityHashingStrategy()); - ObjectIntOpenHashMap iMap = new ObjectIntOpenHashMap<>(); + ObjectIntHashMap iMap = new ObjectIntHashMap<>(); for (long iter = 0; iter < ITERATIONS; iter++) { if (REUSE) { iMap.clear(); } else { - iMap = new ObjectIntOpenHashMap<>(); + iMap = new ObjectIntHashMap<>(); } for (long i = 0; i < PUT_OPERATIONS; i++) { iMap.addTo(values[(int) (i % NUMBER_OF_KEYS)], 1); @@ -86,12 +92,12 @@ public class StringMapAdjustOrPutBenchmark { iMap = null; stopWatch = new StopWatch().start(); - iMap = new ObjectIntOpenHashMap<>(); + iMap = new ObjectIntHashMap<>(); for (long iter = 0; iter < ITERATIONS; iter++) { if (REUSE) { iMap.clear(); } else { - iMap = new ObjectIntOpenHashMap<>(); + iMap = new ObjectIntHashMap<>(); } for (long i = 0; i < PUT_OPERATIONS; i++) { iMap.addTo(values[(int) (i % NUMBER_OF_KEYS)], 1); @@ -104,12 +110,12 @@ public class StringMapAdjustOrPutBenchmark { // now test with THashMap stopWatch = new StopWatch().start(); - ObjectObjectOpenHashMap tMap = new ObjectObjectOpenHashMap<>(); + ObjectObjectHashMap tMap = new ObjectObjectHashMap<>(); for (long iter = 0; iter < ITERATIONS; iter++) { if (REUSE) { tMap.clear(); } else { - tMap = new ObjectObjectOpenHashMap<>(); + tMap = new ObjectObjectHashMap<>(); } for (long i = 0; i < PUT_OPERATIONS; i++) { String key = values[(int) (i % NUMBER_OF_KEYS)]; @@ -187,12 +193,12 @@ public class StringMapAdjustOrPutBenchmark { } stopWatch = new StopWatch().start(); - IntIntOpenHashMap intMap = new IntIntOpenHashMap(); + IntIntHashMap intMap = new IntIntHashMap(); for (long iter = 0; iter < ITERATIONS; iter++) { if (REUSE) { intMap.clear(); } else { - intMap = new IntIntOpenHashMap(); + intMap = new IntIntHashMap(); } for (long i = 0; i < PUT_OPERATIONS; i++) { int key = iValues[(int) (i % NUMBER_OF_KEYS)]; @@ -207,12 +213,12 @@ public class StringMapAdjustOrPutBenchmark { // now test with THashMap stopWatch = new StopWatch().start(); - IntObjectOpenHashMap tIntMap = new IntObjectOpenHashMap<>(); + IntObjectHashMap tIntMap = new IntObjectHashMap<>(); for (long iter = 0; iter < ITERATIONS; iter++) { if (REUSE) { tIntMap.clear(); } else { - tIntMap = new IntObjectOpenHashMap<>(); + tIntMap = new IntObjectHashMap<>(); } for (long i = 0; i < PUT_OPERATIONS; i++) { int key = iValues[(int) (i % NUMBER_OF_KEYS)]; diff --git a/src/test/java/org/elasticsearch/benchmark/search/aggregations/GlobalOrdinalsBenchmark.java b/src/test/java/org/elasticsearch/benchmark/search/aggregations/GlobalOrdinalsBenchmark.java index c1ea372cc53..c5f3b95a795 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/aggregations/GlobalOrdinalsBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/search/aggregations/GlobalOrdinalsBenchmark.java @@ -18,8 +18,8 @@ */ package org.elasticsearch.benchmark.search.aggregations; -import com.carrotsearch.hppc.IntIntOpenHashMap; -import com.carrotsearch.hppc.ObjectOpenHashSet; +import com.carrotsearch.hppc.IntIntHashMap; +import com.carrotsearch.hppc.ObjectHashSet; import com.carrotsearch.randomizedtesting.generators.RandomStrings; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse; @@ -111,7 +111,7 @@ public class GlobalOrdinalsBenchmark { .endArray() .endObject().endObject()) .get(); - ObjectOpenHashSet uniqueTerms = ObjectOpenHashSet.newInstance(); + ObjectHashSet uniqueTerms = new ObjectHashSet<>(); for (int i = 0; i < FIELD_LIMIT; i++) { boolean added; do { @@ -122,16 +122,11 @@ public class GlobalOrdinalsBenchmark { uniqueTerms = null; BulkRequestBuilder builder = client.prepareBulk(); - IntIntOpenHashMap tracker = new IntIntOpenHashMap(); + IntIntHashMap tracker = new IntIntHashMap(); for (int i = 0; i < COUNT; i++) { Map fieldValues = new HashMap<>(); for (int fieldSuffix = 1; fieldSuffix <= FIELD_LIMIT; fieldSuffix <<= 1) { - int index; - if (tracker.containsKey(fieldSuffix)) { - index = tracker.lget(); - } else { - tracker.put(fieldSuffix, index = 0); - } + int index = tracker.putOrAdd(fieldSuffix, 0, 0); if (index >= fieldSuffix) { index = random.nextInt(fieldSuffix); fieldValues.put("field_" + fieldSuffix, sValues[index]); diff --git a/src/test/java/org/elasticsearch/benchmark/search/aggregations/SubAggregationSearchCollectModeBenchmark.java b/src/test/java/org/elasticsearch/benchmark/search/aggregations/SubAggregationSearchCollectModeBenchmark.java index 83184452146..d003dc0cc9e 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/aggregations/SubAggregationSearchCollectModeBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/search/aggregations/SubAggregationSearchCollectModeBenchmark.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.benchmark.search.aggregations; -import com.carrotsearch.hppc.ObjectOpenHashSet; +import com.carrotsearch.hppc.ObjectScatterSet; import com.carrotsearch.randomizedtesting.generators.RandomStrings; import com.google.common.collect.Lists; @@ -137,7 +137,7 @@ public class SubAggregationSearchCollectModeBenchmark { for (int i = 0; i < NUMBER_OF_TERMS; i++) { lValues[i] = ThreadLocalRandom.current().nextLong(); } - ObjectOpenHashSet uniqueTerms = ObjectOpenHashSet.newInstance(); + ObjectScatterSet uniqueTerms = new ObjectScatterSet<>(); for (int i = 0; i < NUMBER_OF_TERMS; i++) { boolean added; do { diff --git a/src/test/java/org/elasticsearch/benchmark/search/aggregations/TermsAggregationSearchAndIndexingBenchmark.java b/src/test/java/org/elasticsearch/benchmark/search/aggregations/TermsAggregationSearchAndIndexingBenchmark.java index 91bb5ce1787..ea876a008e2 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/aggregations/TermsAggregationSearchAndIndexingBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/search/aggregations/TermsAggregationSearchAndIndexingBenchmark.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.benchmark.search.aggregations; -import com.carrotsearch.hppc.ObjectOpenHashSet; +import com.carrotsearch.hppc.ObjectScatterSet; import com.carrotsearch.randomizedtesting.generators.RandomStrings; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse; @@ -96,7 +96,7 @@ public class TermsAggregationSearchAndIndexingBenchmark { Thread.sleep(5000); long startTime = System.currentTimeMillis(); - ObjectOpenHashSet uniqueTerms = ObjectOpenHashSet.newInstance(); + ObjectScatterSet uniqueTerms = new ObjectScatterSet<>(); for (int i = 0; i < NUMBER_OF_TERMS; i++) { boolean added; do { diff --git a/src/test/java/org/elasticsearch/benchmark/search/aggregations/TermsAggregationSearchBenchmark.java b/src/test/java/org/elasticsearch/benchmark/search/aggregations/TermsAggregationSearchBenchmark.java index e9ec2d89f73..26a64255ac2 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/aggregations/TermsAggregationSearchBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/search/aggregations/TermsAggregationSearchBenchmark.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.benchmark.search.aggregations; -import com.carrotsearch.hppc.ObjectOpenHashSet; +import com.carrotsearch.hppc.ObjectScatterSet; import com.carrotsearch.randomizedtesting.generators.RandomStrings; import com.google.common.collect.Lists; @@ -28,7 +28,6 @@ import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.SearchType; import org.elasticsearch.client.Client; import org.elasticsearch.client.Requests; import org.elasticsearch.common.StopWatch; @@ -161,7 +160,7 @@ public class TermsAggregationSearchBenchmark { .endObject() .endObject())).actionGet(); - ObjectOpenHashSet uniqueTerms = ObjectOpenHashSet.newInstance(); + ObjectScatterSet uniqueTerms = new ObjectScatterSet<>(); for (int i = 0; i < NUMBER_OF_TERMS; i++) { boolean added; do { diff --git a/src/test/java/org/elasticsearch/benchmark/search/child/ParentChildIndexGenerator.java b/src/test/java/org/elasticsearch/benchmark/search/child/ParentChildIndexGenerator.java index 4dc785b1dc1..1d02a1f5f3e 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/child/ParentChildIndexGenerator.java +++ b/src/test/java/org/elasticsearch/benchmark/search/child/ParentChildIndexGenerator.java @@ -20,7 +20,7 @@ package org.elasticsearch.benchmark.search.child; import com.carrotsearch.hppc.ObjectArrayList; -import com.carrotsearch.hppc.ObjectOpenHashSet; +import com.carrotsearch.hppc.ObjectHashSet; import com.carrotsearch.randomizedtesting.generators.RandomStrings; import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkResponse; @@ -49,8 +49,8 @@ public class ParentChildIndexGenerator { public void index() { // Memory intensive... - ObjectOpenHashSet usedParentIds = ObjectOpenHashSet.newInstanceWithCapacity(numParents, 0.5f); - ObjectArrayList parents = ObjectArrayList.newInstanceWithCapacity(numParents); + ObjectHashSet usedParentIds = new ObjectHashSet<>(numParents, 0.5d); + ObjectArrayList parents = new ObjectArrayList<>(numParents); for (int i = 0; i < numParents; i++) { String parentId; diff --git a/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationTests.java b/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationTests.java index b01e16f1ca8..cc0a275327e 100644 --- a/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationTests.java +++ b/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationTests.java @@ -19,9 +19,8 @@ package org.elasticsearch.cluster.allocation; -import com.carrotsearch.hppc.ObjectIntOpenHashMap; +import com.carrotsearch.hppc.ObjectIntHashMap; import com.google.common.base.Predicate; -import org.apache.lucene.util.LuceneTestCase.Slow; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.routing.IndexRoutingTable; @@ -32,7 +31,6 @@ import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.discovery.zen.ZenDiscovery; import org.elasticsearch.discovery.zen.elect.ElectMasterService; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope; @@ -95,7 +93,7 @@ public class AwarenessAllocationTests extends ElasticsearchIntegrationTest { logger.info("--> checking current state"); ClusterState clusterState = client().admin().cluster().prepareState().execute().actionGet().getState(); // verify that we have all the primaries on node3 - ObjectIntOpenHashMap counts = new ObjectIntOpenHashMap<>(); + ObjectIntHashMap counts = new ObjectIntHashMap<>(); for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { for (ShardRouting shardRouting : indexShardRoutingTable) { @@ -133,7 +131,7 @@ public class AwarenessAllocationTests extends ElasticsearchIntegrationTest { ClusterHealthResponse health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().setWaitForNodes("4").setWaitForRelocatingShards(0).execute().actionGet(); assertThat(health.isTimedOut(), equalTo(false)); ClusterState clusterState = client().admin().cluster().prepareState().execute().actionGet().getState(); - ObjectIntOpenHashMap counts = new ObjectIntOpenHashMap<>(); + ObjectIntHashMap counts = new ObjectIntHashMap<>(); for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { @@ -169,7 +167,7 @@ public class AwarenessAllocationTests extends ElasticsearchIntegrationTest { ClusterHealthResponse health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().setWaitForNodes("2").setWaitForRelocatingShards(0).execute().actionGet(); assertThat(health.isTimedOut(), equalTo(false)); ClusterState clusterState = client().admin().cluster().prepareState().execute().actionGet().getState(); - ObjectIntOpenHashMap counts = new ObjectIntOpenHashMap<>(); + ObjectIntHashMap counts = new ObjectIntHashMap<>(); for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { @@ -191,7 +189,7 @@ public class AwarenessAllocationTests extends ElasticsearchIntegrationTest { assertThat(health.isTimedOut(), equalTo(false)); clusterState = client().admin().cluster().prepareState().execute().actionGet().getState(); - counts = new ObjectIntOpenHashMap<>(); + counts = new ObjectIntHashMap<>(); for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { @@ -213,7 +211,7 @@ public class AwarenessAllocationTests extends ElasticsearchIntegrationTest { assertThat(health.isTimedOut(), equalTo(false)); clusterState = client().admin().cluster().prepareState().execute().actionGet().getState(); - counts = new ObjectIntOpenHashMap<>(); + counts = new ObjectIntHashMap<>(); for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { @@ -234,7 +232,7 @@ public class AwarenessAllocationTests extends ElasticsearchIntegrationTest { assertThat(health.isTimedOut(), equalTo(false)); clusterState = client().admin().cluster().prepareState().execute().actionGet().getState(); - counts = new ObjectIntOpenHashMap<>(); + counts = new ObjectIntHashMap<>(); for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { diff --git a/src/test/java/org/elasticsearch/cluster/metadata/MetaDataTests.java b/src/test/java/org/elasticsearch/cluster/metadata/MetaDataTests.java index 8576e0f19b0..7d780e95aa2 100644 --- a/src/test/java/org/elasticsearch/cluster/metadata/MetaDataTests.java +++ b/src/test/java/org/elasticsearch/cluster/metadata/MetaDataTests.java @@ -30,6 +30,7 @@ import org.elasticsearch.indices.IndexMissingException; import org.elasticsearch.test.ElasticsearchTestCase; import org.junit.Test; +import java.util.Arrays; import java.util.HashSet; import static com.google.common.collect.Sets.newHashSet; @@ -67,9 +68,8 @@ public class MetaDataTests extends ElasticsearchTestCase { assertThat(results, arrayContainingInAnyOrder("foofoo", "foobar")); results = md.concreteIndices(options, "foofoobar"); - assertEquals(2, results.length); - assertEquals("foo", results[0]); - assertEquals("foobar", results[1]); + assertEquals(new HashSet<>(Arrays.asList("foo", "foobar")), + new HashSet<>(Arrays.asList(results))); try { md.concreteIndices(options, "bar"); @@ -151,8 +151,8 @@ public class MetaDataTests extends ElasticsearchTestCase { results = md.concreteIndices(options, "foofoobar"); assertEquals(2, results.length); - assertEquals("foo", results[0]); - assertEquals("foobar", results[1]); + assertEquals(new HashSet<>(Arrays.asList("foo", "foobar")), + new HashSet<>(Arrays.asList(results))); results = md.concreteIndices(options, "foo", "bar"); assertEquals(1, results.length); diff --git a/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java b/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java index 83a27850591..2625229fa37 100644 --- a/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java +++ b/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java @@ -59,6 +59,7 @@ public class ClusterSerializationTests extends ElasticsearchAllocationTestCase { ClusterState serializedClusterState = ClusterState.Builder.fromBytes(ClusterState.Builder.toBytes(clusterState), newNode("node1")); assertThat(serializedClusterState.getClusterName().value(), equalTo(clusterState.getClusterName().value())); + assertThat(serializedClusterState.routingTable().prettyPrint(), equalTo(clusterState.routingTable().prettyPrint())); } diff --git a/src/test/java/org/elasticsearch/common/hppc/HppcMapsTests.java b/src/test/java/org/elasticsearch/common/hppc/HppcMapsTests.java index 68b894a45fd..f3534da9f38 100644 --- a/src/test/java/org/elasticsearch/common/hppc/HppcMapsTests.java +++ b/src/test/java/org/elasticsearch/common/hppc/HppcMapsTests.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.common.hppc; -import com.carrotsearch.hppc.ObjectOpenHashSet; +import com.carrotsearch.hppc.ObjectHashSet; import org.elasticsearch.common.collect.HppcMaps; import org.elasticsearch.test.ElasticsearchTestCase; import org.junit.Test; @@ -35,48 +35,48 @@ public class HppcMapsTests extends ElasticsearchTestCase { boolean enabled = false; assert enabled = true; assumeTrue("assertions enabled", enabled); - ObjectOpenHashSet set1 = ObjectOpenHashSet.from("1", "2", "3"); - ObjectOpenHashSet set2 = ObjectOpenHashSet.from("1", "2", "3"); + ObjectHashSet set1 = ObjectHashSet.from("1", "2", "3"); + ObjectHashSet set2 = ObjectHashSet.from("1", "2", "3"); List values = toList(HppcMaps.intersection(set1, set2)); assertThat(values.size(), equalTo(3)); assertThat(values.contains("1"), equalTo(true)); assertThat(values.contains("2"), equalTo(true)); assertThat(values.contains("3"), equalTo(true)); - set1 = ObjectOpenHashSet.from("1", "2", "3"); - set2 = ObjectOpenHashSet.from("3", "4", "5"); + set1 = ObjectHashSet.from("1", "2", "3"); + set2 = ObjectHashSet.from("3", "4", "5"); values = toList(HppcMaps.intersection(set1, set2)); assertThat(values.size(), equalTo(1)); assertThat(values.get(0), equalTo("3")); - set1 = ObjectOpenHashSet.from("1", "2", "3"); - set2 = ObjectOpenHashSet.from("4", "5", "6"); + set1 = ObjectHashSet.from("1", "2", "3"); + set2 = ObjectHashSet.from("4", "5", "6"); values = toList(HppcMaps.intersection(set1, set2)); assertThat(values.size(), equalTo(0)); - set1 = ObjectOpenHashSet.from(); - set2 = ObjectOpenHashSet.from("3", "4", "5"); + set1 = ObjectHashSet.from(); + set2 = ObjectHashSet.from("3", "4", "5"); values = toList(HppcMaps.intersection(set1, set2)); assertThat(values.size(), equalTo(0)); - set1 = ObjectOpenHashSet.from("1", "2", "3"); - set2 = ObjectOpenHashSet.from(); + set1 = ObjectHashSet.from("1", "2", "3"); + set2 = ObjectHashSet.from(); values = toList(HppcMaps.intersection(set1, set2)); assertThat(values.size(), equalTo(0)); - set1 = ObjectOpenHashSet.from(); - set2 = ObjectOpenHashSet.from(); + set1 = ObjectHashSet.from(); + set2 = ObjectHashSet.from(); values = toList(HppcMaps.intersection(set1, set2)); assertThat(values.size(), equalTo(0)); set1 = null; - set2 = ObjectOpenHashSet.from(); + set2 = ObjectHashSet.from(); try { toList(HppcMaps.intersection(set1, set2)); fail(); } catch (AssertionError e) {} - set1 = ObjectOpenHashSet.from(); + set1 = ObjectHashSet.from(); set2 = null; try { toList(HppcMaps.intersection(set1, set2)); diff --git a/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java b/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java index 1fb7ee967cf..e7d98db5c59 100644 --- a/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java +++ b/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.common.util; import com.carrotsearch.hppc.ObjectLongMap; -import com.carrotsearch.hppc.ObjectLongOpenHashMap; +import com.carrotsearch.hppc.ObjectLongHashMap; import com.carrotsearch.hppc.cursors.ObjectLongCursor; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRefBuilder; @@ -56,7 +56,7 @@ public class BytesRefHashTests extends ElasticsearchSingleNodeTest { for (int i = 0; i < values.length; ++i) { values[i] = new BytesRef(randomAsciiOfLength(5)); } - final ObjectLongMap valueToId = new ObjectLongOpenHashMap<>(); + final ObjectLongMap valueToId = new ObjectLongHashMap<>(); final BytesRef[] idToValue = new BytesRef[values.length]; final int iters = randomInt(1000000); for (int i = 0; i < iters; ++i) { diff --git a/src/test/java/org/elasticsearch/common/util/LongHashTests.java b/src/test/java/org/elasticsearch/common/util/LongHashTests.java index 63a4758dec2..d35a6f14163 100644 --- a/src/test/java/org/elasticsearch/common/util/LongHashTests.java +++ b/src/test/java/org/elasticsearch/common/util/LongHashTests.java @@ -19,8 +19,8 @@ package org.elasticsearch.common.util; +import com.carrotsearch.hppc.LongLongHashMap; import com.carrotsearch.hppc.LongLongMap; -import com.carrotsearch.hppc.LongLongOpenHashMap; import com.carrotsearch.hppc.cursors.LongLongCursor; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Test; @@ -52,7 +52,7 @@ public class LongHashTests extends ElasticsearchSingleNodeTest { for (int i = 0; i < values.length; ++i) { values[i] = randomLong(); } - final LongLongMap valueToId = new LongLongOpenHashMap(); + final LongLongMap valueToId = new LongLongHashMap(); final long[] idToValue = new long[values.length]; final int iters = randomInt(1000000); for (int i = 0; i < iters; ++i) { diff --git a/src/test/java/org/elasticsearch/common/util/LongObjectHashMapTests.java b/src/test/java/org/elasticsearch/common/util/LongObjectHashMapTests.java index 409a09a513c..fae90cd395b 100644 --- a/src/test/java/org/elasticsearch/common/util/LongObjectHashMapTests.java +++ b/src/test/java/org/elasticsearch/common/util/LongObjectHashMapTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.util; -import com.carrotsearch.hppc.LongObjectOpenHashMap; +import com.carrotsearch.hppc.LongObjectHashMap; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Test; @@ -27,7 +27,7 @@ public class LongObjectHashMapTests extends ElasticsearchSingleNodeTest { @Test public void duel() { - final LongObjectOpenHashMap map1 = new LongObjectOpenHashMap<>(); + final LongObjectHashMap map1 = new LongObjectHashMap<>(); final LongObjectPagedHashMap map2 = new LongObjectPagedHashMap<>(randomInt(42), 0.6f + randomFloat() * 0.39f, BigArraysTests.randombigArrays()); final int maxKey = randomIntBetween(1, 10000); final int iters = scaledRandomIntBetween(10000, 100000); @@ -48,7 +48,7 @@ public class LongObjectHashMapTests extends ElasticsearchSingleNodeTest { for (int i = 0; i <= maxKey; ++i) { assertSame(map1.get(i), map2.get(i)); } - final LongObjectOpenHashMap copy = new LongObjectOpenHashMap<>(); + final LongObjectHashMap copy = new LongObjectHashMap<>(); for (LongObjectPagedHashMap.Cursor cursor : map2) { copy.put(cursor.key, cursor.value); } diff --git a/src/test/java/org/elasticsearch/index/fielddata/LongFieldDataTests.java b/src/test/java/org/elasticsearch/index/fielddata/LongFieldDataTests.java index 257b4b5611f..2b293bd088f 100644 --- a/src/test/java/org/elasticsearch/index/fielddata/LongFieldDataTests.java +++ b/src/test/java/org/elasticsearch/index/fielddata/LongFieldDataTests.java @@ -19,8 +19,11 @@ package org.elasticsearch.index.fielddata; -import com.carrotsearch.hppc.DoubleOpenHashSet; -import com.carrotsearch.hppc.LongOpenHashSet; +import com.carrotsearch.hppc.DoubleHashSet; +import com.carrotsearch.hppc.LongHashSet; +import com.carrotsearch.hppc.cursors.DoubleCursor; +import com.carrotsearch.hppc.cursors.LongCursor; + import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.LongField; @@ -324,22 +327,17 @@ public class LongFieldDataTests extends AbstractNumericFieldDataTests { public abstract long nextValue(Random r); } - private void test(List values) throws Exception { + private void test(List values) throws Exception { StringField id = new StringField("_id", "", Field.Store.NO); for (int i = 0; i < values.size(); ++i) { Document doc = new Document(); id.setStringValue("" + i); doc.add(id); - final LongOpenHashSet v = values.get(i); - final boolean[] states = v.allocated; - final long[] keys = v.keys; - - for (int j = 0; j < states.length; j++) { - if (states[j]) { - LongField value = new LongField("value", keys[j], Field.Store.NO); - doc.add(value); - } + final LongHashSet v = values.get(i); + for (LongCursor c : v) { + LongField value = new LongField("value", c.value, Field.Store.NO); + doc.add(value); } writer.addDocument(doc); } @@ -349,10 +347,10 @@ public class LongFieldDataTests extends AbstractNumericFieldDataTests { final AtomicNumericFieldData atomicFieldData = indexFieldData.load(refreshReader()); final SortedNumericDocValues data = atomicFieldData.getLongValues(); final SortedNumericDoubleValues doubleData = atomicFieldData.getDoubleValues(); - final LongOpenHashSet set = new LongOpenHashSet(); - final DoubleOpenHashSet doubleSet = new DoubleOpenHashSet(); + final LongHashSet set = new LongHashSet(); + final DoubleHashSet doubleSet = new DoubleHashSet(); for (int i = 0; i < values.size(); ++i) { - final LongOpenHashSet v = values.get(i); + final LongHashSet v = values.get(i); data.setDocument(i); assertThat(data.count() > 0, equalTo(!v.isEmpty())); @@ -367,13 +365,9 @@ public class LongFieldDataTests extends AbstractNumericFieldDataTests { } assertThat(set, equalTo(v)); - final DoubleOpenHashSet doubleV = new DoubleOpenHashSet(); - final boolean[] states = v.allocated; - final long[] keys = v.keys; - for (int j = 0; j < states.length; j++) { - if (states[j]) { - doubleV.add((double) keys[j]); - } + final DoubleHashSet doubleV = new DoubleHashSet(); + for (LongCursor c : v) { + doubleV.add(c.value); } doubleSet.clear(); doubleData.setDocument(i); @@ -394,10 +388,10 @@ public class LongFieldDataTests extends AbstractNumericFieldDataTests { private void test(Data data) throws Exception { Random r = getRandom(); final int numDocs = 1000 + r.nextInt(19000); - final List values = new ArrayList<>(numDocs); + final List values = new ArrayList<>(numDocs); for (int i = 0; i < numDocs; ++i) { final int numValues = data.numValues(r); - final LongOpenHashSet vals = new LongOpenHashSet(numValues); + final LongHashSet vals = new LongHashSet(numValues); for (int j = 0; j < numValues; ++j) { vals.add(data.nextValue(r)); } diff --git a/src/test/java/org/elasticsearch/index/search/child/ChildrenConstantScoreQueryTests.java b/src/test/java/org/elasticsearch/index/search/child/ChildrenConstantScoreQueryTests.java index a8f319be0b5..53bfa8cb510 100644 --- a/src/test/java/org/elasticsearch/index/search/child/ChildrenConstantScoreQueryTests.java +++ b/src/test/java/org/elasticsearch/index/search/child/ChildrenConstantScoreQueryTests.java @@ -18,8 +18,8 @@ */ package org.elasticsearch.index.search.child; -import com.carrotsearch.hppc.IntOpenHashSet; -import com.carrotsearch.hppc.ObjectObjectOpenHashMap; +import com.carrotsearch.hppc.IntHashSet; +import com.carrotsearch.hppc.ObjectObjectHashMap; import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.document.Document; @@ -155,10 +155,10 @@ public class ChildrenConstantScoreQueryTests extends AbstractChildTests { childValues[i] = Integer.toString(i); } - IntOpenHashSet filteredOrDeletedDocs = new IntOpenHashSet(); + IntHashSet filteredOrDeletedDocs = new IntHashSet(); int childDocId = 0; int numParentDocs = scaledRandomIntBetween(1, numUniqueChildValues); - ObjectObjectOpenHashMap> childValueToParentIds = new ObjectObjectOpenHashMap<>(); + ObjectObjectHashMap> childValueToParentIds = new ObjectObjectHashMap<>(); for (int parentDocId = 0; parentDocId < numParentDocs; parentDocId++) { boolean markParentAsDeleted = rarely(); boolean filterMe = rarely(); @@ -194,7 +194,7 @@ public class ChildrenConstantScoreQueryTests extends AbstractChildTests { if (!markChildAsDeleted) { NavigableSet parentIds; if (childValueToParentIds.containsKey(childValue)) { - parentIds = childValueToParentIds.lget(); + parentIds = childValueToParentIds.get(childValue); } else { childValueToParentIds.put(childValue, parentIds = new TreeSet<>()); } @@ -271,7 +271,7 @@ public class ChildrenConstantScoreQueryTests extends AbstractChildTests { LeafReader slowLeafReader = SlowCompositeReaderWrapper.wrap(indexReader); Terms terms = slowLeafReader.terms(UidFieldMapper.NAME); if (terms != null) { - NavigableSet parentIds = childValueToParentIds.lget(); + NavigableSet parentIds = childValueToParentIds.get(childValue); TermsEnum termsEnum = terms.iterator(); PostingsEnum docsEnum = null; for (String id : parentIds) { diff --git a/src/test/java/org/elasticsearch/index/search/child/ChildrenQueryTests.java b/src/test/java/org/elasticsearch/index/search/child/ChildrenQueryTests.java index ed235a07e6f..1dd9d5de2c1 100644 --- a/src/test/java/org/elasticsearch/index/search/child/ChildrenQueryTests.java +++ b/src/test/java/org/elasticsearch/index/search/child/ChildrenQueryTests.java @@ -19,8 +19,8 @@ package org.elasticsearch.index.search.child; import com.carrotsearch.hppc.FloatArrayList; -import com.carrotsearch.hppc.IntOpenHashSet; -import com.carrotsearch.hppc.ObjectObjectOpenHashMap; +import com.carrotsearch.hppc.IntHashSet; +import com.carrotsearch.hppc.ObjectObjectHashMap; import com.carrotsearch.randomizedtesting.generators.RandomInts; import org.apache.lucene.analysis.MockAnalyzer; @@ -131,11 +131,11 @@ public class ChildrenQueryTests extends AbstractChildTests { childValues[i] = Integer.toString(i); } - IntOpenHashSet filteredOrDeletedDocs = new IntOpenHashSet(); + IntHashSet filteredOrDeletedDocs = new IntHashSet(); int childDocId = 0; int numParentDocs = scaledRandomIntBetween(1, numUniqueChildValues); - ObjectObjectOpenHashMap> childValueToParentIds = new ObjectObjectOpenHashMap<>(); + ObjectObjectHashMap> childValueToParentIds = new ObjectObjectHashMap<>(); for (int parentDocId = 0; parentDocId < numParentDocs; parentDocId++) { boolean markParentAsDeleted = rarely(); boolean filterMe = rarely(); @@ -171,7 +171,7 @@ public class ChildrenQueryTests extends AbstractChildTests { if (!markChildAsDeleted) { NavigableMap parentIdToChildScores; if (childValueToParentIds.containsKey(childValue)) { - parentIdToChildScores = childValueToParentIds.lget(); + parentIdToChildScores = childValueToParentIds.get(childValue); } else { childValueToParentIds.put(childValue, parentIdToChildScores = new TreeMap<>()); } @@ -255,7 +255,7 @@ public class ChildrenQueryTests extends AbstractChildTests { final FloatArrayList[] scores = new FloatArrayList[slowLeafReader.maxDoc()]; Terms terms = slowLeafReader.terms(UidFieldMapper.NAME); if (terms != null) { - NavigableMap parentIdToChildScores = childValueToParentIds.lget(); + NavigableMap parentIdToChildScores = childValueToParentIds.get(childValue); TermsEnum termsEnum = terms.iterator(); PostingsEnum docsEnum = null; for (Map.Entry entry : parentIdToChildScores.entrySet()) { diff --git a/src/test/java/org/elasticsearch/index/search/child/ParentConstantScoreQueryTests.java b/src/test/java/org/elasticsearch/index/search/child/ParentConstantScoreQueryTests.java index 7f1e83771a4..a42e940569b 100644 --- a/src/test/java/org/elasticsearch/index/search/child/ParentConstantScoreQueryTests.java +++ b/src/test/java/org/elasticsearch/index/search/child/ParentConstantScoreQueryTests.java @@ -18,8 +18,8 @@ */ package org.elasticsearch.index.search.child; -import com.carrotsearch.hppc.IntIntOpenHashMap; -import com.carrotsearch.hppc.ObjectObjectOpenHashMap; +import com.carrotsearch.hppc.IntIntHashMap; +import com.carrotsearch.hppc.ObjectObjectHashMap; import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.document.Document; @@ -112,8 +112,8 @@ public class ParentConstantScoreQueryTests extends AbstractChildTests { int childDocId = 0; int numParentDocs = scaledRandomIntBetween(1, numUniqueParentValues); - ObjectObjectOpenHashMap> parentValueToChildDocIds = new ObjectObjectOpenHashMap<>(); - IntIntOpenHashMap childIdToParentId = new IntIntOpenHashMap(); + ObjectObjectHashMap> parentValueToChildDocIds = new ObjectObjectHashMap<>(); + IntIntHashMap childIdToParentId = new IntIntHashMap(); for (int parentDocId = 0; parentDocId < numParentDocs; parentDocId++) { boolean markParentAsDeleted = rarely(); String parentValue = parentValues[random().nextInt(parentValues.length)]; @@ -152,7 +152,7 @@ public class ParentConstantScoreQueryTests extends AbstractChildTests { if (!markParentAsDeleted) { NavigableSet childIds; if (parentValueToChildDocIds.containsKey(parentValue)) { - childIds = parentValueToChildDocIds.lget(); + childIds = parentValueToChildDocIds.get(parentValue); } else { parentValueToChildDocIds.put(parentValue, childIds = new TreeSet<>()); } @@ -222,7 +222,7 @@ public class ParentConstantScoreQueryTests extends AbstractChildTests { LeafReader slowLeafReader = SlowCompositeReaderWrapper.wrap(indexReader); Terms terms = slowLeafReader.terms(UidFieldMapper.NAME); if (terms != null) { - NavigableSet childIds = parentValueToChildDocIds.lget(); + NavigableSet childIds = parentValueToChildDocIds.get(parentValue); TermsEnum termsEnum = terms.iterator(); PostingsEnum docsEnum = null; for (String id : childIds) { diff --git a/src/test/java/org/elasticsearch/index/search/child/ParentQueryTests.java b/src/test/java/org/elasticsearch/index/search/child/ParentQueryTests.java index 6b6a260ee64..a0e6e542106 100644 --- a/src/test/java/org/elasticsearch/index/search/child/ParentQueryTests.java +++ b/src/test/java/org/elasticsearch/index/search/child/ParentQueryTests.java @@ -19,8 +19,8 @@ package org.elasticsearch.index.search.child; import com.carrotsearch.hppc.FloatArrayList; -import com.carrotsearch.hppc.IntIntOpenHashMap; -import com.carrotsearch.hppc.ObjectObjectOpenHashMap; +import com.carrotsearch.hppc.IntIntHashMap; +import com.carrotsearch.hppc.ObjectObjectHashMap; import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.document.Document; @@ -116,8 +116,8 @@ public class ParentQueryTests extends AbstractChildTests { int childDocId = 0; int numParentDocs = scaledRandomIntBetween(1, numUniqueParentValues); - ObjectObjectOpenHashMap> parentValueToChildIds = new ObjectObjectOpenHashMap<>(); - IntIntOpenHashMap childIdToParentId = new IntIntOpenHashMap(); + ObjectObjectHashMap> parentValueToChildIds = new ObjectObjectHashMap<>(); + IntIntHashMap childIdToParentId = new IntIntHashMap(); for (int parentDocId = 0; parentDocId < numParentDocs; parentDocId++) { boolean markParentAsDeleted = rarely(); String parentValue = parentValues[random().nextInt(parentValues.length)]; @@ -153,10 +153,8 @@ public class ParentQueryTests extends AbstractChildTests { indexWriter.addDocument(document); if (!markParentAsDeleted) { - NavigableMap childIdToScore; - if (parentValueToChildIds.containsKey(parentValue)) { - childIdToScore = parentValueToChildIds.lget(); - } else { + NavigableMap childIdToScore = parentValueToChildIds.getOrDefault(parentValue, null); + if (childIdToScore == null) { parentValueToChildIds.put(parentValue, childIdToScore = new TreeMap<>()); } if (!markChildAsDeleted && !filterMe) { @@ -226,7 +224,7 @@ public class ParentQueryTests extends AbstractChildTests { final FloatArrayList[] scores = new FloatArrayList[slowLeafReader.maxDoc()]; Terms terms = slowLeafReader.terms(UidFieldMapper.NAME); if (terms != null) { - NavigableMap childIdsAndScore = parentValueToChildIds.lget(); + NavigableMap childIdsAndScore = parentValueToChildIds.get(parentValue); TermsEnum termsEnum = terms.iterator(); PostingsEnum docsEnum = null; for (Map.Entry entry : childIdsAndScore.entrySet()) { diff --git a/src/test/java/org/elasticsearch/indices/stats/IndexStatsTests.java b/src/test/java/org/elasticsearch/indices/stats/IndexStatsTests.java index 96d875b2e18..2f04e0a21c3 100644 --- a/src/test/java/org/elasticsearch/indices/stats/IndexStatsTests.java +++ b/src/test/java/org/elasticsearch/indices/stats/IndexStatsTests.java @@ -711,27 +711,27 @@ public class IndexStatsTests extends ElasticsearchIntegrationTest { stats = builder.setFieldDataFields("bar").execute().actionGet(); assertThat(stats.getTotal().fieldData.getMemorySizeInBytes(), greaterThan(0l)); assertThat(stats.getTotal().fieldData.getFields().containsKey("bar"), is(true)); - assertThat(stats.getTotal().fieldData.getFields().lget(), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getFields().get("bar"), greaterThan(0l)); assertThat(stats.getTotal().fieldData.getFields().containsKey("baz"), is(false)); stats = builder.setFieldDataFields("bar", "baz").execute().actionGet(); assertThat(stats.getTotal().fieldData.getMemorySizeInBytes(), greaterThan(0l)); assertThat(stats.getTotal().fieldData.getFields().containsKey("bar"), is(true)); - assertThat(stats.getTotal().fieldData.getFields().lget(), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getFields().get("bar"), greaterThan(0l)); assertThat(stats.getTotal().fieldData.getFields().containsKey("baz"), is(true)); - assertThat(stats.getTotal().fieldData.getFields().lget(), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getFields().get("baz"), greaterThan(0l)); stats = builder.setFieldDataFields("*").execute().actionGet(); assertThat(stats.getTotal().fieldData.getMemorySizeInBytes(), greaterThan(0l)); assertThat(stats.getTotal().fieldData.getFields().containsKey("bar"), is(true)); - assertThat(stats.getTotal().fieldData.getFields().lget(), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getFields().get("bar"), greaterThan(0l)); assertThat(stats.getTotal().fieldData.getFields().containsKey("baz"), is(true)); - assertThat(stats.getTotal().fieldData.getFields().lget(), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getFields().get("baz"), greaterThan(0l)); stats = builder.setFieldDataFields("*r").execute().actionGet(); assertThat(stats.getTotal().fieldData.getMemorySizeInBytes(), greaterThan(0l)); assertThat(stats.getTotal().fieldData.getFields().containsKey("bar"), is(true)); - assertThat(stats.getTotal().fieldData.getFields().lget(), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getFields().get("bar"), greaterThan(0l)); assertThat(stats.getTotal().fieldData.getFields().containsKey("baz"), is(false)); } @@ -758,27 +758,27 @@ public class IndexStatsTests extends ElasticsearchIntegrationTest { stats = builder.setCompletionFields("bar.completion").execute().actionGet(); assertThat(stats.getTotal().completion.getSizeInBytes(), greaterThan(0l)); assertThat(stats.getTotal().completion.getFields().containsKey("bar.completion"), is(true)); - assertThat(stats.getTotal().completion.getFields().lget(), greaterThan(0l)); + assertThat(stats.getTotal().completion.getFields().get("bar.completion"), greaterThan(0l)); assertThat(stats.getTotal().completion.getFields().containsKey("baz.completion"), is(false)); stats = builder.setCompletionFields("bar.completion", "baz.completion").execute().actionGet(); assertThat(stats.getTotal().completion.getSizeInBytes(), greaterThan(0l)); assertThat(stats.getTotal().completion.getFields().containsKey("bar.completion"), is(true)); - assertThat(stats.getTotal().completion.getFields().lget(), greaterThan(0l)); + assertThat(stats.getTotal().completion.getFields().get("bar.completion"), greaterThan(0l)); assertThat(stats.getTotal().completion.getFields().containsKey("baz.completion"), is(true)); - assertThat(stats.getTotal().completion.getFields().lget(), greaterThan(0l)); + assertThat(stats.getTotal().completion.getFields().get("baz.completion"), greaterThan(0l)); stats = builder.setCompletionFields("*").execute().actionGet(); assertThat(stats.getTotal().completion.getSizeInBytes(), greaterThan(0l)); assertThat(stats.getTotal().completion.getFields().containsKey("bar.completion"), is(true)); - assertThat(stats.getTotal().completion.getFields().lget(), greaterThan(0l)); + assertThat(stats.getTotal().completion.getFields().get("bar.completion"), greaterThan(0l)); assertThat(stats.getTotal().completion.getFields().containsKey("baz.completion"), is(true)); - assertThat(stats.getTotal().completion.getFields().lget(), greaterThan(0l)); + assertThat(stats.getTotal().completion.getFields().get("baz.completion"), greaterThan(0l)); stats = builder.setCompletionFields("*r*").execute().actionGet(); assertThat(stats.getTotal().completion.getSizeInBytes(), greaterThan(0l)); assertThat(stats.getTotal().completion.getFields().containsKey("bar.completion"), is(true)); - assertThat(stats.getTotal().completion.getFields().lget(), greaterThan(0l)); + assertThat(stats.getTotal().completion.getFields().get("bar.completion"), greaterThan(0l)); assertThat(stats.getTotal().completion.getFields().containsKey("baz.completion"), is(false)); } diff --git a/src/test/java/org/elasticsearch/recovery/RelocationTests.java b/src/test/java/org/elasticsearch/recovery/RelocationTests.java index 18bea8cf6c5..8e131e99f90 100644 --- a/src/test/java/org/elasticsearch/recovery/RelocationTests.java +++ b/src/test/java/org/elasticsearch/recovery/RelocationTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.recovery; -import com.carrotsearch.hppc.IntOpenHashSet; +import com.carrotsearch.hppc.IntHashSet; import com.carrotsearch.hppc.procedures.IntProcedure; import com.google.common.base.Predicate; import com.google.common.util.concurrent.ListenableFuture; @@ -229,7 +229,7 @@ public class RelocationTests extends ElasticsearchIntegrationTest { for (int hit = 0; hit < indexer.totalIndexedDocs(); hit++) { hitIds[hit] = hit + 1; } - IntOpenHashSet set = IntOpenHashSet.from(hitIds); + IntHashSet set = IntHashSet.from(hitIds); for (SearchHit hit : hits.hits()) { int id = Integer.parseInt(hit.id()); if (!set.remove(id)) { diff --git a/src/test/java/org/elasticsearch/search/aggregations/CombiTests.java b/src/test/java/org/elasticsearch/search/aggregations/CombiTests.java index 2c19d957d8f..4888996f35f 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/CombiTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/CombiTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.search.aggregations; import com.carrotsearch.hppc.IntIntMap; -import com.carrotsearch.hppc.IntIntOpenHashMap; +import com.carrotsearch.hppc.IntIntHashMap; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchResponse; @@ -60,7 +60,7 @@ public class CombiTests extends ElasticsearchIntegrationTest { createIndex("idx"); IndexRequestBuilder[] builders = new IndexRequestBuilder[randomInt(30)]; - IntIntMap values = new IntIntOpenHashMap(); + IntIntMap values = new IntIntHashMap(); long missingValues = 0; for (int i = 0; i < builders.length; i++) { String name = "name_" + randomIntBetween(1, 10); diff --git a/src/test/java/org/elasticsearch/search/aggregations/EquivalenceTests.java b/src/test/java/org/elasticsearch/search/aggregations/EquivalenceTests.java index 948fcc9aeea..bd14009e683 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/EquivalenceTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/EquivalenceTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.aggregations; -import com.carrotsearch.hppc.IntOpenHashSet; +import com.carrotsearch.hppc.IntHashSet; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -174,7 +174,7 @@ public class EquivalenceTests extends ElasticsearchIntegrationTest { final int numDocs = scaledRandomIntBetween(1000, 2000); final int maxNumTerms = randomIntBetween(10, 5000); - final IntOpenHashSet valuesSet = new IntOpenHashSet(); + final IntHashSet valuesSet = new IntHashSet(); cluster().wipeIndices("idx"); prepareCreate("idx") .addMapping("type", jsonBuilder().startObject() diff --git a/src/test/java/org/elasticsearch/search/aggregations/MetaDataTests.java b/src/test/java/org/elasticsearch/search/aggregations/MetaDataTests.java index cc40e49faaf..10e399df6a4 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/MetaDataTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/MetaDataTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.search.aggregations; import com.carrotsearch.hppc.IntIntMap; -import com.carrotsearch.hppc.IntIntOpenHashMap; +import com.carrotsearch.hppc.IntIntHashMap; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.search.aggregations.bucket.missing.Missing; @@ -52,7 +52,7 @@ public class MetaDataTests extends ElasticsearchIntegrationTest { createIndex("idx"); IndexRequestBuilder[] builders = new IndexRequestBuilder[randomInt(30)]; - IntIntMap values = new IntIntOpenHashMap(); + IntIntMap values = new IntIntHashMap(); long missingValues = 0; for (int i = 0; i < builders.length; i++) { String name = "name_" + randomIntBetween(1, 10); diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoHashGridTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoHashGridTests.java index 7a6c2fe9e1c..dac686ea4ae 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoHashGridTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoHashGridTests.java @@ -18,8 +18,8 @@ */ package org.elasticsearch.search.aggregations.bucket; +import com.carrotsearch.hppc.ObjectIntHashMap; import com.carrotsearch.hppc.ObjectIntMap; -import com.carrotsearch.hppc.ObjectIntOpenHashMap; import com.carrotsearch.hppc.cursors.ObjectIntCursor; import org.elasticsearch.action.index.IndexRequestBuilder; @@ -81,7 +81,7 @@ public class GeoHashGridTests extends ElasticsearchIntegrationTest { List cities = new ArrayList<>(); Random random = getRandom(); - expectedDocCountsForGeoHash = new ObjectIntOpenHashMap<>(numDocs * 2); + expectedDocCountsForGeoHash = new ObjectIntHashMap<>(numDocs * 2); for (int i = 0; i < numDocs; i++) { //generate random point double lat = (180d * random.nextDouble()) - 90d; @@ -105,7 +105,7 @@ public class GeoHashGridTests extends ElasticsearchIntegrationTest { .addMapping("type", "location", "type=geo_point", "city", "type=string,index=not_analyzed")); cities = new ArrayList<>(); - multiValuedExpectedDocCountsForGeoHash = new ObjectIntOpenHashMap<>(numDocs * 2); + multiValuedExpectedDocCountsForGeoHash = new ObjectIntHashMap<>(numDocs * 2); for (int i = 0; i < numDocs; i++) { final int numPoints = random.nextInt(4); List points = new ArrayList<>(); diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/HistogramTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/HistogramTests.java index 031e4701a69..47814ffae1d 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/HistogramTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/HistogramTests.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.search.aggregations.bucket; -import com.carrotsearch.hppc.LongOpenHashSet; +import com.carrotsearch.hppc.LongHashSet; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchPhaseExecutionException; @@ -270,7 +270,7 @@ public class HistogramTests extends ElasticsearchIntegrationTest { assertThat(histo.getName(), equalTo("histo")); assertThat(histo.getBuckets().size(), equalTo(numValueBuckets)); - LongOpenHashSet buckets = new LongOpenHashSet(); + LongHashSet buckets = new LongHashSet(); // TODO: use diamond once JI-9019884 is fixed List histoBuckets = new ArrayList(histo.getBuckets()); long previousCount = Long.MIN_VALUE; @@ -300,7 +300,7 @@ public class HistogramTests extends ElasticsearchIntegrationTest { assertThat(histo.getName(), equalTo("histo")); assertThat(histo.getBuckets().size(), equalTo(numValueBuckets)); - LongOpenHashSet buckets = new LongOpenHashSet(); + LongHashSet buckets = new LongHashSet(); // TODO: use diamond once JI-9019884 is fixed List histoBuckets = new ArrayList(histo.getBuckets()); long previousCount = Long.MAX_VALUE; @@ -407,7 +407,7 @@ public class HistogramTests extends ElasticsearchIntegrationTest { assertThat(histo.getName(), equalTo("histo")); assertThat(histo.getBuckets().size(), equalTo(numValueBuckets)); - LongOpenHashSet visited = new LongOpenHashSet(); + LongHashSet visited = new LongHashSet(); double previousSum = Double.NEGATIVE_INFINITY; // TODO: use diamond once JI-9019884 is fixed List buckets = new ArrayList(histo.getBuckets()); @@ -448,7 +448,7 @@ public class HistogramTests extends ElasticsearchIntegrationTest { assertThat(histo.getName(), equalTo("histo")); assertThat(histo.getBuckets().size(), equalTo(numValueBuckets)); - LongOpenHashSet visited = new LongOpenHashSet(); + LongHashSet visited = new LongHashSet(); double previousSum = Double.POSITIVE_INFINITY; // TODO: use diamond once JI-9019884 is fixed List buckets = new ArrayList(histo.getBuckets()); @@ -489,7 +489,7 @@ public class HistogramTests extends ElasticsearchIntegrationTest { assertThat(histo.getName(), equalTo("histo")); assertThat(histo.getBuckets().size(), equalTo(numValueBuckets)); - LongOpenHashSet visited = new LongOpenHashSet(); + LongHashSet visited = new LongHashSet(); double previousSum = Double.NEGATIVE_INFINITY; // TODO: use diamond once JI-9019884 is fixed List buckets = new ArrayList(histo.getBuckets()); @@ -530,7 +530,7 @@ public class HistogramTests extends ElasticsearchIntegrationTest { assertThat(histo.getName(), equalTo("histo")); assertThat(histo.getBuckets().size(), equalTo(numValueBuckets)); - LongOpenHashSet visited = new LongOpenHashSet(); + LongHashSet visited = new LongHashSet(); double previousSum = Double.POSITIVE_INFINITY; // TODO: use diamond once JI-9019884 is fixed List buckets = new ArrayList(histo.getBuckets()); @@ -573,7 +573,7 @@ public class HistogramTests extends ElasticsearchIntegrationTest { assertThat(histo.getName(), equalTo("histo")); assertThat(histo.getBuckets().size(), equalTo(numValueBuckets)); - LongOpenHashSet visited = new LongOpenHashSet(); + LongHashSet visited = new LongHashSet(); double prevMax = asc ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY; // TODO: use diamond once JI-9019884 is fixed List buckets = new ArrayList(histo.getBuckets()); diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/MinDocCountTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/MinDocCountTests.java index bb1dc40a096..0da498c2865 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/MinDocCountTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/MinDocCountTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.aggregations.bucket; -import com.carrotsearch.hppc.LongOpenHashSet; +import com.carrotsearch.hppc.LongHashSet; import com.carrotsearch.hppc.LongSet; import com.carrotsearch.randomizedtesting.generators.RandomStrings; @@ -67,7 +67,7 @@ public class MinDocCountTests extends AbstractTermsTests { cardinality = randomIntBetween(8, 30); final List indexRequests = new ArrayList<>(); final Set stringTerms = new HashSet<>(); - final LongSet longTerms = new LongOpenHashSet(); + final LongSet longTerms = new LongHashSet(); final Set dateTerms = new HashSet<>(); for (int i = 0; i < cardinality; ++i) { String stringTerm; diff --git a/src/test/java/org/elasticsearch/search/aggregations/metrics/cardinality/HyperLogLogPlusPlusTests.java b/src/test/java/org/elasticsearch/search/aggregations/metrics/cardinality/HyperLogLogPlusPlusTests.java index 50f6ee4a619..91ad947ddbe 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/metrics/cardinality/HyperLogLogPlusPlusTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/metrics/cardinality/HyperLogLogPlusPlusTests.java @@ -19,8 +19,8 @@ package org.elasticsearch.search.aggregations.metrics.cardinality; -import com.carrotsearch.hppc.IntOpenHashSet; -import com.carrotsearch.hppc.hash.MurmurHash3; +import com.carrotsearch.hppc.BitMixer; +import com.carrotsearch.hppc.IntHashSet; import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.test.ElasticsearchTestCase; import org.junit.Test; @@ -62,12 +62,12 @@ public class HyperLogLogPlusPlusTests extends ElasticsearchTestCase { final int numValues = randomIntBetween(1, 100000); final int maxValue = randomIntBetween(1, randomBoolean() ? 1000: 100000); final int p = randomIntBetween(14, MAX_PRECISION); - IntOpenHashSet set = new IntOpenHashSet(); + IntHashSet set = new IntHashSet(); HyperLogLogPlusPlus e = new HyperLogLogPlusPlus(p, BigArrays.NON_RECYCLING_INSTANCE, 1); for (int i = 0; i < numValues; ++i) { final int n = randomInt(maxValue); set.add(n); - final long hash = MurmurHash3.hash((long) n); + final long hash = BitMixer.mix64(n); e.collect(bucket, hash); if (randomInt(100) == 0) { //System.out.println(e.cardinality(bucket) + " <> " + set.size()); @@ -91,7 +91,7 @@ public class HyperLogLogPlusPlusTests extends ElasticsearchTestCase { final int maxValue = randomIntBetween(1, randomBoolean() ? 1000: 1000000); for (int i = 0; i < numValues; ++i) { final int n = randomInt(maxValue); - final long hash = MurmurHash3.hash((long) n); + final long hash = BitMixer.mix64(n); single.collect(0, hash); // use a gaussian so that all instances don't collect as many hashes final int index = (int) (Math.pow(randomDouble(), 2)); diff --git a/src/test/java/org/elasticsearch/search/scroll/DuelScrollTests.java b/src/test/java/org/elasticsearch/search/scroll/DuelScrollTests.java index 3e77aa4b4f1..0dc085dd0a6 100644 --- a/src/test/java/org/elasticsearch/search/scroll/DuelScrollTests.java +++ b/src/test/java/org/elasticsearch/search/scroll/DuelScrollTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.scroll; -import com.carrotsearch.hppc.IntOpenHashSet; +import com.carrotsearch.hppc.IntHashSet; import com.carrotsearch.randomizedtesting.generators.RandomPicks; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchResponse; @@ -159,7 +159,7 @@ public class DuelScrollTests extends ElasticsearchIntegrationTest { boolean unevenRouting = randomBoolean(); int numMissingDocs = scaledRandomIntBetween(0, numDocs / 100); - IntOpenHashSet missingDocs = new IntOpenHashSet(numMissingDocs); + IntHashSet missingDocs = new IntHashSet(numMissingDocs); for (int i = 0; i < numMissingDocs; i++) { while (!missingDocs.add(randomInt(numDocs))) {} } diff --git a/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchTests.java b/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchTests.java index f4c7c74933f..ea7adb38a29 100644 --- a/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchTests.java +++ b/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchTests.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.search.suggest; -import com.carrotsearch.hppc.ObjectLongOpenHashMap; +import com.carrotsearch.hppc.ObjectLongHashMap; import com.carrotsearch.randomizedtesting.generators.RandomStrings; import com.google.common.collect.Lists; @@ -751,7 +751,7 @@ public class CompletionSuggestSearchTests extends ElasticsearchIntegrationTest { // regexes IndicesStatsResponse regexFieldStats = client().admin().indices().prepareStats(INDEX).setIndices(INDEX).setCompletion(true).setCompletionFields("*").get(); - ObjectLongOpenHashMap fields = regexFieldStats.getIndex(INDEX).getPrimaries().completion.getFields(); + ObjectLongHashMap fields = regexFieldStats.getIndex(INDEX).getPrimaries().completion.getFields(); long regexSizeInBytes = fields.get(FIELD) + fields.get(otherField); assertThat(regexSizeInBytes, is(totalSizeInBytes)); } diff --git a/src/test/java/org/elasticsearch/search/suggest/completion/AnalyzingCompletionLookupProviderV1.java b/src/test/java/org/elasticsearch/search/suggest/completion/AnalyzingCompletionLookupProviderV1.java index ea84ddd442c..d8cd3dd3fc7 100644 --- a/src/test/java/org/elasticsearch/search/suggest/completion/AnalyzingCompletionLookupProviderV1.java +++ b/src/test/java/org/elasticsearch/search/suggest/completion/AnalyzingCompletionLookupProviderV1.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.suggest.completion; -import com.carrotsearch.hppc.ObjectLongOpenHashMap; +import com.carrotsearch.hppc.ObjectLongHashMap; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.codecs.CodecUtil; @@ -261,9 +261,9 @@ public class AnalyzingCompletionLookupProviderV1 extends CompletionLookupProvide @Override public CompletionStats stats(String... fields) { long sizeInBytes = 0; - ObjectLongOpenHashMap completionFields = null; + ObjectLongHashMap completionFields = null; if (fields != null && fields.length > 0) { - completionFields = new ObjectLongOpenHashMap<>(fields.length); + completionFields = new ObjectLongHashMap<>(fields.length); } for (Map.Entry entry : lookupMap.entrySet()) { diff --git a/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreTests.java b/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreTests.java index 8d569275aea..26dedd308b5 100644 --- a/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreTests.java +++ b/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.snapshots; -import com.carrotsearch.hppc.IntOpenHashSet; +import com.carrotsearch.hppc.IntHashSet; import com.carrotsearch.hppc.IntSet; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; @@ -581,7 +581,7 @@ public class DedicatedClusterSnapshotRestoreTests extends AbstractSnapshotTests ensureGreen("test-idx"); assertThat(client().prepareCount("test-idx").get().getCount(), equalTo(100L)); - IntSet reusedShards = IntOpenHashSet.newInstance(); + IntSet reusedShards = new IntHashSet(); for (ShardRecoveryResponse response : client().admin().indices().prepareRecoveries("test-idx").get().shardResponses().get("test-idx")) { if (response.recoveryState().getIndex().reusedBytes() > 0) { reusedShards.add(response.getShardId()); diff --git a/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortTests.java b/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortTests.java index aeb085a07b3..6ef9ae48366 100644 --- a/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortTests.java +++ b/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortTests.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.transport.netty; -import com.carrotsearch.hppc.IntOpenHashSet; +import com.carrotsearch.hppc.IntHashSet; import com.google.common.base.Charsets; import org.elasticsearch.Version; import org.elasticsearch.cache.recycler.PageCacheRecycler; @@ -156,7 +156,7 @@ public class NettyTransportMultiPortTests extends ElasticsearchTestCase { } private int[] getRandomPorts(int numberOfPorts) { - IntOpenHashSet ports = new IntOpenHashSet(); + IntHashSet ports = new IntHashSet(); for (int i = 0; i < numberOfPorts; i++) { int port = randomIntBetween(49152, 65535);