You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by br...@apache.org on 2024/05/27 10:38:38 UTC
(lucene) branch branch_9x updated: Remove the HPPC dependency from all modules and move the HPPC fork to internal. (#13422)
This is an automated email from the ASF dual-hosted git repository.
broustant pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 0ba07db35ee Remove the HPPC dependency from all modules and move the HPPC fork to internal. (#13422)
0ba07db35ee is described below
commit 0ba07db35ee54a53129be72e524460da5986801d
Author: Bruno Roustant <33...@users.noreply.github.com>
AuthorDate: Mon May 27 12:09:25 2024 +0200
Remove the HPPC dependency from all modules and move the HPPC fork to internal. (#13422)
* Remove hppc dependency
* Change fork version to 0.10.0
* Add @lucene.internal
* Move hppc classes to oal.internal.hppc but export it.
* Delete hppc license since it's no longer a dependency.
---------
Co-authored-by: Dawid Weiss <da...@carrotsearch.com>
---
lucene/CHANGES.txt | 5 +
.../analysis/charfilter/MappingCharFilter.java | 2 +-
.../analysis/charfilter/NormalizeCharMap.java | 2 +-
.../lucene/analysis/core/FlattenGraphFilter.java | 4 +-
.../lucene/analysis/hunspell/Dictionary.java | 6 +-
.../analysis/hunspell/WordFormGenerator.java | 4 +-
.../lucene/analysis/hunspell/WordStorage.java | 2 +-
.../path/ReversePathHierarchyTokenizer.java | 2 +-
.../apache/lucene/analysis/synonym/SynonymMap.java | 4 +-
.../icu/segmentation/ICUTokenizerFactory.java | 2 +-
.../lucene/analysis/ja/JapaneseFilterUtil.java | 2 +-
.../ja/JapaneseHiraganaUppercaseFilter.java | 2 +-
.../ja/JapaneseKatakanaUppercaseFilter.java | 2 +-
.../lucene/analysis/cn/smart/hhmm/BiSegGraph.java | 6 +-
.../lucene/analysis/cn/smart/hhmm/SegGraph.java | 2 +-
.../src/java/org/egothor/stemmer/Gener.java | 2 +-
.../stempel/src/java/org/egothor/stemmer/Lift.java | 2 +-
.../src/java/org/egothor/stemmer/Optimizer.java | 2 +-
.../src/java/org/egothor/stemmer/Reduce.java | 4 +-
.../stempel/src/java/org/egothor/stemmer/Row.java | 6 +-
.../benchmark/byTask/feeds/SpatialDocMaker.java | 2 +-
.../lucene/benchmark/byTask/utils/Config.java | 2 +-
lucene/core/src/java/module-info.java | 19 +-
.../lucene/analysis/AutomatonToTokenStream.java | 6 +-
.../codecs/lucene90/Lucene90DocValuesConsumer.java | 4 +-
.../codecs/lucene90/Lucene90NormsProducer.java | 2 +-
.../codecs/lucene90/Lucene90PointsReader.java | 2 +-
.../blocktree/Lucene90BlockTreeTermsReader.java | 4 +-
.../Lucene90CompressingTermVectorsWriter.java | 2 +-
.../Lucene99ScalarQuantizedVectorsWriter.java | 2 +-
.../apache/lucene/index/BufferedUpdatesStream.java | 2 +-
.../java/org/apache/lucene/index/FieldInfos.java | 2 +-
.../java/org/apache/lucene/index/IndexWriter.java | 4 +-
.../org/apache/lucene/index/SegmentDocValues.java | 6 +-
.../lucene/index/SegmentDocValuesProducer.java | 2 +-
.../org/apache/lucene/index/SegmentReader.java | 2 +-
.../{util => internal}/hppc/AbstractIterator.java | 4 +-
.../lucene/{util => internal}/hppc/BitMixer.java | 6 +-
.../hppc/BufferAllocationException.java | 8 +-
.../lucene/{util => internal}/hppc/CharCursor.java | 8 +-
.../{util => internal}/hppc/CharHashSet.java | 40 ++--
.../{util => internal}/hppc/CharObjectHashMap.java | 30 +--
.../hppc/DoubleCursor.java} | 12 +-
.../hppc/FloatArrayList.java} | 126 ++++++------
.../hppc/FloatCursor.java} | 12 +-
.../{util => internal}/hppc/HashContainers.java | 8 +-
.../{util => internal}/hppc/IntArrayList.java | 18 +-
.../lucene/{util => internal}/hppc/IntCursor.java | 8 +-
.../hppc/IntDoubleHashMap.java} | 183 ++++++++++--------
.../hppc/IntFloatHashMap.java} | 198 ++++++++++---------
.../lucene/{util => internal}/hppc/IntHashSet.java | 8 +-
.../{util => internal}/hppc/IntIntHashMap.java | 12 +-
.../{util => internal}/hppc/IntObjectHashMap.java | 10 +-
.../{util => internal}/hppc/LongArrayList.java | 20 +-
.../lucene/{util => internal}/hppc/LongCursor.java | 8 +-
.../hppc/LongFloatHashMap.java} | 158 ++++++++-------
.../{util => internal}/hppc/LongHashSet.java | 8 +-
.../{util => internal}/hppc/LongIntHashMap.java | 42 ++--
.../{util => internal}/hppc/LongObjectHashMap.java | 12 +-
.../{util => internal}/hppc/ObjectCursor.java | 8 +-
.../{util => internal}/hppc/package-info.java | 7 +-
.../org/apache/lucene/search/MultiPhraseQuery.java | 2 +-
.../java/org/apache/lucene/search/PhraseQuery.java | 2 +-
.../apache/lucene/search/SloppyPhraseMatcher.java | 2 +-
.../apache/lucene/util/automaton/Automaton.java | 2 +-
.../lucene/util/automaton/CompiledAutomaton.java | 2 +-
.../lucene/util/automaton/LevenshteinAutomata.java | 2 +-
.../apache/lucene/util/automaton/Operations.java | 8 +-
.../org/apache/lucene/util/automaton/StateSet.java | 6 +-
.../apache/lucene/util/automaton/UTF32ToUTF8.java | 2 +-
.../java/org/apache/lucene/util/bkd/BKDWriter.java | 2 +-
.../src/java/org/apache/lucene/util/fst/Util.java | 4 +-
.../util/graph/GraphTokenStreamFiniteStrings.java | 2 +-
.../org/apache/lucene/util/hnsw/HnswGraph.java | 4 +-
.../util/hnsw/IncrementalHnswGraphMerger.java | 2 +-
.../apache/lucene/util/hnsw/OnHeapHnswGraph.java | 2 +-
.../{util => internal}/hppc/TestCharHashSet.java | 2 +-
.../hppc/TestCharObjectHashMap.java | 2 +-
.../hppc/TestFloatArrayList.java} | 122 ++++++------
.../{util => internal}/hppc/TestIntArrayList.java | 7 +-
.../hppc/TestIntDoubleHashMap.java} | 215 +++++++++++----------
.../hppc/TestIntFloatHashMap.java} | 215 +++++++++++----------
.../{util => internal}/hppc/TestIntHashSet.java | 2 +-
.../{util => internal}/hppc/TestIntIntHashMap.java | 32 +--
.../hppc/TestIntObjectHashMap.java | 46 ++---
.../{util => internal}/hppc/TestLongArrayList.java | 7 +-
.../hppc/TestLongFloatHashMap.java} | 208 ++++++++++----------
.../{util => internal}/hppc/TestLongHashSet.java | 2 +-
.../hppc/TestLongIntHashMap.java | 32 +--
.../hppc/TestLongObjectHashMap.java | 46 ++---
.../lucene/distribution/TestModularLayer.java | 5 +-
lucene/facet/build.gradle | 1 -
lucene/facet/src/java/module-info.java | 2 -
.../org/apache/lucene/facet/DrillDownQuery.java | 4 +-
.../apache/lucene/facet/LongValueFacetCounts.java | 11 +-
.../lucene/facet/StringValueFacetCounts.java | 7 +-
.../facet/range/OverlappingLongRangeCounter.java | 11 +-
.../lucene/facet/taxonomy/FloatTaxonomyFacets.java | 2 +-
.../lucene/facet/taxonomy/IntTaxonomyFacets.java | 2 +-
.../facet/taxonomy/OrdinalMappingLeafReader.java | 2 +-
.../lucene/facet/taxonomy/TaxonomyFacets.java | 9 +-
.../directory/DirectoryTaxonomyReader.java | 4 +-
.../taxonomy/directory/TaxonomyIndexArrays.java | 2 +-
.../lucene/search/grouping/TermGroupSelector.java | 2 +-
.../vectorhighlight/SimpleBoundaryScanner.java | 2 +-
lucene/join/build.gradle | 1 -
lucene/join/src/java/module-info.java | 2 -
.../DiversifyingNearestChildrenKnnCollector.java | 2 +-
.../org/apache/lucene/search/join/JoinUtil.java | 20 +-
.../search/join/PointInSetIncludingScoreQuery.java | 4 +-
lucene/licenses/hppc-0.9.1.jar.sha1 | 1 -
lucene/licenses/hppc-LICENSE-ASL.txt | 177 -----------------
lucene/licenses/hppc-NOTICE.txt | 0
.../apache/lucene/misc/document/LazyDocument.java | 2 +-
.../misc/search/DiversifiedTopDocsCollector.java | 2 +-
.../generated/checksums/javaccParserClassic.json | 4 +-
.../lucene/queryparser/classic/QueryParser.java | 2 +-
.../lucene/queryparser/classic/QueryParser.jj | 2 +-
.../document/FloatPointNearestNeighbor.java | 2 +-
.../search/LatLonPointPrototypeQueries.java | 2 +-
.../lucene/sandbox/search/NearestNeighbor.java | 2 +-
.../lucene/sandbox/search/QueryProfilerTree.java | 4 +-
.../lucene/sandbox/search/TermAutomatonQuery.java | 2 +-
lucene/spatial-extras/build.gradle | 2 -
lucene/spatial-extras/src/java/module-info.java | 1 -
.../spatial/util/CachingDoubleValueSource.java | 2 +-
lucene/spatial3d/build.gradle | 2 -
lucene/spatial3d/src/java/module-info.java | 2 -
.../lucene/spatial3d/geom/GeoStandardPath.java | 6 +-
.../lucene/spatial3d/geom/StandardObjects.java | 2 +-
.../search/suggest/document/ContextQuery.java | 2 +-
versions.lock | 1 -
versions.props | 1 -
133 files changed, 1103 insertions(+), 1277 deletions(-)
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 480f0692782..b1b78afc471 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -10,6 +10,11 @@ API Changes
* GITHUB#13145: Deprecate ByteBufferIndexInput as it will be removed in Lucene 10.0. (Uwe Schindler)
+* GITHUB#13422: an explicit dependency on the HPPC library is removed in favor of an internal repackaged copy in
+ oal.internal.hppc. If you relied on HPPC as a transitive dependency, you'll have to add it to your project explicitly.
+ The HPPC classes now bundled in Lucene core are internal and will have restricted access in future releases, please do
+ not use them. (Bruno Roustant, Dawid Weiss, Uwe Schindler, Chris Hegarty)
+
New Features
---------------------
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/charfilter/MappingCharFilter.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/charfilter/MappingCharFilter.java
index 0d56ce960fd..5c87464245c 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/charfilter/MappingCharFilter.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/charfilter/MappingCharFilter.java
@@ -20,11 +20,11 @@ import java.io.IOException;
import java.io.Reader;
import org.apache.lucene.analysis.CharFilter; // javadocs
import org.apache.lucene.analysis.util.RollingCharBuffer;
+import org.apache.lucene.internal.hppc.CharObjectHashMap;
import org.apache.lucene.util.CharsRef;
import org.apache.lucene.util.fst.CharSequenceOutputs;
import org.apache.lucene.util.fst.FST;
import org.apache.lucene.util.fst.Outputs;
-import org.apache.lucene.util.hppc.CharObjectHashMap;
/**
* Simplistic {@link CharFilter} that applies the mappings contained in a {@link NormalizeCharMap}
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/charfilter/NormalizeCharMap.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/charfilter/NormalizeCharMap.java
index ef0b0141ac8..a6095a09157 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/charfilter/NormalizeCharMap.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/charfilter/NormalizeCharMap.java
@@ -19,6 +19,7 @@ package org.apache.lucene.analysis.charfilter;
import java.io.IOException;
import java.util.Map;
import java.util.TreeMap;
+import org.apache.lucene.internal.hppc.CharObjectHashMap;
import org.apache.lucene.util.CharsRef;
import org.apache.lucene.util.IntsRefBuilder;
import org.apache.lucene.util.fst.CharSequenceOutputs;
@@ -26,7 +27,6 @@ import org.apache.lucene.util.fst.FST;
import org.apache.lucene.util.fst.FSTCompiler;
import org.apache.lucene.util.fst.Outputs;
import org.apache.lucene.util.fst.Util;
-import org.apache.lucene.util.hppc.CharObjectHashMap;
// TODO: save/load?
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/FlattenGraphFilter.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/FlattenGraphFilter.java
index b72a3aa9a8a..03c8f76c69b 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/FlattenGraphFilter.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/FlattenGraphFilter.java
@@ -26,10 +26,10 @@ import org.apache.lucene.analysis.synonym.SynonymGraphFilter;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionLengthAttribute;
+import org.apache.lucene.internal.hppc.IntArrayList;
+import org.apache.lucene.internal.hppc.IntCursor;
import org.apache.lucene.util.AttributeSource;
import org.apache.lucene.util.RollingBuffer;
-import org.apache.lucene.util.hppc.IntArrayList;
-import org.apache.lucene.util.hppc.IntCursor;
/**
* Converts an incoming graph token stream, such as one from {@link SynonymGraphFilter}, into a flat
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java
index 37d0655b3ed..9581f255103 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java
@@ -50,6 +50,9 @@ import java.util.TreeMap;
import java.util.stream.Collectors;
import org.apache.lucene.analysis.hunspell.SortingStrategy.EntryAccumulator;
import org.apache.lucene.analysis.hunspell.SortingStrategy.EntrySupplier;
+import org.apache.lucene.internal.hppc.CharHashSet;
+import org.apache.lucene.internal.hppc.IntArrayList;
+import org.apache.lucene.internal.hppc.IntCursor;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.IntsRef;
@@ -58,9 +61,6 @@ import org.apache.lucene.util.fst.FST;
import org.apache.lucene.util.fst.FSTCompiler;
import org.apache.lucene.util.fst.IntSequenceOutputs;
import org.apache.lucene.util.fst.Util;
-import org.apache.lucene.util.hppc.CharHashSet;
-import org.apache.lucene.util.hppc.IntArrayList;
-import org.apache.lucene.util.hppc.IntCursor;
/** In-memory structure for the dictionary (.dic) and affix (.aff) data of a hunspell dictionary. */
public class Dictionary {
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/WordFormGenerator.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/WordFormGenerator.java
index b30399e2bb9..e2556fa465a 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/WordFormGenerator.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/WordFormGenerator.java
@@ -40,11 +40,11 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.lucene.analysis.hunspell.AffixedWord.Affix;
+import org.apache.lucene.internal.hppc.CharHashSet;
+import org.apache.lucene.internal.hppc.CharObjectHashMap;
import org.apache.lucene.util.IntsRef;
import org.apache.lucene.util.fst.FST;
import org.apache.lucene.util.fst.IntsRefFSTEnum;
-import org.apache.lucene.util.hppc.CharHashSet;
-import org.apache.lucene.util.hppc.CharObjectHashMap;
/**
* A utility class used for generating possible word forms by adding affixes to stems ({@link
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/WordStorage.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/WordStorage.java
index 5bf9585f719..44b723a8c5b 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/WordStorage.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/WordStorage.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
+import org.apache.lucene.internal.hppc.IntArrayList;
import org.apache.lucene.store.ByteArrayDataInput;
import org.apache.lucene.store.ByteArrayDataOutput;
import org.apache.lucene.store.DataOutput;
@@ -29,7 +30,6 @@ import org.apache.lucene.util.CharsRef;
import org.apache.lucene.util.IntsRef;
import org.apache.lucene.util.IntsRefBuilder;
import org.apache.lucene.util.fst.IntSequenceOutputs;
-import org.apache.lucene.util.hppc.IntArrayList;
/**
* A data structure for memory-efficient word storage and fast lookup/enumeration. Each dictionary
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/path/ReversePathHierarchyTokenizer.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/path/ReversePathHierarchyTokenizer.java
index a5a144a561f..9f58668dc9a 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/path/ReversePathHierarchyTokenizer.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/path/ReversePathHierarchyTokenizer.java
@@ -21,9 +21,9 @@ import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
+import org.apache.lucene.internal.hppc.IntArrayList;
import org.apache.lucene.util.AttributeFactory;
import org.apache.lucene.util.IgnoreRandomChains;
-import org.apache.lucene.util.hppc.IntArrayList;
/**
* Tokenizer for domain-like hierarchies.
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMap.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMap.java
index 7c23cfd2378..29b40cde07c 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMap.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMap.java
@@ -26,6 +26,8 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
+import org.apache.lucene.internal.hppc.IntArrayList;
+import org.apache.lucene.internal.hppc.IntHashSet;
import org.apache.lucene.store.ByteArrayDataOutput;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
@@ -37,8 +39,6 @@ import org.apache.lucene.util.fst.ByteSequenceOutputs;
import org.apache.lucene.util.fst.FST;
import org.apache.lucene.util.fst.FSTCompiler;
import org.apache.lucene.util.fst.Util;
-import org.apache.lucene.util.hppc.IntArrayList;
-import org.apache.lucene.util.hppc.IntHashSet;
/**
* A map of synonyms, keys and values are phrases.
diff --git a/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/segmentation/ICUTokenizerFactory.java b/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/segmentation/ICUTokenizerFactory.java
index 0383a53a2fd..0545db0ba19 100644
--- a/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/segmentation/ICUTokenizerFactory.java
+++ b/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/segmentation/ICUTokenizerFactory.java
@@ -27,11 +27,11 @@ import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import org.apache.lucene.analysis.TokenizerFactory;
+import org.apache.lucene.internal.hppc.IntObjectHashMap;
import org.apache.lucene.util.AttributeFactory;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.ResourceLoader;
import org.apache.lucene.util.ResourceLoaderAware;
-import org.apache.lucene.util.hppc.IntObjectHashMap;
/**
* Factory for {@link ICUTokenizer}. Words are broken across script boundaries, then segmented
diff --git a/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseFilterUtil.java b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseFilterUtil.java
index 36410b3ea31..73666d3e04e 100644
--- a/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseFilterUtil.java
+++ b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseFilterUtil.java
@@ -17,7 +17,7 @@
package org.apache.lucene.analysis.ja;
import java.util.Map;
-import org.apache.lucene.util.hppc.CharObjectHashMap;
+import org.apache.lucene.internal.hppc.CharObjectHashMap;
/** Utility methods for Japanese filters. */
class JapaneseFilterUtil {
diff --git a/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseHiraganaUppercaseFilter.java b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseHiraganaUppercaseFilter.java
index e7c0969aed5..88a01aef56d 100644
--- a/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseHiraganaUppercaseFilter.java
+++ b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseHiraganaUppercaseFilter.java
@@ -23,7 +23,7 @@ import java.util.Map;
import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
-import org.apache.lucene.util.hppc.CharObjectHashMap;
+import org.apache.lucene.internal.hppc.CharObjectHashMap;
/**
* A {@link TokenFilter} that normalizes small letters (捨て仮名) in hiragana into normal letters. For
diff --git a/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseKatakanaUppercaseFilter.java b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseKatakanaUppercaseFilter.java
index 7a96acd4c0c..9fd0a5f74fc 100644
--- a/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseKatakanaUppercaseFilter.java
+++ b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseKatakanaUppercaseFilter.java
@@ -23,7 +23,7 @@ import java.util.Map;
import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
-import org.apache.lucene.util.hppc.CharObjectHashMap;
+import org.apache.lucene.internal.hppc.CharObjectHashMap;
/**
* A {@link TokenFilter} that normalizes small letters (捨て仮名) in katakana into normal letters. For
diff --git a/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/BiSegGraph.java b/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/BiSegGraph.java
index 92cff58002a..ffd1b04a6e5 100644
--- a/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/BiSegGraph.java
+++ b/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/BiSegGraph.java
@@ -19,9 +19,9 @@ package org.apache.lucene.analysis.cn.smart.hhmm;
import java.util.ArrayList;
import java.util.List;
import org.apache.lucene.analysis.cn.smart.Utility;
-import org.apache.lucene.util.hppc.IntArrayList;
-import org.apache.lucene.util.hppc.IntObjectHashMap;
-import org.apache.lucene.util.hppc.ObjectCursor;
+import org.apache.lucene.internal.hppc.IntArrayList;
+import org.apache.lucene.internal.hppc.IntObjectHashMap;
+import org.apache.lucene.internal.hppc.ObjectCursor;
/**
* Graph representing possible token pairs (bigrams) at each start offset in the sentence.
diff --git a/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/SegGraph.java b/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/SegGraph.java
index bf89a63654f..1a07fd998a2 100644
--- a/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/SegGraph.java
+++ b/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/SegGraph.java
@@ -18,7 +18,7 @@ package org.apache.lucene.analysis.cn.smart.hhmm;
import java.util.ArrayList;
import java.util.List;
-import org.apache.lucene.util.hppc.IntObjectHashMap;
+import org.apache.lucene.internal.hppc.IntObjectHashMap;
/**
* Graph representing possible tokens at each start offset in the sentence.
diff --git a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Gener.java b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Gener.java
index b66f6f79656..ecd1f4e197e 100644
--- a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Gener.java
+++ b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Gener.java
@@ -58,7 +58,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import org.apache.lucene.util.hppc.ObjectCursor;
+import org.apache.lucene.internal.hppc.ObjectCursor;
/**
* The Gener object helps in the discarding of nodes which break the reduction effort and defend the
diff --git a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Lift.java b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Lift.java
index 62b2cea821e..0536c3e1610 100644
--- a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Lift.java
+++ b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Lift.java
@@ -58,7 +58,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import org.apache.lucene.util.hppc.ObjectCursor;
+import org.apache.lucene.internal.hppc.ObjectCursor;
/**
* The Lift class is a data structure that is a variation of a Patricia trie.
diff --git a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Optimizer.java b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Optimizer.java
index 778e863b01c..bb232175983 100644
--- a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Optimizer.java
+++ b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Optimizer.java
@@ -58,7 +58,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import org.apache.lucene.util.hppc.CharCursor;
+import org.apache.lucene.internal.hppc.CharCursor;
/**
* The Optimizer class is a Trie that will be reduced (have empty rows removed).
diff --git a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Reduce.java b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Reduce.java
index ae89e1b81ab..d8a3692e2c8 100644
--- a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Reduce.java
+++ b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Reduce.java
@@ -58,8 +58,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import org.apache.lucene.util.hppc.CharCursor;
-import org.apache.lucene.util.hppc.ObjectCursor;
+import org.apache.lucene.internal.hppc.CharCursor;
+import org.apache.lucene.internal.hppc.ObjectCursor;
/** The Reduce object is used to remove gaps in a Trie which stores a dictionary. */
public class Reduce {
diff --git a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Row.java b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Row.java
index 3c8db8fdbb8..275991a5094 100644
--- a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Row.java
+++ b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Row.java
@@ -59,9 +59,9 @@ import java.io.DataOutput;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Iterator;
-import org.apache.lucene.util.hppc.CharCursor;
-import org.apache.lucene.util.hppc.CharObjectHashMap;
-import org.apache.lucene.util.hppc.ObjectCursor;
+import org.apache.lucene.internal.hppc.CharCursor;
+import org.apache.lucene.internal.hppc.CharObjectHashMap;
+import org.apache.lucene.internal.hppc.ObjectCursor;
/** The Row class represents a row in a matrix representation of a trie. */
public class Row {
diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/SpatialDocMaker.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/SpatialDocMaker.java
index bfac6603ab9..968f83b56e8 100644
--- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/SpatialDocMaker.java
+++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/SpatialDocMaker.java
@@ -23,6 +23,7 @@ import java.util.Set;
import org.apache.lucene.benchmark.byTask.utils.Config;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.internal.hppc.IntObjectHashMap;
import org.apache.lucene.spatial.SpatialStrategy;
import org.apache.lucene.spatial.composite.CompositeSpatialStrategy;
import org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy;
@@ -30,7 +31,6 @@ import org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree;
import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTreeFactory;
import org.apache.lucene.spatial.serialized.SerializedDVStrategy;
-import org.apache.lucene.util.hppc.IntObjectHashMap;
import org.locationtech.spatial4j.context.SpatialContext;
import org.locationtech.spatial4j.context.SpatialContextFactory;
import org.locationtech.spatial4j.shape.Point;
diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java
index 36de0c5ffca..25a688dbeee 100644
--- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java
+++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java
@@ -27,7 +27,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
-import org.apache.lucene.util.hppc.IntArrayList;
+import org.apache.lucene.internal.hppc.IntArrayList;
/**
* Perf run configuration properties.
diff --git a/lucene/core/src/java/module-info.java b/lucene/core/src/java/module-info.java
index 5b440c598c9..dc74dc6405d 100644
--- a/lucene/core/src/java/module-info.java
+++ b/lucene/core/src/java/module-info.java
@@ -24,36 +24,39 @@ module org.apache.lucene.core {
requires static jdk.unsupported; // this is optional but without it MMapDirectory won't be enabled
requires static jdk.management; // this is optional but explicit declaration is recommended
- exports org.apache.lucene.analysis;
exports org.apache.lucene.analysis.standard;
exports org.apache.lucene.analysis.tokenattributes;
- exports org.apache.lucene.codecs;
+ exports org.apache.lucene.analysis;
exports org.apache.lucene.codecs.compressing;
+ exports org.apache.lucene.codecs.lucene90.blocktree;
+ exports org.apache.lucene.codecs.lucene90.compressing;
exports org.apache.lucene.codecs.lucene90;
exports org.apache.lucene.codecs.lucene94;
exports org.apache.lucene.codecs.lucene95;
exports org.apache.lucene.codecs.lucene99;
- exports org.apache.lucene.codecs.lucene90.blocktree;
- exports org.apache.lucene.codecs.lucene90.compressing;
exports org.apache.lucene.codecs.perfield;
+ exports org.apache.lucene.codecs;
exports org.apache.lucene.document;
exports org.apache.lucene.geo;
exports org.apache.lucene.index;
- exports org.apache.lucene.search;
exports org.apache.lucene.search.comparators;
- exports org.apache.lucene.search.similarities;
exports org.apache.lucene.search.knn;
+ exports org.apache.lucene.search.similarities;
+ exports org.apache.lucene.search;
exports org.apache.lucene.store;
- exports org.apache.lucene.util;
exports org.apache.lucene.util.automaton;
exports org.apache.lucene.util.bkd;
exports org.apache.lucene.util.compress;
exports org.apache.lucene.util.fst;
exports org.apache.lucene.util.graph;
exports org.apache.lucene.util.hnsw;
- exports org.apache.lucene.util.hppc;
exports org.apache.lucene.util.mutable;
exports org.apache.lucene.util.packed;
+ exports org.apache.lucene.util;
+
+ // Temporarily export HPPC to all modules (eventually, this
+ // should be restricted to only Lucene modules)
+ exports org.apache.lucene.internal.hppc;
// Only export internal packages to the test framework.
exports org.apache.lucene.internal.tests to
diff --git a/lucene/core/src/java/org/apache/lucene/analysis/AutomatonToTokenStream.java b/lucene/core/src/java/org/apache/lucene/analysis/AutomatonToTokenStream.java
index fa0db8de798..78e3ea5cfe2 100644
--- a/lucene/core/src/java/org/apache/lucene/analysis/AutomatonToTokenStream.java
+++ b/lucene/core/src/java/org/apache/lucene/analysis/AutomatonToTokenStream.java
@@ -25,12 +25,12 @@ import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionLengthAttribute;
+import org.apache.lucene.internal.hppc.IntArrayList;
+import org.apache.lucene.internal.hppc.IntCursor;
+import org.apache.lucene.internal.hppc.IntIntHashMap;
import org.apache.lucene.util.automaton.Automaton;
import org.apache.lucene.util.automaton.Operations;
import org.apache.lucene.util.automaton.Transition;
-import org.apache.lucene.util.hppc.IntArrayList;
-import org.apache.lucene.util.hppc.IntCursor;
-import org.apache.lucene.util.hppc.IntIntHashMap;
/** Converts an Automaton into a TokenStream. */
public class AutomatonToTokenStream {
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesConsumer.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesConsumer.java
index 57caf34d1a6..d64dce985c0 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesConsumer.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesConsumer.java
@@ -36,6 +36,8 @@ import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.index.SortedNumericDocValues;
import org.apache.lucene.index.SortedSetDocValues;
import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.internal.hppc.LongHashSet;
+import org.apache.lucene.internal.hppc.LongIntHashMap;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.SortedSetSelector;
import org.apache.lucene.store.ByteArrayDataOutput;
@@ -50,8 +52,6 @@ import org.apache.lucene.util.LongsRef;
import org.apache.lucene.util.MathUtil;
import org.apache.lucene.util.StringHelper;
import org.apache.lucene.util.compress.LZ4;
-import org.apache.lucene.util.hppc.LongHashSet;
-import org.apache.lucene.util.hppc.LongIntHashMap;
import org.apache.lucene.util.packed.DirectMonotonicWriter;
import org.apache.lucene.util.packed.DirectWriter;
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90NormsProducer.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90NormsProducer.java
index 47dd2e14708..dcfa45f5b60 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90NormsProducer.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90NormsProducer.java
@@ -29,12 +29,12 @@ import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.IndexFileNames;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.SegmentReadState;
+import org.apache.lucene.internal.hppc.IntObjectHashMap;
import org.apache.lucene.store.ChecksumIndexInput;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.RandomAccessInput;
import org.apache.lucene.util.IOUtils;
-import org.apache.lucene.util.hppc.IntObjectHashMap;
/** Reader for {@link Lucene90NormsFormat} */
final class Lucene90NormsProducer extends NormsProducer implements Cloneable {
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90PointsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90PointsReader.java
index 81f8408ee2c..3e072cb8770 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90PointsReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90PointsReader.java
@@ -24,12 +24,12 @@ import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexFileNames;
import org.apache.lucene.index.PointValues;
import org.apache.lucene.index.SegmentReadState;
+import org.apache.lucene.internal.hppc.IntObjectHashMap;
import org.apache.lucene.store.ChecksumIndexInput;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.bkd.BKDReader;
-import org.apache.lucene.util.hppc.IntObjectHashMap;
/** Reads point values previously written with {@link Lucene90PointsWriter} */
public class Lucene90PointsReader extends PointsReader {
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/blocktree/Lucene90BlockTreeTermsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/blocktree/Lucene90BlockTreeTermsReader.java
index aab22c2b1dc..74b8591bfd1 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/blocktree/Lucene90BlockTreeTermsReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/blocktree/Lucene90BlockTreeTermsReader.java
@@ -31,6 +31,8 @@ import org.apache.lucene.index.IndexFileNames;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.SegmentReadState;
import org.apache.lucene.index.Terms;
+import org.apache.lucene.internal.hppc.IntCursor;
+import org.apache.lucene.internal.hppc.IntObjectHashMap;
import org.apache.lucene.store.ChecksumIndexInput;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
@@ -38,8 +40,6 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.fst.ByteSequenceOutputs;
import org.apache.lucene.util.fst.Outputs;
-import org.apache.lucene.util.hppc.IntCursor;
-import org.apache.lucene.util.hppc.IntObjectHashMap;
/**
* A block-based terms index and dictionary that assigns terms to variable length blocks according
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingTermVectorsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingTermVectorsWriter.java
index 7a37e8c9300..a070c6be47b 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingTermVectorsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingTermVectorsWriter.java
@@ -39,6 +39,7 @@ import org.apache.lucene.index.Fields;
import org.apache.lucene.index.IndexFileNames;
import org.apache.lucene.index.MergeState;
import org.apache.lucene.index.SegmentInfo;
+import org.apache.lucene.internal.hppc.IntHashSet;
import org.apache.lucene.store.ByteBuffersDataInput;
import org.apache.lucene.store.ByteBuffersDataOutput;
import org.apache.lucene.store.DataInput;
@@ -51,7 +52,6 @@ import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.StringHelper;
-import org.apache.lucene.util.hppc.IntHashSet;
import org.apache.lucene.util.packed.BlockPackedWriter;
import org.apache.lucene.util.packed.DirectWriter;
import org.apache.lucene.util.packed.PackedInts;
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene99/Lucene99ScalarQuantizedVectorsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene99/Lucene99ScalarQuantizedVectorsWriter.java
index b584ffff606..4fc7e60af9b 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene99/Lucene99ScalarQuantizedVectorsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene99/Lucene99ScalarQuantizedVectorsWriter.java
@@ -48,6 +48,7 @@ import org.apache.lucene.index.SegmentWriteState;
import org.apache.lucene.index.Sorter;
import org.apache.lucene.index.VectorEncoding;
import org.apache.lucene.index.VectorSimilarityFunction;
+import org.apache.lucene.internal.hppc.IntArrayList;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.VectorScorer;
import org.apache.lucene.store.IndexInput;
@@ -59,7 +60,6 @@ import org.apache.lucene.util.VectorUtil;
import org.apache.lucene.util.hnsw.CloseableRandomVectorScorerSupplier;
import org.apache.lucene.util.hnsw.RandomVectorScorer;
import org.apache.lucene.util.hnsw.RandomVectorScorerSupplier;
-import org.apache.lucene.util.hppc.IntArrayList;
import org.apache.lucene.util.quantization.QuantizedByteVectorValues;
import org.apache.lucene.util.quantization.QuantizedVectorsReader;
import org.apache.lucene.util.quantization.ScalarQuantizer;
diff --git a/lucene/core/src/java/org/apache/lucene/index/BufferedUpdatesStream.java b/lucene/core/src/java/org/apache/lucene/index/BufferedUpdatesStream.java
index c9072b91121..83deac129a6 100644
--- a/lucene/core/src/java/org/apache/lucene/index/BufferedUpdatesStream.java
+++ b/lucene/core/src/java/org/apache/lucene/index/BufferedUpdatesStream.java
@@ -26,13 +26,13 @@ import java.util.Locale;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
+import org.apache.lucene.internal.hppc.LongHashSet;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOConsumer;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.InfoStream;
-import org.apache.lucene.util.hppc.LongHashSet;
/**
* Tracks the stream of {@link FrozenBufferedUpdates}. When DocumentsWriterPerThread flushes, its
diff --git a/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java b/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
index c2a9ff3ae1c..e1ff4db0192 100644
--- a/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
+++ b/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
@@ -33,9 +33,9 @@ import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
+import org.apache.lucene.internal.hppc.IntObjectHashMap;
import org.apache.lucene.util.CollectionUtil;
import org.apache.lucene.util.Version;
-import org.apache.lucene.util.hppc.IntObjectHashMap;
/**
* Collection of {@link FieldInfo}s (accessible by number or by name).
diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
index 13d524ef3f5..ded326f7a09 100644
--- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
@@ -58,6 +58,8 @@ import org.apache.lucene.index.FieldInfos.FieldNumbers;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.MergePolicy.MergeReader;
import org.apache.lucene.index.Sorter.DocMap;
+import org.apache.lucene.internal.hppc.LongObjectHashMap;
+import org.apache.lucene.internal.hppc.ObjectCursor;
import org.apache.lucene.internal.tests.IndexPackageAccess;
import org.apache.lucene.internal.tests.IndexWriterAccess;
import org.apache.lucene.internal.tests.TestSecrets;
@@ -91,8 +93,6 @@ import org.apache.lucene.util.StringHelper;
import org.apache.lucene.util.ThreadInterruptedException;
import org.apache.lucene.util.UnicodeUtil;
import org.apache.lucene.util.Version;
-import org.apache.lucene.util.hppc.LongObjectHashMap;
-import org.apache.lucene.util.hppc.ObjectCursor;
/**
* An <code>IndexWriter</code> creates and maintains an index.
diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentDocValues.java b/lucene/core/src/java/org/apache/lucene/index/SegmentDocValues.java
index bf4a9358439..3ee7945c282 100644
--- a/lucene/core/src/java/org/apache/lucene/index/SegmentDocValues.java
+++ b/lucene/core/src/java/org/apache/lucene/index/SegmentDocValues.java
@@ -19,12 +19,12 @@ package org.apache.lucene.index;
import java.io.IOException;
import org.apache.lucene.codecs.DocValuesFormat;
import org.apache.lucene.codecs.DocValuesProducer;
+import org.apache.lucene.internal.hppc.LongArrayList;
+import org.apache.lucene.internal.hppc.LongCursor;
+import org.apache.lucene.internal.hppc.LongObjectHashMap;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.util.RefCount;
-import org.apache.lucene.util.hppc.LongArrayList;
-import org.apache.lucene.util.hppc.LongCursor;
-import org.apache.lucene.util.hppc.LongObjectHashMap;
/**
* Manages the {@link DocValuesProducer} held by {@link SegmentReader} and keeps track of their
diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentDocValuesProducer.java b/lucene/core/src/java/org/apache/lucene/index/SegmentDocValuesProducer.java
index f0979ddd3e7..63baddb4174 100644
--- a/lucene/core/src/java/org/apache/lucene/index/SegmentDocValuesProducer.java
+++ b/lucene/core/src/java/org/apache/lucene/index/SegmentDocValuesProducer.java
@@ -23,8 +23,8 @@ import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Set;
import org.apache.lucene.codecs.DocValuesProducer;
+import org.apache.lucene.internal.hppc.LongArrayList;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.util.hppc.LongArrayList;
/** Encapsulates multiple producers when there are docvalues updates as one producer */
// TODO: try to clean up close? no-op?
diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentReader.java b/lucene/core/src/java/org/apache/lucene/index/SegmentReader.java
index 0bc5feeb6ba..4ce9bd21cd2 100644
--- a/lucene/core/src/java/org/apache/lucene/index/SegmentReader.java
+++ b/lucene/core/src/java/org/apache/lucene/index/SegmentReader.java
@@ -29,13 +29,13 @@ import org.apache.lucene.codecs.NormsProducer;
import org.apache.lucene.codecs.PointsReader;
import org.apache.lucene.codecs.StoredFieldsReader;
import org.apache.lucene.codecs.TermVectorsReader;
+import org.apache.lucene.internal.hppc.LongArrayList;
import org.apache.lucene.internal.tests.SegmentReaderAccess;
import org.apache.lucene.internal.tests.TestSecrets;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.IOUtils;
-import org.apache.lucene.util.hppc.LongArrayList;
/**
* IndexReader implementation over a single segment.
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/AbstractIterator.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/AbstractIterator.java
similarity index 97%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/AbstractIterator.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/AbstractIterator.java
index 147274ccfe6..77601ff6e2d 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/AbstractIterator.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/AbstractIterator.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import java.util.Iterator;
import java.util.NoSuchElementException;
@@ -24,6 +24,8 @@ import java.util.NoSuchElementException;
* Simplifies the implementation of iterators a bit. Modeled loosely after Google Guava's API.
*
* <p>Forked from com.carrotsearch.hppc.AbstractIterator
+ *
+ * @lucene.internal
*/
public abstract class AbstractIterator<E> implements Iterator<E> {
private static final int NOT_CACHED = 0;
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/BitMixer.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/BitMixer.java
similarity index 96%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/BitMixer.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/BitMixer.java
index 36d239a7bfb..fbdf2a2597c 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/BitMixer.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/BitMixer.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
/**
* Bit mixing utilities. The purpose of these methods is to evenly distribute key space over int32
@@ -23,7 +23,9 @@ package org.apache.lucene.util.hppc;
*
* <p>Forked from com.carrotsearch.hppc.BitMixer
*
- * <p>github: https://github.com/carrotsearch/hppc release: 0.9.0
+ * <p>github: https://github.com/carrotsearch/hppc release: 0.10.0
+ *
+ * @lucene.internal
*/
public final class BitMixer {
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/BufferAllocationException.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/BufferAllocationException.java
similarity index 93%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/BufferAllocationException.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/BufferAllocationException.java
index 2c20772b147..02ba39bc7d2 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/BufferAllocationException.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/BufferAllocationException.java
@@ -15,12 +15,16 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import java.util.IllegalFormatException;
import java.util.Locale;
-/** BufferAllocationException forked from HPPC */
+/**
+ * BufferAllocationException forked from HPPC.
+ *
+ * @lucene.internal
+ */
public class BufferAllocationException extends RuntimeException {
public BufferAllocationException(String message) {
super(message);
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/CharCursor.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/CharCursor.java
similarity index 90%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/CharCursor.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/CharCursor.java
index 6f18a87b0a1..c11fe77e092 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/CharCursor.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/CharCursor.java
@@ -15,9 +15,13 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
-/** Forked from HPPC, holding int index and char value */
+/**
+ * Forked from HPPC, holding int index and char value.
+ *
+ * @lucene.internal
+ */
public final class CharCursor {
/**
* The current value's index in the container this cursor belongs to. The meaning of this index is
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/CharHashSet.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/CharHashSet.java
similarity index 93%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/CharHashSet.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/CharHashSet.java
index c35f87afd8a..4c13a34da39 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/CharHashSet.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/CharHashSet.java
@@ -15,18 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
-
-import static org.apache.lucene.util.hppc.HashContainers.DEFAULT_EXPECTED_ELEMENTS;
-import static org.apache.lucene.util.hppc.HashContainers.DEFAULT_LOAD_FACTOR;
-import static org.apache.lucene.util.hppc.HashContainers.ITERATION_SEED;
-import static org.apache.lucene.util.hppc.HashContainers.MAX_LOAD_FACTOR;
-import static org.apache.lucene.util.hppc.HashContainers.MIN_LOAD_FACTOR;
-import static org.apache.lucene.util.hppc.HashContainers.checkLoadFactor;
-import static org.apache.lucene.util.hppc.HashContainers.expandAtCount;
-import static org.apache.lucene.util.hppc.HashContainers.iterationIncrement;
-import static org.apache.lucene.util.hppc.HashContainers.minBufferSize;
-import static org.apache.lucene.util.hppc.HashContainers.nextBufferSize;
+package org.apache.lucene.internal.hppc;
import java.util.Arrays;
import java.util.Iterator;
@@ -39,7 +28,9 @@ import org.apache.lucene.util.RamUsageEstimator;
*
* <p>Mostly forked and trimmed from com.carrotsearch.hppc.CharHashSet
*
- * <p>github: https://github.com/carrotsearch/hppc release 0.9.0
+ * <p>github: https://github.com/carrotsearch/hppc release 0.10.0
+ *
+ * @lucene.internal
*/
public class CharHashSet implements Iterable<CharCursor>, Accountable, Cloneable {
@@ -76,7 +67,7 @@ public class CharHashSet implements Iterable<CharCursor>, Accountable, Cloneable
/** New instance with sane defaults. */
public CharHashSet() {
- this(DEFAULT_EXPECTED_ELEMENTS);
+ this(HashContainers.DEFAULT_EXPECTED_ELEMENTS);
}
/**
@@ -86,7 +77,7 @@ public class CharHashSet implements Iterable<CharCursor>, Accountable, Cloneable
* (inclusive).
*/
public CharHashSet(int expectedElements) {
- this(expectedElements, DEFAULT_LOAD_FACTOR);
+ this(expectedElements, HashContainers.DEFAULT_LOAD_FACTOR);
}
/**
@@ -99,7 +90,7 @@ public class CharHashSet implements Iterable<CharCursor>, Accountable, Cloneable
*/
public CharHashSet(int expectedElements, double loadFactor) {
this.loadFactor = verifyLoadFactor(loadFactor);
- iterationSeed = ITERATION_SEED.incrementAndGet();
+ iterationSeed = HashContainers.ITERATION_SEED.incrementAndGet();
ensureCapacity(expectedElements);
}
@@ -193,7 +184,7 @@ public class CharHashSet implements Iterable<CharCursor>, Accountable, Cloneable
final char[] keys = this.keys;
int seed = nextIterationSeed();
- int inc = iterationIncrement(seed);
+ int inc = HashContainers.iterationIncrement(seed);
for (int i = 0, mask = this.mask, slot = seed & mask;
i <= mask;
i++, slot = (slot + inc) & mask) {
@@ -292,7 +283,7 @@ public class CharHashSet implements Iterable<CharCursor>, Accountable, Cloneable
assigned = 0;
hasEmptyKey = false;
keys = null;
- ensureCapacity(DEFAULT_EXPECTED_ELEMENTS);
+ ensureCapacity(HashContainers.DEFAULT_EXPECTED_ELEMENTS);
}
public boolean isEmpty() {
@@ -308,7 +299,7 @@ public class CharHashSet implements Iterable<CharCursor>, Accountable, Cloneable
public void ensureCapacity(int expectedElements) {
if (expectedElements > resizeAt || keys == null) {
final char[] prevKeys = this.keys;
- allocateBuffers(minBufferSize(expectedElements, loadFactor));
+ allocateBuffers(HashContainers.minBufferSize(expectedElements, loadFactor));
if (prevKeys != null && !isEmpty()) {
rehash(prevKeys);
}
@@ -360,7 +351,7 @@ public class CharHashSet implements Iterable<CharCursor>, Accountable, Cloneable
CharHashSet cloned = (CharHashSet) super.clone();
cloned.keys = keys.clone();
cloned.hasEmptyKey = hasEmptyKey;
- cloned.iterationSeed = ITERATION_SEED.incrementAndGet();
+ cloned.iterationSeed = HashContainers.ITERATION_SEED.incrementAndGet();
return cloned;
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
@@ -396,7 +387,7 @@ public class CharHashSet implements Iterable<CharCursor>, Accountable, Cloneable
public EntryIterator() {
cursor = new CharCursor();
int seed = nextIterationSeed();
- increment = iterationIncrement(seed);
+ increment = HashContainers.iterationIncrement(seed);
slot = seed & mask;
}
@@ -589,7 +580,8 @@ public class CharHashSet implements Iterable<CharCursor>, Accountable, Cloneable
* factors.
*/
protected double verifyLoadFactor(double loadFactor) {
- checkLoadFactor(loadFactor, MIN_LOAD_FACTOR, MAX_LOAD_FACTOR);
+ HashContainers.checkLoadFactor(
+ loadFactor, HashContainers.MIN_LOAD_FACTOR, HashContainers.MAX_LOAD_FACTOR);
return loadFactor;
}
@@ -631,7 +623,7 @@ public class CharHashSet implements Iterable<CharCursor>, Accountable, Cloneable
e, this.keys == null ? 0 : size(), arraySize);
}
- this.resizeAt = expandAtCount(arraySize, loadFactor);
+ this.resizeAt = HashContainers.expandAtCount(arraySize, loadFactor);
this.mask = arraySize - 1;
}
@@ -648,7 +640,7 @@ public class CharHashSet implements Iterable<CharCursor>, Accountable, Cloneable
// Try to allocate new buffers first. If we OOM, we leave in a consistent state.
final char[] prevKeys = this.keys;
- allocateBuffers(nextBufferSize(mask + 1, size(), loadFactor));
+ allocateBuffers(HashContainers.nextBufferSize(mask + 1, size(), loadFactor));
assert this.keys.length > prevKeys.length;
// We have succeeded at allocating new data so insert the pending key/value at
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/CharObjectHashMap.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/CharObjectHashMap.java
similarity index 95%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/CharObjectHashMap.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/CharObjectHashMap.java
index 6db9e4affb1..b1fad7017b5 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/CharObjectHashMap.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/CharObjectHashMap.java
@@ -15,19 +15,19 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
-
-import static org.apache.lucene.util.hppc.HashContainers.DEFAULT_EXPECTED_ELEMENTS;
-import static org.apache.lucene.util.hppc.HashContainers.DEFAULT_LOAD_FACTOR;
-import static org.apache.lucene.util.hppc.HashContainers.ITERATION_SEED;
-import static org.apache.lucene.util.hppc.HashContainers.MAX_LOAD_FACTOR;
-import static org.apache.lucene.util.hppc.HashContainers.MIN_LOAD_FACTOR;
-import static org.apache.lucene.util.hppc.HashContainers.checkLoadFactor;
-import static org.apache.lucene.util.hppc.HashContainers.checkPowerOfTwo;
-import static org.apache.lucene.util.hppc.HashContainers.expandAtCount;
-import static org.apache.lucene.util.hppc.HashContainers.iterationIncrement;
-import static org.apache.lucene.util.hppc.HashContainers.minBufferSize;
-import static org.apache.lucene.util.hppc.HashContainers.nextBufferSize;
+package org.apache.lucene.internal.hppc;
+
+import static org.apache.lucene.internal.hppc.HashContainers.DEFAULT_EXPECTED_ELEMENTS;
+import static org.apache.lucene.internal.hppc.HashContainers.DEFAULT_LOAD_FACTOR;
+import static org.apache.lucene.internal.hppc.HashContainers.ITERATION_SEED;
+import static org.apache.lucene.internal.hppc.HashContainers.MAX_LOAD_FACTOR;
+import static org.apache.lucene.internal.hppc.HashContainers.MIN_LOAD_FACTOR;
+import static org.apache.lucene.internal.hppc.HashContainers.checkLoadFactor;
+import static org.apache.lucene.internal.hppc.HashContainers.checkPowerOfTwo;
+import static org.apache.lucene.internal.hppc.HashContainers.expandAtCount;
+import static org.apache.lucene.internal.hppc.HashContainers.iterationIncrement;
+import static org.apache.lucene.internal.hppc.HashContainers.minBufferSize;
+import static org.apache.lucene.internal.hppc.HashContainers.nextBufferSize;
import java.util.Arrays;
import java.util.Iterator;
@@ -40,7 +40,9 @@ import org.apache.lucene.util.RamUsageEstimator;
*
* <p>Mostly forked and trimmed from com.carrotsearch.hppc.CharObjectHashMap
*
- * <p>github: https://github.com/carrotsearch/hppc release 0.9.0
+ * <p>github: https://github.com/carrotsearch/hppc release 0.10.0
+ *
+ * @lucene.internal
*/
@SuppressWarnings("unchecked")
public class CharObjectHashMap<VType>
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/ObjectCursor.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/DoubleCursor.java
similarity index 86%
copy from lucene/core/src/java/org/apache/lucene/util/hppc/ObjectCursor.java
copy to lucene/core/src/java/org/apache/lucene/internal/hppc/DoubleCursor.java
index 45d0cb56b62..7c2bbf53097 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/ObjectCursor.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/DoubleCursor.java
@@ -15,10 +15,14 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
-/** Forked from HPPC, holding int index and Object value */
-public final class ObjectCursor<VType> {
+/**
+ * Forked from HPPC, holding int index and double value.
+ *
+ * @lucene.internal
+ */
+public final class DoubleCursor {
/**
* The current value's index in the container this cursor belongs to. The meaning of this index is
* defined by the container (usually it will be an index in the underlying storage buffer).
@@ -26,7 +30,7 @@ public final class ObjectCursor<VType> {
public int index;
/** The current value. */
- public VType value;
+ public double value;
@Override
public String toString() {
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/IntArrayList.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/FloatArrayList.java
similarity index 77%
copy from lucene/core/src/java/org/apache/lucene/util/hppc/IntArrayList.java
copy to lucene/core/src/java/org/apache/lucene/internal/hppc/FloatArrayList.java
index bc80e36463b..728c0aa96d1 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/IntArrayList.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/FloatArrayList.java
@@ -15,44 +15,43 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
-import static org.apache.lucene.util.hppc.HashContainers.DEFAULT_EXPECTED_ELEMENTS;
+import static org.apache.lucene.internal.hppc.HashContainers.DEFAULT_EXPECTED_ELEMENTS;
import java.util.Arrays;
import java.util.Iterator;
-import java.util.stream.IntStream;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.RamUsageEstimator;
/**
- * An array-backed list of {@code int}.
+ * An array-backed list of {@code float}.
*
- * <p>Mostly forked and trimmed from com.carrotsearch.hppc.IntArrayList
+ * <p>Mostly forked and trimmed from com.carrotsearch.hppc.FloatArrayList
*
- * <p>github: https://github.com/carrotsearch/hppc release 0.9.0
+ * <p>github: https://github.com/carrotsearch/hppc release 0.10.0
+ *
+ * @lucene.internal
*/
-public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable {
+public class FloatArrayList implements Iterable<FloatCursor>, Cloneable, Accountable {
private static final long BASE_RAM_BYTES_USED =
- RamUsageEstimator.shallowSizeOfInstance(IntArrayList.class);
+ RamUsageEstimator.shallowSizeOfInstance(FloatArrayList.class);
/** An immutable empty buffer (array). */
- public static final int[] EMPTY_ARRAY = new int[0];
-
- ;
+ public static final float[] EMPTY_ARRAY = new float[0];
/**
* Internal array for storing the list. The array may be larger than the current size ({@link
* #size()}).
*/
- public int[] buffer = EMPTY_ARRAY;
+ public float[] buffer;
/** Current number of elements stored in {@link #buffer}. */
public int elementsCount;
/** New instance with sane defaults. */
- public IntArrayList() {
+ public FloatArrayList() {
this(DEFAULT_EXPECTED_ELEMENTS);
}
@@ -62,23 +61,23 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
* @param expectedElements The expected number of elements guaranteed not to cause buffer
* expansion (inclusive).
*/
- public IntArrayList(int expectedElements) {
- buffer = new int[expectedElements];
+ public FloatArrayList(int expectedElements) {
+ buffer = new float[expectedElements];
}
/** Creates a new list from the elements of another list in its iteration order. */
- public IntArrayList(IntArrayList list) {
+ public FloatArrayList(FloatArrayList list) {
this(list.size());
addAll(list);
}
- public void add(int e1) {
+ public void add(float e1) {
ensureBufferSpace(1);
buffer[elementsCount++] = e1;
}
/** Add all elements from a range of given array to the list. */
- public void add(int[] elements, int start, int length) {
+ public void add(float[] elements, int start, int length) {
assert length >= 0 : "Length must be >= 0";
ensureBufferSpace(length);
@@ -92,16 +91,16 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
* <p><b>This method is handy, but costly if used in tight loops (anonymous array passing)</b>
*/
/* */
- public final void add(int... elements) {
+ public final void add(float... elements) {
add(elements, 0, elements.length);
}
/** Adds all elements from another list. */
- public int addAll(IntArrayList list) {
+ public int addAll(FloatArrayList list) {
final int size = list.size();
ensureBufferSpace(size);
- for (IntCursor cursor : list) {
+ for (FloatCursor cursor : list) {
add(cursor.value);
}
@@ -109,16 +108,16 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
}
/** Adds all elements from another iterable. */
- public int addAll(Iterable<? extends IntCursor> iterable) {
+ public int addAll(Iterable<? extends FloatCursor> iterable) {
int size = 0;
- for (IntCursor cursor : iterable) {
+ for (FloatCursor cursor : iterable) {
add(cursor.value);
size++;
}
return size;
}
- public void insert(int index, int e1) {
+ public void insert(int index, float e1) {
assert (index >= 0 && index <= size())
: "Index " + index + " out of bounds [" + 0 + ", " + size() + "].";
@@ -128,34 +127,34 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
elementsCount++;
}
- public int get(int index) {
+ public float get(int index) {
assert (index >= 0 && index < size())
: "Index " + index + " out of bounds [" + 0 + ", " + size() + ").";
return buffer[index];
}
- public int set(int index, int e1) {
+ public float set(int index, float e1) {
assert (index >= 0 && index < size())
: "Index " + index + " out of bounds [" + 0 + ", " + size() + ").";
- final int v = buffer[index];
+ final float v = buffer[index];
buffer[index] = e1;
return v;
}
/** Removes the element at the specified position in this container and returns it. */
- public int removeAt(int index) {
+ public float removeAt(int index) {
assert (index >= 0 && index < size())
: "Index " + index + " out of bounds [" + 0 + ", " + size() + ").";
- final int v = buffer[index];
+ final float v = buffer[index];
System.arraycopy(buffer, index + 1, buffer, index, --elementsCount - index);
return v;
}
/** Removes and returns the last element of this list. */
- public int removeLast() {
+ public float removeLast() {
assert !isEmpty() : "List is empty";
return buffer[--elementsCount];
@@ -181,7 +180,7 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
* Removes the first element that equals <code>e</code>, returning whether an element has been
* removed.
*/
- public boolean removeElement(int e) {
+ public boolean removeElement(float e) {
return removeFirst(e) != -1;
}
@@ -189,7 +188,7 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
* Removes the first element that equals <code>e1</code>, returning its deleted position or <code>
* -1</code> if the element was not found.
*/
- public int removeFirst(int e1) {
+ public int removeFirst(float e1) {
final int index = indexOf(e1);
if (index >= 0) removeAt(index);
return index;
@@ -199,7 +198,7 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
* Removes the last element that equals <code>e1</code>, returning its deleted position or <code>
* -1</code> if the element was not found.
*/
- public int removeLast(int e1) {
+ public int removeLast(float e1) {
final int index = lastIndexOf(e1);
if (index >= 0) removeAt(index);
return index;
@@ -211,7 +210,7 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
* @param e Element to be removed from this collection, if present.
* @return The number of removed elements as a result of this call.
*/
- public int removeAll(int e) {
+ public int removeAll(float e) {
int to = 0;
for (int from = 0; from < elementsCount; from++) {
if (((e) == (buffer[from]))) {
@@ -227,11 +226,11 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
return deleted;
}
- public boolean contains(int e1) {
+ public boolean contains(float e1) {
return indexOf(e1) >= 0;
}
- public int indexOf(int e1) {
+ public int indexOf(float e1) {
for (int i = 0; i < elementsCount; i++) {
if (((e1) == (buffer[i]))) {
return i;
@@ -241,7 +240,7 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
return -1;
}
- public int lastIndexOf(int e1) {
+ public int lastIndexOf(float e1) {
for (int i = elementsCount - 1; i >= 0; i--) {
if (((e1) == (buffer[i]))) {
return i;
@@ -262,8 +261,7 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
* @param expectedElements The total number of elements, inclusive.
*/
public void ensureCapacity(int expectedElements) {
- final int bufferLen = (buffer == null ? 0 : buffer.length);
- if (expectedElements > bufferLen) {
+ if (expectedElements > buffer.length) {
ensureBufferSpace(expectedElements - size());
}
}
@@ -273,8 +271,7 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
* Increases internal buffer size if needed.
*/
protected void ensureBufferSpace(int expectedAdditions) {
- final int bufferLen = (buffer == null ? 0 : buffer.length);
- if (elementsCount + expectedAdditions > bufferLen) {
+ if (elementsCount + expectedAdditions > buffer.length) {
this.buffer = ArrayUtil.grow(buffer, elementsCount + expectedAdditions);
}
}
@@ -288,9 +285,9 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
public void resize(int newSize) {
if (newSize <= buffer.length) {
if (newSize < elementsCount) {
- Arrays.fill(buffer, newSize, elementsCount, 0);
+ Arrays.fill(buffer, newSize, elementsCount, 0f);
} else {
- Arrays.fill(buffer, elementsCount, newSize, 0);
+ Arrays.fill(buffer, elementsCount, newSize, 0f);
}
} else {
ensureCapacity(newSize);
@@ -315,7 +312,7 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
* #elementsCount} field to zero.
*/
public void clear() {
- Arrays.fill(buffer, 0, elementsCount, 0);
+ Arrays.fill(buffer, 0, elementsCount, 0f);
this.elementsCount = 0;
}
@@ -326,7 +323,7 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
}
/** The returned array is sized to match exactly the number of elements of the stack. */
- public int[] toArray() {
+ public float[] toArray() {
return ArrayUtil.copyOfSubArray(buffer, 0, elementsCount);
}
@@ -336,9 +333,9 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
* strategy.
*/
@Override
- public IntArrayList clone() {
+ public FloatArrayList clone() {
try {
- final IntArrayList cloned = (IntArrayList) super.clone();
+ final FloatArrayList cloned = (FloatArrayList) super.clone();
cloned.buffer = buffer.clone();
return cloned;
} catch (CloneNotSupportedException e) {
@@ -365,8 +362,8 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
|| (obj != null && getClass() == obj.getClass() && equalElements(getClass().cast(obj)));
}
- /** Compare index-aligned elements against another {@link IntArrayList}. */
- protected boolean equalElements(IntArrayList other) {
+ /** Compare index-aligned elements against another {@link FloatArrayList}. */
+ protected boolean equalElements(FloatArrayList other) {
int max = size();
if (other.size() != max) {
return false;
@@ -392,43 +389,38 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
return BASE_RAM_BYTES_USED + RamUsageEstimator.sizeOf(buffer);
}
- /** Returns a stream of all the elements contained in this list. */
- public IntStream stream() {
- return Arrays.stream(buffer, 0, size());
- }
-
/** Sorts the elements in this list and returns this list. */
- public IntArrayList sort() {
+ public FloatArrayList sort() {
Arrays.sort(buffer, 0, elementsCount);
return this;
}
/** Reverses the elements in this list and returns this list. */
- public IntArrayList reverse() {
+ public FloatArrayList reverse() {
for (int i = 0, mid = elementsCount >> 1, j = elementsCount - 1; i < mid; i++, j--) {
- int tmp = buffer[i];
+ float tmp = buffer[i];
buffer[i] = buffer[j];
buffer[j] = tmp;
}
return this;
}
- /** An iterator implementation for {@link IntArrayList#iterator}. */
- static final class ValueIterator extends AbstractIterator<IntCursor> {
- private final IntCursor cursor;
+ /** An iterator implementation for {@link FloatArrayList#iterator}. */
+ static final class ValueIterator extends AbstractIterator<FloatCursor> {
+ private final FloatCursor cursor;
- private final int[] buffer;
+ private final float[] buffer;
private final int size;
- public ValueIterator(int[] buffer, int size) {
- this.cursor = new IntCursor();
+ public ValueIterator(float[] buffer, int size) {
+ this.cursor = new FloatCursor();
this.cursor.index = -1;
this.size = size;
this.buffer = buffer;
}
@Override
- protected IntCursor fetch() {
+ protected FloatCursor fetch() {
if (cursor.index + 1 == size) return done();
cursor.value = buffer[++cursor.index];
@@ -437,7 +429,7 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
}
@Override
- public Iterator<IntCursor> iterator() {
+ public Iterator<FloatCursor> iterator() {
return new ValueIterator(buffer, size());
}
@@ -446,8 +438,8 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
* are copied from the argument to the internal buffer.
*/
/* */
- public static IntArrayList from(int... elements) {
- final IntArrayList list = new IntArrayList(elements.length);
+ public static FloatArrayList from(float... elements) {
+ final FloatArrayList list = new FloatArrayList(elements.length);
list.add(elements);
return list;
}
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/ObjectCursor.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/FloatCursor.java
similarity index 86%
copy from lucene/core/src/java/org/apache/lucene/util/hppc/ObjectCursor.java
copy to lucene/core/src/java/org/apache/lucene/internal/hppc/FloatCursor.java
index 45d0cb56b62..1851aa7572b 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/ObjectCursor.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/FloatCursor.java
@@ -15,10 +15,14 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
-/** Forked from HPPC, holding int index and Object value */
-public final class ObjectCursor<VType> {
+/**
+ * Forked from HPPC, holding int index and float value.
+ *
+ * @lucene.internal
+ */
+public final class FloatCursor {
/**
* The current value's index in the container this cursor belongs to. The meaning of this index is
* defined by the container (usually it will be an index in the underlying storage buffer).
@@ -26,7 +30,7 @@ public final class ObjectCursor<VType> {
public int index;
/** The current value. */
- public VType value;
+ public float value;
@Override
public String toString() {
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/HashContainers.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/HashContainers.java
similarity index 97%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/HashContainers.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/HashContainers.java
index 7859c457eb9..f65f93d2db5 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/HashContainers.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/HashContainers.java
@@ -15,13 +15,17 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import static org.apache.lucene.util.BitUtil.nextHighestPowerOfTwo;
import java.util.concurrent.atomic.AtomicInteger;
-/** Constants for primitive maps. */
+/**
+ * Constants for primitive maps.
+ *
+ * @lucene.internal
+ */
class HashContainers {
static final int DEFAULT_EXPECTED_ELEMENTS = 4;
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/IntArrayList.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/IntArrayList.java
similarity index 96%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/IntArrayList.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/IntArrayList.java
index bc80e36463b..992c924630d 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/IntArrayList.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/IntArrayList.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
-import static org.apache.lucene.util.hppc.HashContainers.DEFAULT_EXPECTED_ELEMENTS;
+import static org.apache.lucene.internal.hppc.HashContainers.DEFAULT_EXPECTED_ELEMENTS;
import java.util.Arrays;
import java.util.Iterator;
@@ -31,7 +31,9 @@ import org.apache.lucene.util.RamUsageEstimator;
*
* <p>Mostly forked and trimmed from com.carrotsearch.hppc.IntArrayList
*
- * <p>github: https://github.com/carrotsearch/hppc release 0.9.0
+ * <p>github: https://github.com/carrotsearch/hppc release 0.10.0
+ *
+ * @lucene.internal
*/
public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable {
private static final long BASE_RAM_BYTES_USED =
@@ -40,13 +42,11 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
/** An immutable empty buffer (array). */
public static final int[] EMPTY_ARRAY = new int[0];
- ;
-
/**
* Internal array for storing the list. The array may be larger than the current size ({@link
* #size()}).
*/
- public int[] buffer = EMPTY_ARRAY;
+ public int[] buffer;
/** Current number of elements stored in {@link #buffer}. */
public int elementsCount;
@@ -262,8 +262,7 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
* @param expectedElements The total number of elements, inclusive.
*/
public void ensureCapacity(int expectedElements) {
- final int bufferLen = (buffer == null ? 0 : buffer.length);
- if (expectedElements > bufferLen) {
+ if (expectedElements > buffer.length) {
ensureBufferSpace(expectedElements - size());
}
}
@@ -273,8 +272,7 @@ public class IntArrayList implements Iterable<IntCursor>, Cloneable, Accountable
* Increases internal buffer size if needed.
*/
protected void ensureBufferSpace(int expectedAdditions) {
- final int bufferLen = (buffer == null ? 0 : buffer.length);
- if (elementsCount + expectedAdditions > bufferLen) {
+ if (elementsCount + expectedAdditions > buffer.length) {
this.buffer = ArrayUtil.grow(buffer, elementsCount + expectedAdditions);
}
}
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/IntCursor.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/IntCursor.java
similarity index 90%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/IntCursor.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/IntCursor.java
index 72a83e0d416..bb79c9167e3 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/IntCursor.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/IntCursor.java
@@ -15,9 +15,13 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
-/** Forked from HPPC, holding int index and int value */
+/**
+ * Forked from HPPC, holding int index and int value.
+ *
+ * @lucene.internal
+ */
public final class IntCursor {
/**
* The current value's index in the container this cursor belongs to. The meaning of this index is
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/IntIntHashMap.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/IntDoubleHashMap.java
similarity index 80%
copy from lucene/core/src/java/org/apache/lucene/util/hppc/IntIntHashMap.java
copy to lucene/core/src/java/org/apache/lucene/internal/hppc/IntDoubleHashMap.java
index bb9488ce9d5..60c4876d9ae 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/IntIntHashMap.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/IntDoubleHashMap.java
@@ -15,9 +15,19 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
-
-import static org.apache.lucene.util.hppc.HashContainers.*;
+package org.apache.lucene.internal.hppc;
+
+import static org.apache.lucene.internal.hppc.HashContainers.DEFAULT_EXPECTED_ELEMENTS;
+import static org.apache.lucene.internal.hppc.HashContainers.DEFAULT_LOAD_FACTOR;
+import static org.apache.lucene.internal.hppc.HashContainers.ITERATION_SEED;
+import static org.apache.lucene.internal.hppc.HashContainers.MAX_LOAD_FACTOR;
+import static org.apache.lucene.internal.hppc.HashContainers.MIN_LOAD_FACTOR;
+import static org.apache.lucene.internal.hppc.HashContainers.checkLoadFactor;
+import static org.apache.lucene.internal.hppc.HashContainers.checkPowerOfTwo;
+import static org.apache.lucene.internal.hppc.HashContainers.expandAtCount;
+import static org.apache.lucene.internal.hppc.HashContainers.iterationIncrement;
+import static org.apache.lucene.internal.hppc.HashContainers.minBufferSize;
+import static org.apache.lucene.internal.hppc.HashContainers.nextBufferSize;
import java.util.Arrays;
import java.util.Iterator;
@@ -25,23 +35,26 @@ import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.RamUsageEstimator;
/**
- * A hash map of <code>int</code> to <code>int</code>, implemented using open addressing with linear
- * probing for collision resolution.
+ * A hash map of <code>int</code> to <code>double</code>, implemented using open addressing with
+ * linear probing for collision resolution.
+ *
+ * <p>Mostly forked and trimmed from com.carrotsearch.hppc.IntDoubleHashMap
*
- * <p>Mostly forked and trimmed from com.carrotsearch.hppc.IntIntHashMap
+ * <p>github: https://github.com/carrotsearch/hppc release 0.10.0
*
- * <p>github: https://github.com/carrotsearch/hppc release 0.9.0
+ * @lucene.internal
*/
-public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Accountable, Cloneable {
+public class IntDoubleHashMap
+ implements Iterable<IntDoubleHashMap.IntDoubleCursor>, Accountable, Cloneable {
private static final long BASE_RAM_BYTES_USED =
- RamUsageEstimator.shallowSizeOfInstance(IntIntHashMap.class);
+ RamUsageEstimator.shallowSizeOfInstance(IntDoubleHashMap.class);
/** The array holding keys. */
public int[] keys;
/** The array holding values. */
- public int[] values;
+ public double[] values;
/**
* The number of stored keys (assigned key slots), excluding the special "empty" key, if any (use
@@ -67,7 +80,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
protected int iterationSeed;
/** New instance with sane defaults. */
- public IntIntHashMap() {
+ public IntDoubleHashMap() {
this(DEFAULT_EXPECTED_ELEMENTS);
}
@@ -77,7 +90,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
* @param expectedElements The expected number of elements guaranteed not to cause buffer
* expansion (inclusive).
*/
- public IntIntHashMap(int expectedElements) {
+ public IntDoubleHashMap(int expectedElements) {
this(expectedElements, DEFAULT_LOAD_FACTOR);
}
@@ -89,24 +102,24 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
* @param loadFactor The load factor for internal buffers. Insane load factors (zero, full
* capacity) are rejected by {@link #verifyLoadFactor(double)}.
*/
- public IntIntHashMap(int expectedElements, double loadFactor) {
+ public IntDoubleHashMap(int expectedElements, double loadFactor) {
this.loadFactor = verifyLoadFactor(loadFactor);
iterationSeed = ITERATION_SEED.incrementAndGet();
ensureCapacity(expectedElements);
}
/** Create a hash map from all key-value pairs of another map. */
- public IntIntHashMap(IntIntHashMap map) {
+ public IntDoubleHashMap(IntDoubleHashMap map) {
this(map.size());
putAll(map);
}
- public int put(int key, int value) {
+ public double put(int key, double value) {
assert assigned < mask + 1;
final int mask = this.mask;
if (((key) == 0)) {
- int previousValue = hasEmptyKey ? values[mask + 1] : 0;
+ double previousValue = hasEmptyKey ? values[mask + 1] : 0;
hasEmptyKey = true;
values[mask + 1] = value;
return previousValue;
@@ -117,7 +130,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
int existing;
while (!((existing = keys[slot]) == 0)) {
if (((existing) == (key))) {
- final int previousValue = values[slot];
+ final double previousValue = values[slot];
values[slot] = value;
return previousValue;
}
@@ -136,9 +149,9 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
}
- public int putAll(Iterable<? extends IntIntCursor> iterable) {
+ public int putAll(Iterable<? extends IntDoubleCursor> iterable) {
final int count = size();
- for (IntIntCursor c : iterable) {
+ for (IntDoubleCursor c : iterable) {
put(c.key, c.value);
}
return size() - count;
@@ -157,7 +170,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
* @return <code>true</code> if <code>key</code> did not exist and <code>value</code> was placed
* in the map.
*/
- public boolean putIfAbsent(int key, int value) {
+ public boolean putIfAbsent(int key, double value) {
int keyIndex = indexOf(key);
if (!indexExists(keyIndex)) {
indexInsert(keyIndex, key, value);
@@ -176,7 +189,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
* @param incrementValue The value to add to the existing value if <code>key</code> exists.
* @return Returns the current value associated with <code>key</code> (after changes).
*/
- public int putOrAdd(int key, int putValue, int incrementValue) {
+ public double putOrAdd(int key, double putValue, double incrementValue) {
assert assigned < mask + 1;
int keyIndex = indexOf(key);
@@ -197,18 +210,18 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
* @param incrementValue The value to put or add to the existing value if <code>key</code> exists.
* @return Returns the current value associated with <code>key</code> (after changes).
*/
- public int addTo(int key, int incrementValue) {
+ public double addTo(int key, double incrementValue) {
return putOrAdd(key, incrementValue, incrementValue);
}
- public int remove(int key) {
+ public double remove(int key) {
final int mask = this.mask;
if (((key) == 0)) {
if (!hasEmptyKey) {
return 0;
}
hasEmptyKey = false;
- int previousValue = values[mask + 1];
+ double previousValue = values[mask + 1];
values[mask + 1] = 0;
return previousValue;
} else {
@@ -218,7 +231,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
int existing;
while (!((existing = keys[slot]) == 0)) {
if (((existing) == (key))) {
- final int previousValue = values[slot];
+ final double previousValue = values[slot];
shiftConflictingKeys(slot);
return previousValue;
}
@@ -229,7 +242,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
}
- public int get(int key) {
+ public double get(int key) {
if (((key) == 0)) {
return hasEmptyKey ? values[mask + 1] : 0;
} else {
@@ -249,7 +262,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
}
- public int getOrDefault(int key, int defaultValue) {
+ public double getOrDefault(int key, double defaultValue) {
if (((key) == 0)) {
return hasEmptyKey ? values[mask + 1] : defaultValue;
} else {
@@ -310,28 +323,28 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
public boolean indexExists(int index) {
- assert index < 0 || (index >= 0 && index <= mask) || (index == mask + 1 && hasEmptyKey);
+ assert index < 0 || index <= mask || (index == mask + 1 && hasEmptyKey);
return index >= 0;
}
- public int indexGet(int index) {
+ public double indexGet(int index) {
assert index >= 0 : "The index must point at an existing key.";
assert index <= mask || (index == mask + 1 && hasEmptyKey);
return values[index];
}
- public int indexReplace(int index, int newValue) {
+ public double indexReplace(int index, double newValue) {
assert index >= 0 : "The index must point at an existing key.";
assert index <= mask || (index == mask + 1 && hasEmptyKey);
- int previousValue = values[index];
+ double previousValue = values[index];
values[index] = newValue;
return previousValue;
}
- public void indexInsert(int index, int key, int value) {
+ public void indexInsert(int index, int key, double value) {
assert index < 0 : "The index must not point at an existing key.";
index = ~index;
@@ -353,11 +366,11 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
}
- public int indexRemove(int index) {
+ public double indexRemove(int index) {
assert index >= 0 : "The index must point at an existing key.";
assert index <= mask || (index == mask + 1 && hasEmptyKey);
- int previousValue = values[index];
+ double previousValue = values[index];
if (index > mask) {
assert index == mask + 1;
hasEmptyKey = false;
@@ -397,7 +410,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
@Override
public int hashCode() {
int h = hasEmptyKey ? 0xDEADBEEF : 0;
- for (IntIntCursor c : this) {
+ for (IntDoubleCursor c : this) {
h += BitMixer.mix(c.key) + BitMixer.mix(c.value);
}
return h;
@@ -410,14 +423,15 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
/** Return true if all keys of some other container exist in this container. */
- protected boolean equalElements(IntIntHashMap other) {
+ protected boolean equalElements(IntDoubleHashMap other) {
if (other.size() != size()) {
return false;
}
- for (IntIntCursor c : other) {
+ for (IntDoubleCursor c : other) {
int key = c.key;
- if (!containsKey(key) || !((get(key)) == (c.value))) {
+ if (!containsKey(key)
+ || !(Double.doubleToLongBits(c.value) == Double.doubleToLongBits(get(key)))) {
return false;
}
}
@@ -434,7 +448,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
public void ensureCapacity(int expectedElements) {
if (expectedElements > resizeAt || keys == null) {
final int[] prevKeys = this.keys;
- final int[] prevValues = this.values;
+ final double[] prevValues = this.values;
allocateBuffers(minBufferSize(expectedElements, loadFactor));
if (prevKeys != null && !isEmpty()) {
rehash(prevKeys, prevValues);
@@ -457,22 +471,22 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
/** An iterator implementation for {@link #iterator}. */
- private final class EntryIterator extends AbstractIterator<IntIntCursor> {
- private final IntIntCursor cursor;
+ private final class EntryIterator extends AbstractIterator<IntDoubleCursor> {
+ private final IntDoubleCursor cursor;
private final int increment;
private int index;
private int slot;
public EntryIterator() {
- cursor = new IntIntCursor();
+ cursor = new IntDoubleCursor();
int seed = nextIterationSeed();
increment = iterationIncrement(seed);
slot = seed & mask;
}
@Override
- protected IntIntCursor fetch() {
- final int mask = IntIntHashMap.this.mask;
+ protected IntDoubleCursor fetch() {
+ final int mask = IntDoubleHashMap.this.mask;
while (index <= mask) {
int existing;
index++;
@@ -497,7 +511,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
@Override
- public Iterator<IntIntCursor> iterator() {
+ public Iterator<IntDoubleCursor> iterator() {
return new EntryIterator();
}
@@ -507,11 +521,25 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
/** A view of the keys inside this hash map. */
- public final class KeysContainer extends IntContainer {
+ public final class KeysContainer implements Iterable<IntCursor> {
+
@Override
public Iterator<IntCursor> iterator() {
return new KeysIterator();
}
+
+ public int size() {
+ return IntDoubleHashMap.this.size();
+ }
+
+ public int[] toArray() {
+ int[] array = new int[size()];
+ int i = 0;
+ for (IntCursor cursor : this) {
+ array[i++] = cursor.value;
+ }
+ return array;
+ }
}
/** An iterator over the set of assigned keys. */
@@ -530,7 +558,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
@Override
protected IntCursor fetch() {
- final int mask = IntIntHashMap.this.mask;
+ final int mask = IntDoubleHashMap.this.mask;
while (index <= mask) {
int existing;
index++;
@@ -555,29 +583,26 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
/**
* @return Returns a container with all values stored in this map.
*/
- public IntContainer values() {
+ public ValuesContainer values() {
return new ValuesContainer();
}
/** A view over the set of values of this map. */
- private final class ValuesContainer extends IntContainer {
+ public final class ValuesContainer implements Iterable<DoubleCursor> {
+
@Override
- public Iterator<IntCursor> iterator() {
+ public Iterator<DoubleCursor> iterator() {
return new ValuesIterator();
}
- }
-
- /** IntCursor iterable with size and toArray function implemented */
- public abstract class IntContainer implements Iterable<IntCursor> {
public int size() {
- return IntIntHashMap.this.size();
+ return IntDoubleHashMap.this.size();
}
- public int[] toArray() {
- int[] array = new int[size()];
+ public double[] toArray() {
+ double[] array = new double[size()];
int i = 0;
- for (IntCursor cursor : this) {
+ for (DoubleCursor cursor : this) {
array[i++] = cursor.value;
}
return array;
@@ -585,22 +610,22 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
/** An iterator over the set of assigned values. */
- private final class ValuesIterator extends AbstractIterator<IntCursor> {
- private final IntCursor cursor;
+ private final class ValuesIterator extends AbstractIterator<DoubleCursor> {
+ private final DoubleCursor cursor;
private final int increment;
private int index;
private int slot;
public ValuesIterator() {
- cursor = new IntCursor();
+ cursor = new DoubleCursor();
int seed = nextIterationSeed();
increment = iterationIncrement(seed);
slot = seed & mask;
}
@Override
- protected IntCursor fetch() {
- final int mask = IntIntHashMap.this.mask;
+ protected DoubleCursor fetch() {
+ final int mask = IntDoubleHashMap.this.mask;
while (index <= mask) {
index++;
slot = (slot + increment) & mask;
@@ -622,10 +647,10 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
@Override
- public IntIntHashMap clone() {
+ public IntDoubleHashMap clone() {
try {
/* */
- IntIntHashMap cloned = (IntIntHashMap) super.clone();
+ IntDoubleHashMap cloned = (IntDoubleHashMap) super.clone();
cloned.keys = keys.clone();
cloned.values = values.clone();
cloned.hasEmptyKey = hasEmptyKey;
@@ -643,7 +668,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
buffer.append("[");
boolean first = true;
- for (IntIntCursor cursor : this) {
+ for (IntDoubleCursor cursor : this) {
if (!first) {
buffer.append(", ");
}
@@ -657,13 +682,13 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
/** Creates a hash map from two index-aligned arrays of key-value pairs. */
- public static IntIntHashMap from(int[] keys, int[] values) {
+ public static IntDoubleHashMap from(int[] keys, double[] values) {
if (keys.length != values.length) {
throw new IllegalArgumentException(
"Arrays of keys and values must have an identical length.");
}
- IntIntHashMap map = new IntIntHashMap(keys.length);
+ IntDoubleHashMap map = new IntDoubleHashMap(keys.length);
for (int i = 0; i < keys.length; i++) {
map.put(keys[i], values[i]);
}
@@ -691,12 +716,12 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
/** Rehash from old buffers to new buffers. */
- protected void rehash(int[] fromKeys, int[] fromValues) {
+ protected void rehash(int[] fromKeys, double[] fromValues) {
assert fromKeys.length == fromValues.length && checkPowerOfTwo(fromKeys.length - 1);
// Rehash all stored key/value pairs into the new buffers.
final int[] keys = this.keys;
- final int[] values = this.values;
+ final double[] values = this.values;
final int mask = this.mask;
int existing;
@@ -725,11 +750,11 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
// Ensure no change is done if we hit an OOM.
int[] prevKeys = this.keys;
- int[] prevValues = this.values;
+ double[] prevValues = this.values;
try {
int emptyElementSlot = 1;
this.keys = (new int[arraySize + emptyElementSlot]);
- this.values = (new int[arraySize + emptyElementSlot]);
+ this.values = (new double[arraySize + emptyElementSlot]);
} catch (OutOfMemoryError e) {
this.keys = prevKeys;
this.values = prevValues;
@@ -750,12 +775,12 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
* assign the pending element to the previous buffer (possibly violating the invariant of having
* at least one empty slot) and rehash all keys, substituting new buffers at the end.
*/
- protected void allocateThenInsertThenRehash(int slot, int pendingKey, int pendingValue) {
+ protected void allocateThenInsertThenRehash(int slot, int pendingKey, double pendingValue) {
assert assigned == resizeAt && ((keys[slot]) == 0) && !((pendingKey) == 0);
// Try to allocate new buffers first. If we OOM, we leave in a consistent state.
final int[] prevKeys = this.keys;
- final int[] prevValues = this.values;
+ final double[] prevValues = this.values;
allocateBuffers(nextBufferSize(mask + 1, size(), loadFactor));
assert this.keys.length > prevKeys.length;
@@ -773,7 +798,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
*/
protected void shiftConflictingKeys(int gapSlot) {
final int[] keys = this.keys;
- final int[] values = this.values;
+ final double[] values = this.values;
final int mask = this.mask;
// Perform shifts of conflicting keys to fill in the gap.
@@ -806,10 +831,10 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
/** Forked from HPPC, holding int index,key and value */
- public final class IntIntCursor {
+ public static final class IntDoubleCursor {
/**
- * The current key and value's index in the container this cursor belongs to. The meaning of
- * this index is defined by the container (usually it will be an index in the underlying storage
+ * The current key and value's index in the container this cursor beints to. The meaning of this
+ * index is defined by the container (usually it will be an index in the underlying storage
* buffer).
*/
public int index;
@@ -818,7 +843,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
public int key;
/** The current value. */
- public int value;
+ public double value;
@Override
public String toString() {
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/IntIntHashMap.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/IntFloatHashMap.java
similarity index 79%
copy from lucene/core/src/java/org/apache/lucene/util/hppc/IntIntHashMap.java
copy to lucene/core/src/java/org/apache/lucene/internal/hppc/IntFloatHashMap.java
index bb9488ce9d5..045585e7087 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/IntIntHashMap.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/IntFloatHashMap.java
@@ -15,9 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
-
-import static org.apache.lucene.util.hppc.HashContainers.*;
+package org.apache.lucene.internal.hppc;
import java.util.Arrays;
import java.util.Iterator;
@@ -25,23 +23,26 @@ import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.RamUsageEstimator;
/**
- * A hash map of <code>int</code> to <code>int</code>, implemented using open addressing with linear
- * probing for collision resolution.
+ * A hash map of <code>int</code> to <code>float</code>, implemented using open addressing with
+ * linear probing for collision resolution.
+ *
+ * <p>Mostly forked and trimmed from com.carrotsearch.hppc.IntFloatHashMap
*
- * <p>Mostly forked and trimmed from com.carrotsearch.hppc.IntIntHashMap
+ * <p>github: https://github.com/carrotsearch/hppc release 0.10.0
*
- * <p>github: https://github.com/carrotsearch/hppc release 0.9.0
+ * @lucene.internal
*/
-public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Accountable, Cloneable {
+public class IntFloatHashMap
+ implements Iterable<IntFloatHashMap.IntFloatCursor>, Accountable, Cloneable {
private static final long BASE_RAM_BYTES_USED =
- RamUsageEstimator.shallowSizeOfInstance(IntIntHashMap.class);
+ RamUsageEstimator.shallowSizeOfInstance(IntFloatHashMap.class);
/** The array holding keys. */
public int[] keys;
/** The array holding values. */
- public int[] values;
+ public float[] values;
/**
* The number of stored keys (assigned key slots), excluding the special "empty" key, if any (use
@@ -67,8 +68,8 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
protected int iterationSeed;
/** New instance with sane defaults. */
- public IntIntHashMap() {
- this(DEFAULT_EXPECTED_ELEMENTS);
+ public IntFloatHashMap() {
+ this(HashContainers.DEFAULT_EXPECTED_ELEMENTS);
}
/**
@@ -77,8 +78,8 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
* @param expectedElements The expected number of elements guaranteed not to cause buffer
* expansion (inclusive).
*/
- public IntIntHashMap(int expectedElements) {
- this(expectedElements, DEFAULT_LOAD_FACTOR);
+ public IntFloatHashMap(int expectedElements) {
+ this(expectedElements, HashContainers.DEFAULT_LOAD_FACTOR);
}
/**
@@ -89,24 +90,24 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
* @param loadFactor The load factor for internal buffers. Insane load factors (zero, full
* capacity) are rejected by {@link #verifyLoadFactor(double)}.
*/
- public IntIntHashMap(int expectedElements, double loadFactor) {
+ public IntFloatHashMap(int expectedElements, double loadFactor) {
this.loadFactor = verifyLoadFactor(loadFactor);
- iterationSeed = ITERATION_SEED.incrementAndGet();
+ iterationSeed = HashContainers.ITERATION_SEED.incrementAndGet();
ensureCapacity(expectedElements);
}
/** Create a hash map from all key-value pairs of another map. */
- public IntIntHashMap(IntIntHashMap map) {
+ public IntFloatHashMap(IntFloatHashMap map) {
this(map.size());
putAll(map);
}
- public int put(int key, int value) {
+ public float put(int key, float value) {
assert assigned < mask + 1;
final int mask = this.mask;
if (((key) == 0)) {
- int previousValue = hasEmptyKey ? values[mask + 1] : 0;
+ float previousValue = hasEmptyKey ? values[mask + 1] : 0;
hasEmptyKey = true;
values[mask + 1] = value;
return previousValue;
@@ -117,7 +118,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
int existing;
while (!((existing = keys[slot]) == 0)) {
if (((existing) == (key))) {
- final int previousValue = values[slot];
+ final float previousValue = values[slot];
values[slot] = value;
return previousValue;
}
@@ -136,9 +137,9 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
}
- public int putAll(Iterable<? extends IntIntCursor> iterable) {
+ public int putAll(Iterable<? extends IntFloatCursor> iterable) {
final int count = size();
- for (IntIntCursor c : iterable) {
+ for (IntFloatCursor c : iterable) {
put(c.key, c.value);
}
return size() - count;
@@ -157,7 +158,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
* @return <code>true</code> if <code>key</code> did not exist and <code>value</code> was placed
* in the map.
*/
- public boolean putIfAbsent(int key, int value) {
+ public boolean putIfAbsent(int key, float value) {
int keyIndex = indexOf(key);
if (!indexExists(keyIndex)) {
indexInsert(keyIndex, key, value);
@@ -176,7 +177,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
* @param incrementValue The value to add to the existing value if <code>key</code> exists.
* @return Returns the current value associated with <code>key</code> (after changes).
*/
- public int putOrAdd(int key, int putValue, int incrementValue) {
+ public float putOrAdd(int key, float putValue, float incrementValue) {
assert assigned < mask + 1;
int keyIndex = indexOf(key);
@@ -197,18 +198,18 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
* @param incrementValue The value to put or add to the existing value if <code>key</code> exists.
* @return Returns the current value associated with <code>key</code> (after changes).
*/
- public int addTo(int key, int incrementValue) {
+ public float addTo(int key, float incrementValue) {
return putOrAdd(key, incrementValue, incrementValue);
}
- public int remove(int key) {
+ public float remove(int key) {
final int mask = this.mask;
if (((key) == 0)) {
if (!hasEmptyKey) {
return 0;
}
hasEmptyKey = false;
- int previousValue = values[mask + 1];
+ float previousValue = values[mask + 1];
values[mask + 1] = 0;
return previousValue;
} else {
@@ -218,7 +219,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
int existing;
while (!((existing = keys[slot]) == 0)) {
if (((existing) == (key))) {
- final int previousValue = values[slot];
+ final float previousValue = values[slot];
shiftConflictingKeys(slot);
return previousValue;
}
@@ -229,7 +230,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
}
- public int get(int key) {
+ public float get(int key) {
if (((key) == 0)) {
return hasEmptyKey ? values[mask + 1] : 0;
} else {
@@ -249,7 +250,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
}
- public int getOrDefault(int key, int defaultValue) {
+ public float getOrDefault(int key, float defaultValue) {
if (((key) == 0)) {
return hasEmptyKey ? values[mask + 1] : defaultValue;
} else {
@@ -310,28 +311,28 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
public boolean indexExists(int index) {
- assert index < 0 || (index >= 0 && index <= mask) || (index == mask + 1 && hasEmptyKey);
+ assert index < 0 || index <= mask || (index == mask + 1 && hasEmptyKey);
return index >= 0;
}
- public int indexGet(int index) {
+ public float indexGet(int index) {
assert index >= 0 : "The index must point at an existing key.";
assert index <= mask || (index == mask + 1 && hasEmptyKey);
return values[index];
}
- public int indexReplace(int index, int newValue) {
+ public float indexReplace(int index, float newValue) {
assert index >= 0 : "The index must point at an existing key.";
assert index <= mask || (index == mask + 1 && hasEmptyKey);
- int previousValue = values[index];
+ float previousValue = values[index];
values[index] = newValue;
return previousValue;
}
- public void indexInsert(int index, int key, int value) {
+ public void indexInsert(int index, int key, float value) {
assert index < 0 : "The index must not point at an existing key.";
index = ~index;
@@ -353,11 +354,11 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
}
- public int indexRemove(int index) {
+ public float indexRemove(int index) {
assert index >= 0 : "The index must point at an existing key.";
assert index <= mask || (index == mask + 1 && hasEmptyKey);
- int previousValue = values[index];
+ float previousValue = values[index];
if (index > mask) {
assert index == mask + 1;
hasEmptyKey = false;
@@ -383,7 +384,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
keys = null;
values = null;
- ensureCapacity(DEFAULT_EXPECTED_ELEMENTS);
+ ensureCapacity(HashContainers.DEFAULT_EXPECTED_ELEMENTS);
}
public int size() {
@@ -397,7 +398,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
@Override
public int hashCode() {
int h = hasEmptyKey ? 0xDEADBEEF : 0;
- for (IntIntCursor c : this) {
+ for (IntFloatCursor c : this) {
h += BitMixer.mix(c.key) + BitMixer.mix(c.value);
}
return h;
@@ -410,14 +411,14 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
/** Return true if all keys of some other container exist in this container. */
- protected boolean equalElements(IntIntHashMap other) {
+ protected boolean equalElements(IntFloatHashMap other) {
if (other.size() != size()) {
return false;
}
- for (IntIntCursor c : other) {
+ for (IntFloatCursor c : other) {
int key = c.key;
- if (!containsKey(key) || !((get(key)) == (c.value))) {
+ if (!containsKey(key) || !(Float.floatToIntBits(c.value) == Float.floatToIntBits(get(key)))) {
return false;
}
}
@@ -434,8 +435,8 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
public void ensureCapacity(int expectedElements) {
if (expectedElements > resizeAt || keys == null) {
final int[] prevKeys = this.keys;
- final int[] prevValues = this.values;
- allocateBuffers(minBufferSize(expectedElements, loadFactor));
+ final float[] prevValues = this.values;
+ allocateBuffers(HashContainers.minBufferSize(expectedElements, loadFactor));
if (prevKeys != null && !isEmpty()) {
rehash(prevKeys, prevValues);
}
@@ -457,22 +458,22 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
/** An iterator implementation for {@link #iterator}. */
- private final class EntryIterator extends AbstractIterator<IntIntCursor> {
- private final IntIntCursor cursor;
+ private final class EntryIterator extends AbstractIterator<IntFloatCursor> {
+ private final IntFloatCursor cursor;
private final int increment;
private int index;
private int slot;
public EntryIterator() {
- cursor = new IntIntCursor();
+ cursor = new IntFloatCursor();
int seed = nextIterationSeed();
- increment = iterationIncrement(seed);
+ increment = HashContainers.iterationIncrement(seed);
slot = seed & mask;
}
@Override
- protected IntIntCursor fetch() {
- final int mask = IntIntHashMap.this.mask;
+ protected IntFloatCursor fetch() {
+ final int mask = IntFloatHashMap.this.mask;
while (index <= mask) {
int existing;
index++;
@@ -497,7 +498,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
@Override
- public Iterator<IntIntCursor> iterator() {
+ public Iterator<IntFloatCursor> iterator() {
return new EntryIterator();
}
@@ -507,11 +508,25 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
/** A view of the keys inside this hash map. */
- public final class KeysContainer extends IntContainer {
+ public final class KeysContainer implements Iterable<IntCursor> {
+
@Override
public Iterator<IntCursor> iterator() {
return new KeysIterator();
}
+
+ public int size() {
+ return IntFloatHashMap.this.size();
+ }
+
+ public int[] toArray() {
+ int[] array = new int[size()];
+ int i = 0;
+ for (IntCursor cursor : this) {
+ array[i++] = cursor.value;
+ }
+ return array;
+ }
}
/** An iterator over the set of assigned keys. */
@@ -524,13 +539,13 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
public KeysIterator() {
cursor = new IntCursor();
int seed = nextIterationSeed();
- increment = iterationIncrement(seed);
+ increment = HashContainers.iterationIncrement(seed);
slot = seed & mask;
}
@Override
protected IntCursor fetch() {
- final int mask = IntIntHashMap.this.mask;
+ final int mask = IntFloatHashMap.this.mask;
while (index <= mask) {
int existing;
index++;
@@ -555,29 +570,26 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
/**
* @return Returns a container with all values stored in this map.
*/
- public IntContainer values() {
+ public ValuesContainer values() {
return new ValuesContainer();
}
/** A view over the set of values of this map. */
- private final class ValuesContainer extends IntContainer {
+ public final class ValuesContainer implements Iterable<FloatCursor> {
+
@Override
- public Iterator<IntCursor> iterator() {
+ public Iterator<FloatCursor> iterator() {
return new ValuesIterator();
}
- }
-
- /** IntCursor iterable with size and toArray function implemented */
- public abstract class IntContainer implements Iterable<IntCursor> {
public int size() {
- return IntIntHashMap.this.size();
+ return IntFloatHashMap.this.size();
}
- public int[] toArray() {
- int[] array = new int[size()];
+ public float[] toArray() {
+ float[] array = new float[size()];
int i = 0;
- for (IntCursor cursor : this) {
+ for (FloatCursor cursor : this) {
array[i++] = cursor.value;
}
return array;
@@ -585,22 +597,22 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
/** An iterator over the set of assigned values. */
- private final class ValuesIterator extends AbstractIterator<IntCursor> {
- private final IntCursor cursor;
+ private final class ValuesIterator extends AbstractIterator<FloatCursor> {
+ private final FloatCursor cursor;
private final int increment;
private int index;
private int slot;
public ValuesIterator() {
- cursor = new IntCursor();
+ cursor = new FloatCursor();
int seed = nextIterationSeed();
- increment = iterationIncrement(seed);
+ increment = HashContainers.iterationIncrement(seed);
slot = seed & mask;
}
@Override
- protected IntCursor fetch() {
- final int mask = IntIntHashMap.this.mask;
+ protected FloatCursor fetch() {
+ final int mask = IntFloatHashMap.this.mask;
while (index <= mask) {
index++;
slot = (slot + increment) & mask;
@@ -622,14 +634,14 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
@Override
- public IntIntHashMap clone() {
+ public IntFloatHashMap clone() {
try {
/* */
- IntIntHashMap cloned = (IntIntHashMap) super.clone();
+ IntFloatHashMap cloned = (IntFloatHashMap) super.clone();
cloned.keys = keys.clone();
cloned.values = values.clone();
cloned.hasEmptyKey = hasEmptyKey;
- cloned.iterationSeed = ITERATION_SEED.incrementAndGet();
+ cloned.iterationSeed = HashContainers.ITERATION_SEED.incrementAndGet();
return cloned;
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
@@ -643,7 +655,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
buffer.append("[");
boolean first = true;
- for (IntIntCursor cursor : this) {
+ for (IntFloatCursor cursor : this) {
if (!first) {
buffer.append(", ");
}
@@ -657,13 +669,13 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
/** Creates a hash map from two index-aligned arrays of key-value pairs. */
- public static IntIntHashMap from(int[] keys, int[] values) {
+ public static IntFloatHashMap from(int[] keys, float[] values) {
if (keys.length != values.length) {
throw new IllegalArgumentException(
"Arrays of keys and values must have an identical length.");
}
- IntIntHashMap map = new IntIntHashMap(keys.length);
+ IntFloatHashMap map = new IntFloatHashMap(keys.length);
for (int i = 0; i < keys.length; i++) {
map.put(keys[i], values[i]);
}
@@ -686,17 +698,19 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
* factors.
*/
protected double verifyLoadFactor(double loadFactor) {
- checkLoadFactor(loadFactor, MIN_LOAD_FACTOR, MAX_LOAD_FACTOR);
+ HashContainers.checkLoadFactor(
+ loadFactor, HashContainers.MIN_LOAD_FACTOR, HashContainers.MAX_LOAD_FACTOR);
return loadFactor;
}
/** Rehash from old buffers to new buffers. */
- protected void rehash(int[] fromKeys, int[] fromValues) {
- assert fromKeys.length == fromValues.length && checkPowerOfTwo(fromKeys.length - 1);
+ protected void rehash(int[] fromKeys, float[] fromValues) {
+ assert fromKeys.length == fromValues.length
+ && HashContainers.checkPowerOfTwo(fromKeys.length - 1);
// Rehash all stored key/value pairs into the new buffers.
final int[] keys = this.keys;
- final int[] values = this.values;
+ final float[] values = this.values;
final int mask = this.mask;
int existing;
@@ -725,11 +739,11 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
// Ensure no change is done if we hit an OOM.
int[] prevKeys = this.keys;
- int[] prevValues = this.values;
+ float[] prevValues = this.values;
try {
int emptyElementSlot = 1;
this.keys = (new int[arraySize + emptyElementSlot]);
- this.values = (new int[arraySize + emptyElementSlot]);
+ this.values = (new float[arraySize + emptyElementSlot]);
} catch (OutOfMemoryError e) {
this.keys = prevKeys;
this.values = prevValues;
@@ -738,7 +752,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
e, this.mask + 1, arraySize);
}
- this.resizeAt = expandAtCount(arraySize, loadFactor);
+ this.resizeAt = HashContainers.expandAtCount(arraySize, loadFactor);
this.mask = arraySize - 1;
}
@@ -750,13 +764,13 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
* assign the pending element to the previous buffer (possibly violating the invariant of having
* at least one empty slot) and rehash all keys, substituting new buffers at the end.
*/
- protected void allocateThenInsertThenRehash(int slot, int pendingKey, int pendingValue) {
+ protected void allocateThenInsertThenRehash(int slot, int pendingKey, float pendingValue) {
assert assigned == resizeAt && ((keys[slot]) == 0) && !((pendingKey) == 0);
// Try to allocate new buffers first. If we OOM, we leave in a consistent state.
final int[] prevKeys = this.keys;
- final int[] prevValues = this.values;
- allocateBuffers(nextBufferSize(mask + 1, size(), loadFactor));
+ final float[] prevValues = this.values;
+ allocateBuffers(HashContainers.nextBufferSize(mask + 1, size(), loadFactor));
assert this.keys.length > prevKeys.length;
// We have succeeded at allocating new data so insert the pending key/value at
@@ -773,7 +787,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
*/
protected void shiftConflictingKeys(int gapSlot) {
final int[] keys = this.keys;
- final int[] values = this.values;
+ final float[] values = this.values;
final int mask = this.mask;
// Perform shifts of conflicting keys to fill in the gap.
@@ -806,10 +820,10 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
/** Forked from HPPC, holding int index,key and value */
- public final class IntIntCursor {
+ public static final class IntFloatCursor {
/**
- * The current key and value's index in the container this cursor belongs to. The meaning of
- * this index is defined by the container (usually it will be an index in the underlying storage
+ * The current key and value's index in the container this cursor beints to. The meaning of this
+ * index is defined by the container (usually it will be an index in the underlying storage
* buffer).
*/
public int index;
@@ -818,7 +832,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
public int key;
/** The current value. */
- public int value;
+ public float value;
@Override
public String toString() {
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/IntHashSet.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/IntHashSet.java
similarity index 99%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/IntHashSet.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/IntHashSet.java
index 2b2213a9242..82f3299f31e 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/IntHashSet.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/IntHashSet.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
-import static org.apache.lucene.util.hppc.HashContainers.*;
+import static org.apache.lucene.internal.hppc.HashContainers.*;
import java.util.Arrays;
import java.util.Collection;
@@ -31,7 +31,9 @@ import org.apache.lucene.util.RamUsageEstimator;
*
* <p>Mostly forked and trimmed from com.carrotsearch.hppc.IntHashSet
*
- * <p>github: https://github.com/carrotsearch/hppc release 0.9.0
+ * <p>github: https://github.com/carrotsearch/hppc release 0.10.0
+ *
+ * @lucene.internal
*/
public class IntHashSet implements Iterable<IntCursor>, Accountable, Cloneable {
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/IntIntHashMap.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/IntIntHashMap.java
similarity index 98%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/IntIntHashMap.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/IntIntHashMap.java
index bb9488ce9d5..70a19bb2d84 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/IntIntHashMap.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/IntIntHashMap.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
-import static org.apache.lucene.util.hppc.HashContainers.*;
+import static org.apache.lucene.internal.hppc.HashContainers.*;
import java.util.Arrays;
import java.util.Iterator;
@@ -30,7 +30,9 @@ import org.apache.lucene.util.RamUsageEstimator;
*
* <p>Mostly forked and trimmed from com.carrotsearch.hppc.IntIntHashMap
*
- * <p>github: https://github.com/carrotsearch/hppc release 0.9.0
+ * <p>github: https://github.com/carrotsearch/hppc release 0.10.0
+ *
+ * @lucene.internal
*/
public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Accountable, Cloneable {
@@ -310,7 +312,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
public boolean indexExists(int index) {
- assert index < 0 || (index >= 0 && index <= mask) || (index == mask + 1 && hasEmptyKey);
+ assert index < 0 || index <= mask || (index == mask + 1 && hasEmptyKey);
return index >= 0;
}
@@ -806,7 +808,7 @@ public class IntIntHashMap implements Iterable<IntIntHashMap.IntIntCursor>, Acco
}
/** Forked from HPPC, holding int index,key and value */
- public final class IntIntCursor {
+ public static final class IntIntCursor {
/**
* The current key and value's index in the container this cursor belongs to. The meaning of
* this index is defined by the container (usually it will be an index in the underlying storage
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/IntObjectHashMap.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/IntObjectHashMap.java
similarity index 98%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/IntObjectHashMap.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/IntObjectHashMap.java
index b493312115f..180bb3249f3 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/IntObjectHashMap.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/IntObjectHashMap.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
-import static org.apache.lucene.util.hppc.HashContainers.*;
+import static org.apache.lucene.internal.hppc.HashContainers.*;
import java.util.Arrays;
import java.util.Iterator;
@@ -30,7 +30,9 @@ import org.apache.lucene.util.RamUsageEstimator;
*
* <p>Mostly forked and trimmed from com.carrotsearch.hppc.IntObjectHashMap
*
- * <p>github: https://github.com/carrotsearch/hppc release 0.9.0
+ * <p>github: https://github.com/carrotsearch/hppc release 0.10.0
+ *
+ * @lucene.internal
*/
@SuppressWarnings("unchecked")
public class IntObjectHashMap<VType>
@@ -278,7 +280,7 @@ public class IntObjectHashMap<VType>
}
public boolean indexExists(int index) {
- assert index < 0 || (index >= 0 && index <= mask) || (index == mask + 1 && hasEmptyKey);
+ assert index < 0 || index <= mask || (index == mask + 1 && hasEmptyKey);
return index >= 0;
}
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/LongArrayList.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/LongArrayList.java
similarity index 96%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/LongArrayList.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/LongArrayList.java
index a3503944bdd..dcc37c1a527 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/LongArrayList.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/LongArrayList.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
-import static org.apache.lucene.util.hppc.HashContainers.DEFAULT_EXPECTED_ELEMENTS;
+import static org.apache.lucene.internal.hppc.HashContainers.DEFAULT_EXPECTED_ELEMENTS;
import java.util.Arrays;
import java.util.Iterator;
@@ -31,7 +31,9 @@ import org.apache.lucene.util.RamUsageEstimator;
*
* <p>Mostly forked and trimmed from com.carrotsearch.hppc.LongArrayList
*
- * <p>github: https://github.com/carrotsearch/hppc release 0.9.0
+ * <p>github: https://github.com/carrotsearch/hppc release 0.10.0
+ *
+ * @lucene.internal
*/
public class LongArrayList implements Iterable<LongCursor>, Cloneable, Accountable {
private static final long BASE_RAM_BYTES_USED =
@@ -40,13 +42,11 @@ public class LongArrayList implements Iterable<LongCursor>, Cloneable, Accountab
/** An immutable empty buffer (array). */
public static final long[] EMPTY_ARRAY = new long[0];
- ;
-
/**
* Internal array for storing the list. The array may be larger than the current size ({@link
* #size()}).
*/
- public long[] buffer = EMPTY_ARRAY;
+ public long[] buffer;
/** Current number of elements stored in {@link #buffer}. */
public int elementsCount;
@@ -262,8 +262,7 @@ public class LongArrayList implements Iterable<LongCursor>, Cloneable, Accountab
* @param expectedElements The total number of elements, inclusive.
*/
public void ensureCapacity(int expectedElements) {
- final int bufferLen = (buffer == null ? 0 : buffer.length);
- if (expectedElements > bufferLen) {
+ if (expectedElements > buffer.length) {
ensureBufferSpace(expectedElements - size());
}
}
@@ -273,8 +272,7 @@ public class LongArrayList implements Iterable<LongCursor>, Cloneable, Accountab
* Increases internal buffer size if needed.
*/
protected void ensureBufferSpace(int expectedAdditions) {
- final int bufferLen = (buffer == null ? 0 : buffer.length);
- if (elementsCount + expectedAdditions > bufferLen) {
+ if (elementsCount + expectedAdditions > buffer.length) {
this.buffer = ArrayUtil.grow(buffer, elementsCount + expectedAdditions);
}
}
@@ -315,7 +313,7 @@ public class LongArrayList implements Iterable<LongCursor>, Cloneable, Accountab
* #elementsCount} field to zero.
*/
public void clear() {
- Arrays.fill(buffer, 0, elementsCount, 0);
+ Arrays.fill(buffer, 0, elementsCount, 0L);
this.elementsCount = 0;
}
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/LongCursor.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/LongCursor.java
similarity index 90%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/LongCursor.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/LongCursor.java
index 2a424254306..73ebb60f0ff 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/LongCursor.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/LongCursor.java
@@ -15,9 +15,13 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
-/** Forked from HPPC, holding int index and long value */
+/**
+ * Forked from HPPC, holding int index and long value.
+ *
+ * @lucene.internal
+ */
public final class LongCursor {
/**
* The current value's index in the container this cursor belongs to. The meaning of this index is
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/LongIntHashMap.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/LongFloatHashMap.java
similarity index 82%
copy from lucene/core/src/java/org/apache/lucene/util/hppc/LongIntHashMap.java
copy to lucene/core/src/java/org/apache/lucene/internal/hppc/LongFloatHashMap.java
index 5240beeeced..bdc77c8a8dd 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/LongIntHashMap.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/LongFloatHashMap.java
@@ -15,9 +15,19 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
-
-import static org.apache.lucene.util.hppc.HashContainers.*;
+package org.apache.lucene.internal.hppc;
+
+import static org.apache.lucene.internal.hppc.HashContainers.DEFAULT_EXPECTED_ELEMENTS;
+import static org.apache.lucene.internal.hppc.HashContainers.DEFAULT_LOAD_FACTOR;
+import static org.apache.lucene.internal.hppc.HashContainers.ITERATION_SEED;
+import static org.apache.lucene.internal.hppc.HashContainers.MAX_LOAD_FACTOR;
+import static org.apache.lucene.internal.hppc.HashContainers.MIN_LOAD_FACTOR;
+import static org.apache.lucene.internal.hppc.HashContainers.checkLoadFactor;
+import static org.apache.lucene.internal.hppc.HashContainers.checkPowerOfTwo;
+import static org.apache.lucene.internal.hppc.HashContainers.expandAtCount;
+import static org.apache.lucene.internal.hppc.HashContainers.iterationIncrement;
+import static org.apache.lucene.internal.hppc.HashContainers.minBufferSize;
+import static org.apache.lucene.internal.hppc.HashContainers.nextBufferSize;
import java.util.Arrays;
import java.util.Iterator;
@@ -25,24 +35,26 @@ import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.RamUsageEstimator;
/**
- * A hash map of <code>long</code> to <code>int</code>, implemented using open addressing with
+ * A hash map of <code>long</code> to <code>float</code>, implemented using open addressing with
* linear probing for collision resolution.
*
- * <p>Mostly forked and trimmed from com.carrotsearch.hppc.LongIntHashMap
+ * <p>Mostly forked and trimmed from com.carrotsearch.hppc.LongFloatHashMap
+ *
+ * <p>github: https://github.com/carrotsearch/hppc release 0.10.0
*
- * <p>github: https://github.com/carrotsearch/hppc release 0.9.0
+ * @lucene.internal
*/
-public class LongIntHashMap
- implements Iterable<LongIntHashMap.LongIntCursor>, Accountable, Cloneable {
+public class LongFloatHashMap
+ implements Iterable<LongFloatHashMap.LongFloatCursor>, Accountable, Cloneable {
private static final long BASE_RAM_BYTES_USED =
- RamUsageEstimator.shallowSizeOfInstance(LongIntHashMap.class);
+ RamUsageEstimator.shallowSizeOfInstance(LongFloatHashMap.class);
/** The array holding keys. */
public long[] keys;
/** The array holding values. */
- public int[] values;
+ public float[] values;
/**
* The number of stored keys (assigned key slots), excluding the special "empty" key, if any (use
@@ -68,7 +80,7 @@ public class LongIntHashMap
protected int iterationSeed;
/** New instance with sane defaults. */
- public LongIntHashMap() {
+ public LongFloatHashMap() {
this(DEFAULT_EXPECTED_ELEMENTS);
}
@@ -78,7 +90,7 @@ public class LongIntHashMap
* @param expectedElements The expected number of elements guaranteed not to cause buffer
* expansion (inclusive).
*/
- public LongIntHashMap(int expectedElements) {
+ public LongFloatHashMap(int expectedElements) {
this(expectedElements, DEFAULT_LOAD_FACTOR);
}
@@ -90,24 +102,24 @@ public class LongIntHashMap
* @param loadFactor The load factor for internal buffers. Insane load factors (zero, full
* capacity) are rejected by {@link #verifyLoadFactor(double)}.
*/
- public LongIntHashMap(int expectedElements, double loadFactor) {
+ public LongFloatHashMap(int expectedElements, double loadFactor) {
this.loadFactor = verifyLoadFactor(loadFactor);
iterationSeed = ITERATION_SEED.incrementAndGet();
ensureCapacity(expectedElements);
}
/** Create a hash map from all key-value pairs of another map. */
- public LongIntHashMap(LongIntHashMap map) {
+ public LongFloatHashMap(LongFloatHashMap map) {
this(map.size());
putAll(map);
}
- public int put(long key, int value) {
+ public float put(long key, float value) {
assert assigned < mask + 1;
final int mask = this.mask;
if (((key) == 0)) {
- int previousValue = hasEmptyKey ? values[mask + 1] : 0;
+ float previousValue = hasEmptyKey ? values[mask + 1] : 0;
hasEmptyKey = true;
values[mask + 1] = value;
return previousValue;
@@ -118,7 +130,7 @@ public class LongIntHashMap
long existing;
while (!((existing = keys[slot]) == 0)) {
if (((existing) == (key))) {
- final int previousValue = values[slot];
+ final float previousValue = values[slot];
values[slot] = value;
return previousValue;
}
@@ -137,9 +149,9 @@ public class LongIntHashMap
}
}
- public int putAll(Iterable<? extends LongIntCursor> iterable) {
+ public int putAll(Iterable<? extends LongFloatCursor> iterable) {
final int count = size();
- for (LongIntCursor c : iterable) {
+ for (LongFloatCursor c : iterable) {
put(c.key, c.value);
}
return size() - count;
@@ -158,7 +170,7 @@ public class LongIntHashMap
* @return <code>true</code> if <code>key</code> did not exist and <code>value</code> was placed
* in the map.
*/
- public boolean putIfAbsent(long key, int value) {
+ public boolean putIfAbsent(long key, float value) {
int keyIndex = indexOf(key);
if (!indexExists(keyIndex)) {
indexInsert(keyIndex, key, value);
@@ -177,7 +189,7 @@ public class LongIntHashMap
* @param incrementValue The value to add to the existing value if <code>key</code> exists.
* @return Returns the current value associated with <code>key</code> (after changes).
*/
- public int putOrAdd(long key, int putValue, int incrementValue) {
+ public float putOrAdd(long key, float putValue, float incrementValue) {
assert assigned < mask + 1;
int keyIndex = indexOf(key);
@@ -198,18 +210,18 @@ public class LongIntHashMap
* @param incrementValue The value to put or add to the existing value if <code>key</code> exists.
* @return Returns the current value associated with <code>key</code> (after changes).
*/
- public int addTo(long key, int incrementValue) {
+ public float addTo(long key, float incrementValue) {
return putOrAdd(key, incrementValue, incrementValue);
}
- public int remove(long key) {
+ public float remove(long key) {
final int mask = this.mask;
if (((key) == 0)) {
if (!hasEmptyKey) {
return 0;
}
hasEmptyKey = false;
- int previousValue = values[mask + 1];
+ float previousValue = values[mask + 1];
values[mask + 1] = 0;
return previousValue;
} else {
@@ -219,7 +231,7 @@ public class LongIntHashMap
long existing;
while (!((existing = keys[slot]) == 0)) {
if (((existing) == (key))) {
- final int previousValue = values[slot];
+ final float previousValue = values[slot];
shiftConflictingKeys(slot);
return previousValue;
}
@@ -230,7 +242,7 @@ public class LongIntHashMap
}
}
- public int get(long key) {
+ public float get(long key) {
if (((key) == 0)) {
return hasEmptyKey ? values[mask + 1] : 0;
} else {
@@ -250,7 +262,7 @@ public class LongIntHashMap
}
}
- public int getOrDefault(long key, int defaultValue) {
+ public float getOrDefault(long key, float defaultValue) {
if (((key) == 0)) {
return hasEmptyKey ? values[mask + 1] : defaultValue;
} else {
@@ -311,28 +323,28 @@ public class LongIntHashMap
}
public boolean indexExists(int index) {
- assert index < 0 || (index >= 0 && index <= mask) || (index == mask + 1 && hasEmptyKey);
+ assert index < 0 || index <= mask || (index == mask + 1 && hasEmptyKey);
return index >= 0;
}
- public int indexGet(int index) {
+ public float indexGet(int index) {
assert index >= 0 : "The index must point at an existing key.";
assert index <= mask || (index == mask + 1 && hasEmptyKey);
return values[index];
}
- public int indexReplace(int index, int newValue) {
+ public float indexReplace(int index, float newValue) {
assert index >= 0 : "The index must point at an existing key.";
assert index <= mask || (index == mask + 1 && hasEmptyKey);
- int previousValue = values[index];
+ float previousValue = values[index];
values[index] = newValue;
return previousValue;
}
- public void indexInsert(int index, long key, int value) {
+ public void indexInsert(int index, long key, float value) {
assert index < 0 : "The index must not point at an existing key.";
index = ~index;
@@ -354,11 +366,11 @@ public class LongIntHashMap
}
}
- public int indexRemove(int index) {
+ public float indexRemove(int index) {
assert index >= 0 : "The index must point at an existing key.";
assert index <= mask || (index == mask + 1 && hasEmptyKey);
- int previousValue = values[index];
+ float previousValue = values[index];
if (index > mask) {
assert index == mask + 1;
hasEmptyKey = false;
@@ -373,7 +385,7 @@ public class LongIntHashMap
assigned = 0;
hasEmptyKey = false;
- Arrays.fill(keys, 0);
+ Arrays.fill(keys, 0L);
/* */
}
@@ -398,7 +410,7 @@ public class LongIntHashMap
@Override
public int hashCode() {
int h = hasEmptyKey ? 0xDEADBEEF : 0;
- for (LongIntCursor c : this) {
+ for (LongFloatCursor c : this) {
h += BitMixer.mix(c.key) + BitMixer.mix(c.value);
}
return h;
@@ -411,14 +423,14 @@ public class LongIntHashMap
}
/** Return true if all keys of some other container exist in this container. */
- protected boolean equalElements(LongIntHashMap other) {
+ protected boolean equalElements(LongFloatHashMap other) {
if (other.size() != size()) {
return false;
}
- for (LongIntCursor c : other) {
+ for (LongFloatCursor c : other) {
long key = c.key;
- if (!containsKey(key) || !((get(key)) == (c.value))) {
+ if (!containsKey(key) || !(Float.floatToIntBits(c.value) == Float.floatToIntBits(get(key)))) {
return false;
}
}
@@ -435,7 +447,7 @@ public class LongIntHashMap
public void ensureCapacity(int expectedElements) {
if (expectedElements > resizeAt || keys == null) {
final long[] prevKeys = this.keys;
- final int[] prevValues = this.values;
+ final float[] prevValues = this.values;
allocateBuffers(minBufferSize(expectedElements, loadFactor));
if (prevKeys != null && !isEmpty()) {
rehash(prevKeys, prevValues);
@@ -458,22 +470,22 @@ public class LongIntHashMap
}
/** An iterator implementation for {@link #iterator}. */
- private final class EntryIterator extends AbstractIterator<LongIntCursor> {
- private final LongIntCursor cursor;
+ private final class EntryIterator extends AbstractIterator<LongFloatCursor> {
+ private final LongFloatCursor cursor;
private final int increment;
private int index;
private int slot;
public EntryIterator() {
- cursor = new LongIntCursor();
+ cursor = new LongFloatCursor();
int seed = nextIterationSeed();
increment = iterationIncrement(seed);
slot = seed & mask;
}
@Override
- protected LongIntCursor fetch() {
- final int mask = LongIntHashMap.this.mask;
+ protected LongFloatCursor fetch() {
+ final int mask = LongFloatHashMap.this.mask;
while (index <= mask) {
long existing;
index++;
@@ -498,7 +510,7 @@ public class LongIntHashMap
}
@Override
- public Iterator<LongIntCursor> iterator() {
+ public Iterator<LongFloatCursor> iterator() {
return new EntryIterator();
}
@@ -516,7 +528,7 @@ public class LongIntHashMap
}
public int size() {
- return LongIntHashMap.this.size();
+ return LongFloatHashMap.this.size();
}
public long[] toArray() {
@@ -545,7 +557,7 @@ public class LongIntHashMap
@Override
protected LongCursor fetch() {
- final int mask = LongIntHashMap.this.mask;
+ final int mask = LongFloatHashMap.this.mask;
while (index <= mask) {
long existing;
index++;
@@ -575,21 +587,21 @@ public class LongIntHashMap
}
/** A view over the set of values of this map. */
- public final class ValuesContainer implements Iterable<IntCursor> {
+ public final class ValuesContainer implements Iterable<FloatCursor> {
@Override
- public Iterator<IntCursor> iterator() {
+ public Iterator<FloatCursor> iterator() {
return new ValuesIterator();
}
public int size() {
- return LongIntHashMap.this.size();
+ return LongFloatHashMap.this.size();
}
- public int[] toArray() {
- int[] array = new int[size()];
+ public float[] toArray() {
+ float[] array = new float[size()];
int i = 0;
- for (IntCursor cursor : this) {
+ for (FloatCursor cursor : this) {
array[i++] = cursor.value;
}
return array;
@@ -597,22 +609,22 @@ public class LongIntHashMap
}
/** An iterator over the set of assigned values. */
- private final class ValuesIterator extends AbstractIterator<IntCursor> {
- private final IntCursor cursor;
+ private final class ValuesIterator extends AbstractIterator<FloatCursor> {
+ private final FloatCursor cursor;
private final int increment;
private int index;
private int slot;
public ValuesIterator() {
- cursor = new IntCursor();
+ cursor = new FloatCursor();
int seed = nextIterationSeed();
increment = iterationIncrement(seed);
slot = seed & mask;
}
@Override
- protected IntCursor fetch() {
- final int mask = LongIntHashMap.this.mask;
+ protected FloatCursor fetch() {
+ final int mask = LongFloatHashMap.this.mask;
while (index <= mask) {
index++;
slot = (slot + increment) & mask;
@@ -634,10 +646,10 @@ public class LongIntHashMap
}
@Override
- public LongIntHashMap clone() {
+ public LongFloatHashMap clone() {
try {
/* */
- LongIntHashMap cloned = (LongIntHashMap) super.clone();
+ LongFloatHashMap cloned = (LongFloatHashMap) super.clone();
cloned.keys = keys.clone();
cloned.values = values.clone();
cloned.hasEmptyKey = hasEmptyKey;
@@ -655,7 +667,7 @@ public class LongIntHashMap
buffer.append("[");
boolean first = true;
- for (LongIntCursor cursor : this) {
+ for (LongFloatCursor cursor : this) {
if (!first) {
buffer.append(", ");
}
@@ -669,13 +681,13 @@ public class LongIntHashMap
}
/** Creates a hash map from two index-aligned arrays of key-value pairs. */
- public static LongIntHashMap from(long[] keys, int[] values) {
+ public static LongFloatHashMap from(long[] keys, float[] values) {
if (keys.length != values.length) {
throw new IllegalArgumentException(
"Arrays of keys and values must have an identical length.");
}
- LongIntHashMap map = new LongIntHashMap(keys.length);
+ LongFloatHashMap map = new LongFloatHashMap(keys.length);
for (int i = 0; i < keys.length; i++) {
map.put(keys[i], values[i]);
}
@@ -703,12 +715,12 @@ public class LongIntHashMap
}
/** Rehash from old buffers to new buffers. */
- protected void rehash(long[] fromKeys, int[] fromValues) {
+ protected void rehash(long[] fromKeys, float[] fromValues) {
assert fromKeys.length == fromValues.length && checkPowerOfTwo(fromKeys.length - 1);
// Rehash all stored key/value pairs into the new buffers.
final long[] keys = this.keys;
- final int[] values = this.values;
+ final float[] values = this.values;
final int mask = this.mask;
long existing;
@@ -737,11 +749,11 @@ public class LongIntHashMap
// Ensure no change is done if we hit an OOM.
long[] prevKeys = this.keys;
- int[] prevValues = this.values;
+ float[] prevValues = this.values;
try {
int emptyElementSlot = 1;
this.keys = (new long[arraySize + emptyElementSlot]);
- this.values = (new int[arraySize + emptyElementSlot]);
+ this.values = (new float[arraySize + emptyElementSlot]);
} catch (OutOfMemoryError e) {
this.keys = prevKeys;
this.values = prevValues;
@@ -762,12 +774,12 @@ public class LongIntHashMap
* assign the pending element to the previous buffer (possibly violating the invariant of having
* at least one empty slot) and rehash all keys, substituting new buffers at the end.
*/
- protected void allocateThenInsertThenRehash(int slot, long pendingKey, int pendingValue) {
+ protected void allocateThenInsertThenRehash(int slot, long pendingKey, float pendingValue) {
assert assigned == resizeAt && ((keys[slot]) == 0) && !((pendingKey) == 0);
// Try to allocate new buffers first. If we OOM, we leave in a consistent state.
final long[] prevKeys = this.keys;
- final int[] prevValues = this.values;
+ final float[] prevValues = this.values;
allocateBuffers(nextBufferSize(mask + 1, size(), loadFactor));
assert this.keys.length > prevKeys.length;
@@ -785,7 +797,7 @@ public class LongIntHashMap
*/
protected void shiftConflictingKeys(int gapSlot) {
final long[] keys = this.keys;
- final int[] values = this.values;
+ final float[] values = this.values;
final int mask = this.mask;
// Perform shifts of conflicting keys to fill in the gap.
@@ -818,7 +830,7 @@ public class LongIntHashMap
}
/** Forked from HPPC, holding int index,key and value */
- public final class LongIntCursor {
+ public static final class LongFloatCursor {
/**
* The current key and value's index in the container this cursor belongs to. The meaning of
* this index is defined by the container (usually it will be an index in the underlying storage
@@ -830,7 +842,7 @@ public class LongIntHashMap
public long key;
/** The current value. */
- public int value;
+ public float value;
@Override
public String toString() {
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/LongHashSet.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/LongHashSet.java
similarity index 99%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/LongHashSet.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/LongHashSet.java
index 696c96083f5..744b334e34e 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/LongHashSet.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/LongHashSet.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
-import static org.apache.lucene.util.hppc.HashContainers.*;
+import static org.apache.lucene.internal.hppc.HashContainers.*;
import java.util.Arrays;
import java.util.Iterator;
@@ -30,7 +30,9 @@ import org.apache.lucene.util.RamUsageEstimator;
*
* <p>Mostly forked and trimmed from com.carrotsearch.hppc.LongHashSet
*
- * <p>github: https://github.com/carrotsearch/hppc release 0.9.0
+ * <p>github: https://github.com/carrotsearch/hppc release 0.10.0
+ *
+ * @lucene.internal
*/
public class LongHashSet implements Iterable<LongCursor>, Accountable, Cloneable {
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/LongIntHashMap.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/LongIntHashMap.java
similarity index 94%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/LongIntHashMap.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/LongIntHashMap.java
index 5240beeeced..d012e4101ad 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/LongIntHashMap.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/LongIntHashMap.java
@@ -15,9 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
-
-import static org.apache.lucene.util.hppc.HashContainers.*;
+package org.apache.lucene.internal.hppc;
import java.util.Arrays;
import java.util.Iterator;
@@ -30,7 +28,9 @@ import org.apache.lucene.util.RamUsageEstimator;
*
* <p>Mostly forked and trimmed from com.carrotsearch.hppc.LongIntHashMap
*
- * <p>github: https://github.com/carrotsearch/hppc release 0.9.0
+ * <p>github: https://github.com/carrotsearch/hppc release 0.10.0
+ *
+ * @lucene.internal
*/
public class LongIntHashMap
implements Iterable<LongIntHashMap.LongIntCursor>, Accountable, Cloneable {
@@ -69,7 +69,7 @@ public class LongIntHashMap
/** New instance with sane defaults. */
public LongIntHashMap() {
- this(DEFAULT_EXPECTED_ELEMENTS);
+ this(HashContainers.DEFAULT_EXPECTED_ELEMENTS);
}
/**
@@ -79,7 +79,7 @@ public class LongIntHashMap
* expansion (inclusive).
*/
public LongIntHashMap(int expectedElements) {
- this(expectedElements, DEFAULT_LOAD_FACTOR);
+ this(expectedElements, HashContainers.DEFAULT_LOAD_FACTOR);
}
/**
@@ -92,7 +92,7 @@ public class LongIntHashMap
*/
public LongIntHashMap(int expectedElements, double loadFactor) {
this.loadFactor = verifyLoadFactor(loadFactor);
- iterationSeed = ITERATION_SEED.incrementAndGet();
+ iterationSeed = HashContainers.ITERATION_SEED.incrementAndGet();
ensureCapacity(expectedElements);
}
@@ -311,7 +311,7 @@ public class LongIntHashMap
}
public boolean indexExists(int index) {
- assert index < 0 || (index >= 0 && index <= mask) || (index == mask + 1 && hasEmptyKey);
+ assert index < 0 || index <= mask || (index == mask + 1 && hasEmptyKey);
return index >= 0;
}
@@ -373,7 +373,7 @@ public class LongIntHashMap
assigned = 0;
hasEmptyKey = false;
- Arrays.fill(keys, 0);
+ Arrays.fill(keys, 0L);
/* */
}
@@ -384,7 +384,7 @@ public class LongIntHashMap
keys = null;
values = null;
- ensureCapacity(DEFAULT_EXPECTED_ELEMENTS);
+ ensureCapacity(HashContainers.DEFAULT_EXPECTED_ELEMENTS);
}
public int size() {
@@ -436,7 +436,7 @@ public class LongIntHashMap
if (expectedElements > resizeAt || keys == null) {
final long[] prevKeys = this.keys;
final int[] prevValues = this.values;
- allocateBuffers(minBufferSize(expectedElements, loadFactor));
+ allocateBuffers(HashContainers.minBufferSize(expectedElements, loadFactor));
if (prevKeys != null && !isEmpty()) {
rehash(prevKeys, prevValues);
}
@@ -467,7 +467,7 @@ public class LongIntHashMap
public EntryIterator() {
cursor = new LongIntCursor();
int seed = nextIterationSeed();
- increment = iterationIncrement(seed);
+ increment = HashContainers.iterationIncrement(seed);
slot = seed & mask;
}
@@ -539,7 +539,7 @@ public class LongIntHashMap
public KeysIterator() {
cursor = new LongCursor();
int seed = nextIterationSeed();
- increment = iterationIncrement(seed);
+ increment = HashContainers.iterationIncrement(seed);
slot = seed & mask;
}
@@ -606,7 +606,7 @@ public class LongIntHashMap
public ValuesIterator() {
cursor = new IntCursor();
int seed = nextIterationSeed();
- increment = iterationIncrement(seed);
+ increment = HashContainers.iterationIncrement(seed);
slot = seed & mask;
}
@@ -641,7 +641,7 @@ public class LongIntHashMap
cloned.keys = keys.clone();
cloned.values = values.clone();
cloned.hasEmptyKey = hasEmptyKey;
- cloned.iterationSeed = ITERATION_SEED.incrementAndGet();
+ cloned.iterationSeed = HashContainers.ITERATION_SEED.incrementAndGet();
return cloned;
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
@@ -698,13 +698,15 @@ public class LongIntHashMap
* factors.
*/
protected double verifyLoadFactor(double loadFactor) {
- checkLoadFactor(loadFactor, MIN_LOAD_FACTOR, MAX_LOAD_FACTOR);
+ HashContainers.checkLoadFactor(
+ loadFactor, HashContainers.MIN_LOAD_FACTOR, HashContainers.MAX_LOAD_FACTOR);
return loadFactor;
}
/** Rehash from old buffers to new buffers. */
protected void rehash(long[] fromKeys, int[] fromValues) {
- assert fromKeys.length == fromValues.length && checkPowerOfTwo(fromKeys.length - 1);
+ assert fromKeys.length == fromValues.length
+ && HashContainers.checkPowerOfTwo(fromKeys.length - 1);
// Rehash all stored key/value pairs into the new buffers.
final long[] keys = this.keys;
@@ -750,7 +752,7 @@ public class LongIntHashMap
e, this.mask + 1, arraySize);
}
- this.resizeAt = expandAtCount(arraySize, loadFactor);
+ this.resizeAt = HashContainers.expandAtCount(arraySize, loadFactor);
this.mask = arraySize - 1;
}
@@ -768,7 +770,7 @@ public class LongIntHashMap
// Try to allocate new buffers first. If we OOM, we leave in a consistent state.
final long[] prevKeys = this.keys;
final int[] prevValues = this.values;
- allocateBuffers(nextBufferSize(mask + 1, size(), loadFactor));
+ allocateBuffers(HashContainers.nextBufferSize(mask + 1, size(), loadFactor));
assert this.keys.length > prevKeys.length;
// We have succeeded at allocating new data so insert the pending key/value at
@@ -818,7 +820,7 @@ public class LongIntHashMap
}
/** Forked from HPPC, holding int index,key and value */
- public final class LongIntCursor {
+ public static final class LongIntCursor {
/**
* The current key and value's index in the container this cursor belongs to. The meaning of
* this index is defined by the container (usually it will be an index in the underlying storage
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/LongObjectHashMap.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/LongObjectHashMap.java
similarity index 98%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/LongObjectHashMap.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/LongObjectHashMap.java
index ae6c111789b..4bc890b80b1 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/LongObjectHashMap.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/LongObjectHashMap.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
-import static org.apache.lucene.util.hppc.HashContainers.*;
+import static org.apache.lucene.internal.hppc.HashContainers.*;
import java.util.Arrays;
import java.util.Iterator;
@@ -30,7 +30,9 @@ import org.apache.lucene.util.RamUsageEstimator;
*
* <p>Mostly forked and trimmed from com.carrotsearch.hppc.LongObjectHashMap
*
- * <p>github: https://github.com/carrotsearch/hppc release 0.9.0
+ * <p>github: https://github.com/carrotsearch/hppc release 0.10.0
+ *
+ * @lucene.internal
*/
@SuppressWarnings("unchecked")
public class LongObjectHashMap<VType>
@@ -278,7 +280,7 @@ public class LongObjectHashMap<VType>
}
public boolean indexExists(int index) {
- assert index < 0 || (index >= 0 && index <= mask) || (index == mask + 1 && hasEmptyKey);
+ assert index < 0 || index <= mask || (index == mask + 1 && hasEmptyKey);
return index >= 0;
}
@@ -340,7 +342,7 @@ public class LongObjectHashMap<VType>
assigned = 0;
hasEmptyKey = false;
- Arrays.fill(keys, 0);
+ Arrays.fill(keys, 0L);
/* */
}
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/ObjectCursor.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/ObjectCursor.java
similarity index 90%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/ObjectCursor.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/ObjectCursor.java
index 45d0cb56b62..873bca13fc7 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/ObjectCursor.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/ObjectCursor.java
@@ -15,9 +15,13 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
-/** Forked from HPPC, holding int index and Object value */
+/**
+ * Forked from HPPC, holding int index and Object value.
+ *
+ * @lucene.internal
+ */
public final class ObjectCursor<VType> {
/**
* The current value's index in the container this cursor belongs to. The meaning of this index is
diff --git a/lucene/core/src/java/org/apache/lucene/util/hppc/package-info.java b/lucene/core/src/java/org/apache/lucene/internal/hppc/package-info.java
similarity index 82%
rename from lucene/core/src/java/org/apache/lucene/util/hppc/package-info.java
rename to lucene/core/src/java/org/apache/lucene/internal/hppc/package-info.java
index 6f395a68a48..c739206da9a 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hppc/package-info.java
+++ b/lucene/core/src/java/org/apache/lucene/internal/hppc/package-info.java
@@ -15,5 +15,8 @@
* limitations under the License.
*/
-/** package holding hppc related classes. */
-package org.apache.lucene.util.hppc;
+/**
+ * Internal copy of a subset of classes from the <a
+ * href="https://github.com/carrotsearch/hppc/">HPPC</a> library.
+ */
+package org.apache.lucene.internal.hppc;
diff --git a/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java b/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java
index 8ad2f5afb18..315b94a2acd 100644
--- a/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java
@@ -33,12 +33,12 @@ import org.apache.lucene.index.TermState;
import org.apache.lucene.index.TermStates;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.internal.hppc.IntArrayList;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.search.similarities.Similarity.SimScorer;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.PriorityQueue;
-import org.apache.lucene.util.hppc.IntArrayList;
/**
* A generalized version of {@link PhraseQuery}, with the possibility of adding more than one term
diff --git a/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java b/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java
index 5c771aba2cf..c5a5ee36fd4 100644
--- a/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/PhraseQuery.java
@@ -33,11 +33,11 @@ import org.apache.lucene.index.TermState;
import org.apache.lucene.index.TermStates;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.internal.hppc.IntArrayList;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.search.similarities.Similarity.SimScorer;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.hppc.IntArrayList;
/**
* A Query that matches documents containing a particular sequence of terms. A PhraseQuery is built
diff --git a/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseMatcher.java b/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseMatcher.java
index 93139fbb9a8..46cb7c90148 100644
--- a/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseMatcher.java
+++ b/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseMatcher.java
@@ -30,9 +30,9 @@ import org.apache.lucene.index.Impact;
import org.apache.lucene.index.Impacts;
import org.apache.lucene.index.ImpactsSource;
import org.apache.lucene.index.Term;
+import org.apache.lucene.internal.hppc.IntHashSet;
import org.apache.lucene.search.similarities.Similarity.SimScorer;
import org.apache.lucene.util.FixedBitSet;
-import org.apache.lucene.util.hppc.IntHashSet;
/**
* Find all slop-valid position-combinations (matches) encountered while traversing/hopping the
diff --git a/lucene/core/src/java/org/apache/lucene/util/automaton/Automaton.java b/lucene/core/src/java/org/apache/lucene/util/automaton/Automaton.java
index 192b33d304f..91702ecc96c 100644
--- a/lucene/core/src/java/org/apache/lucene/util/automaton/Automaton.java
+++ b/lucene/core/src/java/org/apache/lucene/util/automaton/Automaton.java
@@ -19,12 +19,12 @@ package org.apache.lucene.util.automaton;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Objects;
+import org.apache.lucene.internal.hppc.IntHashSet;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.InPlaceMergeSorter;
import org.apache.lucene.util.RamUsageEstimator;
import org.apache.lucene.util.Sorter;
-import org.apache.lucene.util.hppc.IntHashSet;
// TODO
// - could use packed int arrays instead
diff --git a/lucene/core/src/java/org/apache/lucene/util/automaton/CompiledAutomaton.java b/lucene/core/src/java/org/apache/lucene/util/automaton/CompiledAutomaton.java
index 83d937809b1..cfc8abebe0c 100644
--- a/lucene/core/src/java/org/apache/lucene/util/automaton/CompiledAutomaton.java
+++ b/lucene/core/src/java/org/apache/lucene/util/automaton/CompiledAutomaton.java
@@ -21,6 +21,7 @@ import org.apache.lucene.index.SingleTermsEnum;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.internal.hppc.IntArrayList;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryVisitor;
import org.apache.lucene.util.Accountable;
@@ -30,7 +31,6 @@ import org.apache.lucene.util.IntsRef;
import org.apache.lucene.util.RamUsageEstimator;
import org.apache.lucene.util.StringHelper;
import org.apache.lucene.util.UnicodeUtil;
-import org.apache.lucene.util.hppc.IntArrayList;
/**
* Immutable class holding compiled details for a given Automaton. The Automaton is deterministic,
diff --git a/lucene/core/src/java/org/apache/lucene/util/automaton/LevenshteinAutomata.java b/lucene/core/src/java/org/apache/lucene/util/automaton/LevenshteinAutomata.java
index b59bb80e8c5..2a5ba487945 100644
--- a/lucene/core/src/java/org/apache/lucene/util/automaton/LevenshteinAutomata.java
+++ b/lucene/core/src/java/org/apache/lucene/util/automaton/LevenshteinAutomata.java
@@ -17,8 +17,8 @@
package org.apache.lucene.util.automaton;
import java.util.Arrays;
+import org.apache.lucene.internal.hppc.IntHashSet;
import org.apache.lucene.util.UnicodeUtil;
-import org.apache.lucene.util.hppc.IntHashSet;
/**
* Class to construct DFAs that match a word within some edit distance.
diff --git a/lucene/core/src/java/org/apache/lucene/util/automaton/Operations.java b/lucene/core/src/java/org/apache/lucene/util/automaton/Operations.java
index 23c79951373..e238857f3a9 100644
--- a/lucene/core/src/java/org/apache/lucene/util/automaton/Operations.java
+++ b/lucene/core/src/java/org/apache/lucene/util/automaton/Operations.java
@@ -39,6 +39,10 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.apache.lucene.internal.hppc.BitMixer;
+import org.apache.lucene.internal.hppc.IntCursor;
+import org.apache.lucene.internal.hppc.IntHashSet;
+import org.apache.lucene.internal.hppc.IntObjectHashMap;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.BytesRef;
@@ -47,10 +51,6 @@ import org.apache.lucene.util.FixedBitSet;
import org.apache.lucene.util.IntsRef;
import org.apache.lucene.util.IntsRefBuilder;
import org.apache.lucene.util.RamUsageEstimator;
-import org.apache.lucene.util.hppc.BitMixer;
-import org.apache.lucene.util.hppc.IntCursor;
-import org.apache.lucene.util.hppc.IntHashSet;
-import org.apache.lucene.util.hppc.IntObjectHashMap;
/**
* Automata operations.
diff --git a/lucene/core/src/java/org/apache/lucene/util/automaton/StateSet.java b/lucene/core/src/java/org/apache/lucene/util/automaton/StateSet.java
index aea79177fab..1a7a0f4cdc1 100644
--- a/lucene/core/src/java/org/apache/lucene/util/automaton/StateSet.java
+++ b/lucene/core/src/java/org/apache/lucene/util/automaton/StateSet.java
@@ -18,9 +18,9 @@
package org.apache.lucene.util.automaton;
import java.util.Arrays;
-import org.apache.lucene.util.hppc.BitMixer;
-import org.apache.lucene.util.hppc.IntCursor;
-import org.apache.lucene.util.hppc.IntIntHashMap;
+import org.apache.lucene.internal.hppc.BitMixer;
+import org.apache.lucene.internal.hppc.IntCursor;
+import org.apache.lucene.internal.hppc.IntIntHashMap;
/**
* A thin wrapper of {@link IntIntHashMap} Maps from state in integer representation to its
diff --git a/lucene/core/src/java/org/apache/lucene/util/automaton/UTF32ToUTF8.java b/lucene/core/src/java/org/apache/lucene/util/automaton/UTF32ToUTF8.java
index a1734cbad3c..99648a618a3 100644
--- a/lucene/core/src/java/org/apache/lucene/util/automaton/UTF32ToUTF8.java
+++ b/lucene/core/src/java/org/apache/lucene/util/automaton/UTF32ToUTF8.java
@@ -17,7 +17,7 @@
package org.apache.lucene.util.automaton;
import java.util.Arrays;
-import org.apache.lucene.util.hppc.IntArrayList;
+import org.apache.lucene.internal.hppc.IntArrayList;
// TODO
// - do we really need the .bits...? if not we can make util in UnicodeUtil to convert 1 char
diff --git a/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java b/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java
index a65ba9164b8..4e6cc40eb87 100644
--- a/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java
@@ -28,6 +28,7 @@ import org.apache.lucene.index.MergeState;
import org.apache.lucene.index.PointValues;
import org.apache.lucene.index.PointValues.IntersectVisitor;
import org.apache.lucene.index.PointValues.Relation;
+import org.apache.lucene.internal.hppc.LongArrayList;
import org.apache.lucene.store.ByteBuffersDataOutput;
import org.apache.lucene.store.ChecksumIndexInput;
import org.apache.lucene.store.DataOutput;
@@ -45,7 +46,6 @@ import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.NumericUtils;
import org.apache.lucene.util.PriorityQueue;
import org.apache.lucene.util.bkd.BKDUtil.ByteArrayPredicate;
-import org.apache.lucene.util.hppc.LongArrayList;
// TODO
// - allow variable length byte[] (across docs and dims), but this is quite a bit more hairy
diff --git a/lucene/core/src/java/org/apache/lucene/util/fst/Util.java b/lucene/core/src/java/org/apache/lucene/util/fst/Util.java
index 4ee07a2feda..15f763f62b2 100644
--- a/lucene/core/src/java/org/apache/lucene/util/fst/Util.java
+++ b/lucene/core/src/java/org/apache/lucene/util/fst/Util.java
@@ -26,14 +26,14 @@ import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.TreeSet;
+import org.apache.lucene.internal.hppc.IntArrayList;
+import org.apache.lucene.internal.hppc.IntCursor;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
import org.apache.lucene.util.IntsRef;
import org.apache.lucene.util.IntsRefBuilder;
import org.apache.lucene.util.fst.FST.Arc;
import org.apache.lucene.util.fst.FST.BytesReader;
-import org.apache.lucene.util.hppc.IntArrayList;
-import org.apache.lucene.util.hppc.IntCursor;
/**
* Static helper methods.
diff --git a/lucene/core/src/java/org/apache/lucene/util/graph/GraphTokenStreamFiniteStrings.java b/lucene/core/src/java/org/apache/lucene/util/graph/GraphTokenStreamFiniteStrings.java
index f8ad4806da1..fa5895e3008 100644
--- a/lucene/core/src/java/org/apache/lucene/util/graph/GraphTokenStreamFiniteStrings.java
+++ b/lucene/core/src/java/org/apache/lucene/util/graph/GraphTokenStreamFiniteStrings.java
@@ -30,6 +30,7 @@ import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionLengthAttribute;
import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
import org.apache.lucene.index.Term;
+import org.apache.lucene.internal.hppc.IntArrayList;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.AttributeSource;
import org.apache.lucene.util.IntsRef;
@@ -37,7 +38,6 @@ import org.apache.lucene.util.automaton.Automaton;
import org.apache.lucene.util.automaton.FiniteStringsIterator;
import org.apache.lucene.util.automaton.Operations;
import org.apache.lucene.util.automaton.Transition;
-import org.apache.lucene.util.hppc.IntArrayList;
/**
* Consumes a TokenStream and creates an {@link Automaton} where the transition labels are terms
diff --git a/lucene/core/src/java/org/apache/lucene/util/hnsw/HnswGraph.java b/lucene/core/src/java/org/apache/lucene/util/hnsw/HnswGraph.java
index 5907a262fe0..a9b74be991c 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hnsw/HnswGraph.java
+++ b/lucene/core/src/java/org/apache/lucene/util/hnsw/HnswGraph.java
@@ -25,8 +25,8 @@ import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.PrimitiveIterator;
import org.apache.lucene.index.FloatVectorValues;
-import org.apache.lucene.util.hppc.IntArrayList;
-import org.apache.lucene.util.hppc.IntCursor;
+import org.apache.lucene.internal.hppc.IntArrayList;
+import org.apache.lucene.internal.hppc.IntCursor;
/**
* Hierarchical Navigable Small World graph. Provides efficient approximate nearest neighbor search
diff --git a/lucene/core/src/java/org/apache/lucene/util/hnsw/IncrementalHnswGraphMerger.java b/lucene/core/src/java/org/apache/lucene/util/hnsw/IncrementalHnswGraphMerger.java
index 501c894e871..4d639c1db70 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hnsw/IncrementalHnswGraphMerger.java
+++ b/lucene/core/src/java/org/apache/lucene/util/hnsw/IncrementalHnswGraphMerger.java
@@ -26,12 +26,12 @@ import org.apache.lucene.index.ByteVectorValues;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.FloatVectorValues;
import org.apache.lucene.index.MergeState;
+import org.apache.lucene.internal.hppc.IntIntHashMap;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.util.BitSet;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.FixedBitSet;
import org.apache.lucene.util.InfoStream;
-import org.apache.lucene.util.hppc.IntIntHashMap;
/**
* This selects the biggest Hnsw graph from the provided merge state and initializes a new
diff --git a/lucene/core/src/java/org/apache/lucene/util/hnsw/OnHeapHnswGraph.java b/lucene/core/src/java/org/apache/lucene/util/hnsw/OnHeapHnswGraph.java
index 6368a120fcc..cac58f39638 100644
--- a/lucene/core/src/java/org/apache/lucene/util/hnsw/OnHeapHnswGraph.java
+++ b/lucene/core/src/java/org/apache/lucene/util/hnsw/OnHeapHnswGraph.java
@@ -21,10 +21,10 @@ import static org.apache.lucene.search.DocIdSetIterator.NO_MORE_DOCS;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
+import org.apache.lucene.internal.hppc.IntArrayList;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.RamUsageEstimator;
-import org.apache.lucene.util.hppc.IntArrayList;
/**
* An {@link HnswGraph} where all nodes and connections are held in memory. This class is used to
diff --git a/lucene/core/src/test/org/apache/lucene/util/hppc/TestCharHashSet.java b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestCharHashSet.java
similarity index 99%
rename from lucene/core/src/test/org/apache/lucene/util/hppc/TestCharHashSet.java
rename to lucene/core/src/test/org/apache/lucene/internal/hppc/TestCharHashSet.java
index b98c7c854db..1ac24ab34f3 100644
--- a/lucene/core/src/test/org/apache/lucene/util/hppc/TestCharHashSet.java
+++ b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestCharHashSet.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
diff --git a/lucene/core/src/test/org/apache/lucene/util/hppc/TestCharObjectHashMap.java b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestCharObjectHashMap.java
similarity index 99%
rename from lucene/core/src/test/org/apache/lucene/util/hppc/TestCharObjectHashMap.java
rename to lucene/core/src/test/org/apache/lucene/internal/hppc/TestCharObjectHashMap.java
index 1a3e58f51a4..4cc036dcfe6 100644
--- a/lucene/core/src/test/org/apache/lucene/util/hppc/TestCharObjectHashMap.java
+++ b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestCharObjectHashMap.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import java.util.Arrays;
diff --git a/lucene/core/src/test/org/apache/lucene/util/hppc/TestIntArrayList.java b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestFloatArrayList.java
similarity index 77%
copy from lucene/core/src/test/org/apache/lucene/util/hppc/TestIntArrayList.java
copy to lucene/core/src/test/org/apache/lucene/internal/hppc/TestFloatArrayList.java
index dd1371aea77..a45f82b258c 100644
--- a/lucene/core/src/test/org/apache/lucene/util/hppc/TestIntArrayList.java
+++ b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestFloatArrayList.java
@@ -15,43 +15,42 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import java.util.Arrays;
import java.util.Iterator;
-import java.util.NoSuchElementException;
import org.apache.lucene.tests.util.LuceneTestCase;
import org.junit.Before;
import org.junit.Test;
/**
- * Tests for {@link IntArrayList}.
+ * Tests for {@link FloatArrayList}.
*
- * <p>Mostly forked and trimmed from com.carrotsearch.hppc.IntArrayListTest
+ * <p>Mostly forked and trimmed from com.carrotsearch.hppc.FloatArrayListTest
*
* <p>github: https://github.com/carrotsearch/hppc release: 0.9.0
*/
-public class TestIntArrayList extends LuceneTestCase {
- private final int key0 = cast(0);
- private final int key1 = cast(1);
- private final int key2 = cast(2);
- private final int key3 = cast(3);
- private final int key4 = cast(4);
- private final int key5 = cast(5);
- private final int key6 = cast(6);
- private final int key7 = cast(7);
+public class TestFloatArrayList extends LuceneTestCase {
+ private final float key0 = cast(0);
+ private final float key1 = cast(1);
+ private final float key2 = cast(2);
+ private final float key3 = cast(3);
+ private final float key4 = cast(4);
+ private final float key5 = cast(5);
+ private final float key6 = cast(6);
+ private final float key7 = cast(7);
/** Convert to target type from an integer used to test stuff. */
- private int cast(int v) {
+ private float cast(int v) {
return v;
}
/** Per-test fresh initialized instance. */
- private IntArrayList list;
+ private FloatArrayList list;
@Before
public void initialize() {
- list = new IntArrayList();
+ list = new FloatArrayList();
}
@Test
@@ -87,7 +86,7 @@ public class TestIntArrayList extends LuceneTestCase {
@Test
public void testAddAll() {
- IntArrayList list2 = new IntArrayList();
+ FloatArrayList list2 = new FloatArrayList();
list2.add(asArray(0, 1, 2));
list.addAll(list2);
@@ -221,9 +220,9 @@ public class TestIntArrayList extends LuceneTestCase {
@Test
public void testEnsureCapacity() {
- IntArrayList list = new IntArrayList(0);
+ FloatArrayList list = new FloatArrayList(0);
assertEquals(list.size(), list.buffer.length);
- int[] buffer1 = list.buffer;
+ float[] buffer1 = list.buffer;
list.ensureCapacity(100);
assertNotSame(buffer1, list.buffer);
}
@@ -270,7 +269,7 @@ public class TestIntArrayList extends LuceneTestCase {
public void testIterable() {
list.add(asArray(0, 1, 2, 3));
int count = 0;
- for (IntCursor cursor : list) {
+ for (FloatCursor cursor : list) {
count++;
assertEquals(list.get(cursor.index), cursor.value);
assertEquals(list.buffer[cursor.index], cursor.value);
@@ -279,7 +278,7 @@ public class TestIntArrayList extends LuceneTestCase {
count = 0;
list.resize(0);
- for (@SuppressWarnings("unused") IntCursor cursor : list) {
+ for (@SuppressWarnings("unused") FloatCursor cursor : list) {
count++;
}
assertEquals(0, count);
@@ -288,7 +287,7 @@ public class TestIntArrayList extends LuceneTestCase {
@Test
public void testIterator() {
list.add(asArray(0, 1, 2, 3));
- Iterator<IntCursor> iterator = list.iterator();
+ Iterator<FloatCursor> iterator = list.iterator();
int count = 0;
while (iterator.hasNext()) {
iterator.hasNext();
@@ -313,7 +312,7 @@ public class TestIntArrayList extends LuceneTestCase {
@Test
public void testFrom() {
- list = IntArrayList.from(key1, key2, key3);
+ list = FloatArrayList.from(key1, key2, key3);
assertEquals(3, list.size());
assertListEquals(list.toArray(), 1, 2, 3);
assertEquals(list.size(), list.buffer.length);
@@ -322,7 +321,7 @@ public class TestIntArrayList extends LuceneTestCase {
@Test
public void testCopyList() {
list.add(asArray(1, 2, 3));
- IntArrayList copy = new IntArrayList(list);
+ FloatArrayList copy = new FloatArrayList(list);
assertEquals(3, copy.size());
assertListEquals(copy.toArray(), 1, 2, 3);
assertEquals(copy.size(), copy.buffer.length);
@@ -330,12 +329,12 @@ public class TestIntArrayList extends LuceneTestCase {
@Test
public void testHashCodeEquals() {
- IntArrayList l0 = IntArrayList.from();
+ FloatArrayList l0 = FloatArrayList.from();
assertEquals(1, l0.hashCode());
- assertEquals(l0, IntArrayList.from());
+ assertEquals(l0, FloatArrayList.from());
- IntArrayList l1 = IntArrayList.from(key1, key2, key3);
- IntArrayList l2 = IntArrayList.from(key1, key2);
+ FloatArrayList l1 = FloatArrayList.from(key1, key2, key3);
+ FloatArrayList l2 = FloatArrayList.from(key1, key2);
l2.add(key3);
assertEquals(l1.hashCode(), l2.hashCode());
@@ -344,8 +343,8 @@ public class TestIntArrayList extends LuceneTestCase {
@Test
public void testEqualElements() {
- IntArrayList l1 = IntArrayList.from(key1, key2, key3);
- IntArrayList l2 = IntArrayList.from(key1, key2);
+ FloatArrayList l1 = FloatArrayList.from(key1, key2, key3);
+ FloatArrayList l2 = FloatArrayList.from(key1, key2);
l2.add(key3);
assertEquals(l1.hashCode(), l2.hashCode());
@@ -354,17 +353,17 @@ public class TestIntArrayList extends LuceneTestCase {
@Test
public void testToArray() {
- IntArrayList l1 = IntArrayList.from(key1, key2, key3);
+ FloatArrayList l1 = FloatArrayList.from(key1, key2, key3);
l1.ensureCapacity(100);
- int[] result = l1.toArray();
- assertArrayEquals(new int[] {key1, key2, key3}, result);
+ float[] result = l1.toArray();
+ assertArrayEquals(new float[] {key1, key2, key3}, result);
}
@Test
public void testClone() {
list.add(key1, key2, key3);
- IntArrayList cloned = list.clone();
+ FloatArrayList cloned = list.clone();
cloned.removeAt(cloned.indexOf(key1));
assertSortedListEquals(list.toArray(), key1, key2, key3);
@@ -375,14 +374,14 @@ public class TestIntArrayList extends LuceneTestCase {
public void testToString() {
assertEquals(
"[" + key1 + ", " + key2 + ", " + key3 + "]",
- IntArrayList.from(key1, key2, key3).toString());
+ FloatArrayList.from(key1, key2, key3).toString());
}
@Test
public void testEqualsSameClass() {
- IntArrayList l1 = IntArrayList.from(key1, key2, key3);
- IntArrayList l2 = IntArrayList.from(key1, key2, key3);
- IntArrayList l3 = IntArrayList.from(key1, key3, key2);
+ FloatArrayList l1 = FloatArrayList.from(key1, key2, key3);
+ FloatArrayList l2 = FloatArrayList.from(key1, key2, key3);
+ FloatArrayList l3 = FloatArrayList.from(key1, key3, key2);
assertEquals(l1, l2);
assertEquals(l1.hashCode(), l2.hashCode());
@@ -391,12 +390,12 @@ public class TestIntArrayList extends LuceneTestCase {
@Test
public void testEqualsSubClass() {
- class Sub extends IntArrayList {}
+ class Sub extends FloatArrayList {}
;
- IntArrayList l1 = IntArrayList.from(key1, key2, key3);
- IntArrayList l2 = new Sub();
- IntArrayList l3 = new Sub();
+ FloatArrayList l1 = FloatArrayList.from(key1, key2, key3);
+ FloatArrayList l2 = new Sub();
+ FloatArrayList l3 = new Sub();
l2.addAll(l1);
l3.addAll(l1);
@@ -404,63 +403,58 @@ public class TestIntArrayList extends LuceneTestCase {
assertNotEquals(l1, l3);
}
- @Test
- public void testStream() {
- assertEquals(key1, IntArrayList.from(key1, key2, key3).stream().min().orElseThrow());
- assertEquals(key3, IntArrayList.from(key2, key1, key3).stream().max().orElseThrow());
- assertEquals(0, IntArrayList.from(key1, key2, -key3).stream().sum());
- expectThrows(
- NoSuchElementException.class,
- () -> {
- IntArrayList.from().stream().min().orElseThrow();
- });
- }
-
@Test
public void testSort() {
- list.add(key1, key3, key2);
-
- IntArrayList list2 = new IntArrayList();
+ list.add(key3, key1, key3, key2);
+ FloatArrayList list2 = new FloatArrayList();
list2.ensureCapacity(100);
list2.addAll(list);
assertSame(list2, list2.sort());
- assertEquals(IntArrayList.from(list.stream().sorted().toArray()), list2);
+ assertEquals(FloatArrayList.from(key1, key2, key3, key3), list2);
}
@Test
public void testReverse() {
for (int i = 0; i < 10; i++) {
- int[] elements = new int[i];
+ float[] elements = new float[i];
for (int j = 0; j < i; j++) {
elements[j] = cast(j);
}
- IntArrayList list = new IntArrayList();
+ FloatArrayList list = new FloatArrayList();
list.ensureCapacity(30);
list.add(elements);
assertSame(list, list.reverse());
assertEquals(elements.length, list.size());
int reverseIndex = elements.length - 1;
- for (IntCursor cursor : list) {
+ for (FloatCursor cursor : list) {
assertEquals(elements[reverseIndex--], cursor.value);
}
}
}
/** Check if the array's content is identical to a given sequence of elements. */
- private static void assertListEquals(int[] array, int... elements) {
+ private static void assertListEquals(float[] array, float... elements) {
assertEquals(elements.length, array.length);
assertArrayEquals(elements, array);
}
- private static int[] asArray(int... elements) {
+ private static float[] asArray(float... elements) {
return elements;
}
/** Check if the array's content is identical to a given sequence of elements. */
- private static void assertSortedListEquals(int[] array, int... elements) {
+ private static void assertSortedListEquals(float[] array, float... elements) {
assertEquals(elements.length, array.length);
Arrays.sort(array);
Arrays.sort(elements);
assertArrayEquals(elements, array);
}
+
+ private static void assertEquals(float f1, float f2) {
+ assertEquals(f1, f2, 0f);
+ }
+
+ private static void assertArrayEquals(float[] f1, float[] f2) {
+ assertArrayEquals(f1, f2, 0f);
+ }
}
diff --git a/lucene/core/src/test/org/apache/lucene/util/hppc/TestIntArrayList.java b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntArrayList.java
similarity index 98%
rename from lucene/core/src/test/org/apache/lucene/util/hppc/TestIntArrayList.java
rename to lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntArrayList.java
index dd1371aea77..a89da9a1d25 100644
--- a/lucene/core/src/test/org/apache/lucene/util/hppc/TestIntArrayList.java
+++ b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntArrayList.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import java.util.Arrays;
import java.util.Iterator;
@@ -418,13 +418,12 @@ public class TestIntArrayList extends LuceneTestCase {
@Test
public void testSort() {
- list.add(key1, key3, key2);
-
+ list.add(key3, key1, key3, key2);
IntArrayList list2 = new IntArrayList();
list2.ensureCapacity(100);
list2.addAll(list);
assertSame(list2, list2.sort());
- assertEquals(IntArrayList.from(list.stream().sorted().toArray()), list2);
+ assertEquals(IntArrayList.from(key1, key2, key3, key3), list2);
}
@Test
diff --git a/lucene/core/src/test/org/apache/lucene/util/hppc/TestIntIntHashMap.java b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntDoubleHashMap.java
similarity index 72%
copy from lucene/core/src/test/org/apache/lucene/util/hppc/TestIntIntHashMap.java
copy to lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntDoubleHashMap.java
index f1c036d2458..a873f8df174 100644
--- a/lucene/core/src/test/org/apache/lucene/util/hppc/TestIntIntHashMap.java
+++ b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntDoubleHashMap.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import java.util.Arrays;
@@ -24,17 +24,16 @@ import java.util.HashSet;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.tests.util.LuceneTestCase;
-import org.junit.After;
import org.junit.Test;
/**
- * Tests for {@link IntIntHashMap}.
+ * Tests for {@link IntDoubleHashMap}.
*
- * <p>Mostly forked and trimmed from com.carrotsearch.hppc.IntIntHashMapTest
+ * <p>Mostly forked and trimmed from com.carrotsearch.hppc.IntDoubleHashMapTest
*
* <p>github: https://github.com/carrotsearch/hppc release: 0.9.0
*/
-public class TestIntIntHashMap extends LuceneTestCase {
+public class TestIntDoubleHashMap extends LuceneTestCase {
/* Ready to use key values. */
private final int keyE = 0;
@@ -65,6 +64,14 @@ public class TestIntIntHashMap extends LuceneTestCase {
assertArrayEquals(elements, array);
}
+ /** Check if the array's content is identical to a given sequence of elements. */
+ private static void assertSortedListEquals(double[] array, double... elements) {
+ assertEquals(elements.length, array.length);
+ Arrays.sort(array);
+ Arrays.sort(elements);
+ assertArrayEquals(elements, array);
+ }
+
private final int value0 = vcast(0);
private final int value1 = vcast(1);
private final int value2 = vcast(2);
@@ -72,27 +79,10 @@ public class TestIntIntHashMap extends LuceneTestCase {
private final int value4 = vcast(4);
/** Per-test fresh initialized instance. */
- private IntIntHashMap map = newInstance();
-
- private IntIntHashMap newInstance() {
- return new IntIntHashMap();
- }
-
- @After
- public void checkEmptySlotsUninitialized() {
- if (map != null) {
- int occupied = 0;
- for (int i = 0; i <= map.mask; i++) {
- if (((map.keys[i]) == 0)) {
-
- } else {
- occupied++;
- }
- }
- assertEquals(occupied, map.assigned);
+ private IntDoubleHashMap map = newInstance();
- if (!map.hasEmptyKey) {}
- }
+ private IntDoubleHashMap newInstance() {
+ return new IntDoubleHashMap();
}
/** Convert to target type from an integer used to test stuff. */
@@ -101,25 +91,38 @@ public class TestIntIntHashMap extends LuceneTestCase {
}
/** Create a new array of a given type and copy the arguments to this array. */
- private int[] newvArray(int... elements) {
- return elements;
+ /* */
+ private double[] newvArray(int... elements) {
+ double[] v = new double[elements.length];
+ for (int i = 0; i < elements.length; i++) {
+ v[i] = elements[i];
+ }
+ return v;
}
- private void assertSameMap(final IntIntHashMap c1, final IntIntHashMap c2) {
+ private void assertSameMap(final IntDoubleHashMap c1, final IntDoubleHashMap c2) {
assertEquals(c1.size(), c2.size());
- for (IntIntHashMap.IntIntCursor entry : c1) {
+ for (IntDoubleHashMap.IntDoubleCursor entry : c1) {
assertTrue(c2.containsKey(entry.key));
- assertEquals(entry.value, c2.get(entry.key));
+ assertEquals2(entry.value, c2.get(entry.key));
}
}
+ private static void assertEquals2(double v1, double v2) {
+ assertEquals(v1, v2, 0f);
+ }
+
+ private static void assertArrayEquals(double[] v1, double[] v2) {
+ assertArrayEquals(v1, v2, 0f);
+ }
+
/* */
@Test
public void testEnsureCapacity() {
final AtomicInteger expands = new AtomicInteger();
- IntIntHashMap map =
- new IntIntHashMap(0) {
+ IntDoubleHashMap map =
+ new IntDoubleHashMap(0) {
@Override
protected void allocateBuffers(int arraySize) {
super.allocateBuffers(arraySize);
@@ -148,9 +151,9 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.put(key1, value2);
map.put(key2, value3);
- for (IntIntHashMap.IntIntCursor c : map) {
+ for (IntDoubleHashMap.IntDoubleCursor c : map) {
assertTrue(map.indexExists(c.index));
- assertEquals(c.value, map.indexGet(c.index));
+ assertEquals2(c.value, map.indexGet(c.index));
}
}
@@ -167,8 +170,8 @@ public class TestIntIntHashMap extends LuceneTestCase {
assertTrue(map.indexExists(map.indexOf(key1)));
assertFalse(map.indexExists(map.indexOf(key2)));
- assertEquals(value1, map.indexGet(map.indexOf(keyE)));
- assertEquals(value2, map.indexGet(map.indexOf(key1)));
+ assertEquals2(value1, map.indexGet(map.indexOf(keyE)));
+ assertEquals2(value2, map.indexGet(map.indexOf(key1)));
expectThrows(
AssertionError.class,
@@ -176,18 +179,18 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.indexGet(map.indexOf(key2));
});
- assertEquals(value1, map.indexReplace(map.indexOf(keyE), value3));
- assertEquals(value2, map.indexReplace(map.indexOf(key1), value4));
- assertEquals(value3, map.indexGet(map.indexOf(keyE)));
- assertEquals(value4, map.indexGet(map.indexOf(key1)));
+ assertEquals2(value1, map.indexReplace(map.indexOf(keyE), value3));
+ assertEquals2(value2, map.indexReplace(map.indexOf(key1), value4));
+ assertEquals2(value3, map.indexGet(map.indexOf(keyE)));
+ assertEquals2(value4, map.indexGet(map.indexOf(key1)));
map.indexInsert(map.indexOf(key2), key2, value1);
- assertEquals(value1, map.indexGet(map.indexOf(key2)));
+ assertEquals2(value1, map.indexGet(map.indexOf(key2)));
assertEquals(3, map.size());
- assertEquals(value3, map.indexRemove(map.indexOf(keyE)));
+ assertEquals2(value3, map.indexRemove(map.indexOf(keyE)));
assertEquals(2, map.size());
- assertEquals(value1, map.indexRemove(map.indexOf(key2)));
+ assertEquals2(value1, map.indexRemove(map.indexOf(key2)));
assertEquals(1, map.size());
assertTrue(map.indexOf(keyE) < 0);
assertTrue(map.indexOf(key1) >= 0);
@@ -201,7 +204,7 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.put(key2, value2);
map.put(key3, value3);
- assertSameMap(map, new IntIntHashMap(map));
+ assertSameMap(map, new IntDoubleHashMap(map));
}
/* */
@@ -211,8 +214,8 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.put(key2, value2);
map.put(key3, value3);
- IntIntHashMap map2 =
- IntIntHashMap.from(newArray(key1, key2, key3), newvArray(value1, value2, value3));
+ IntDoubleHashMap map2 =
+ IntDoubleHashMap.from(newArray(key1, key2, key3), newvArray(value1, value2, value3));
assertSameMap(map, map2);
}
@@ -223,10 +226,10 @@ public class TestIntIntHashMap extends LuceneTestCase {
assertTrue(map.containsKey(key2));
map.put(key1, value1);
- assertEquals(value1, map.getOrDefault(key1, value3));
- assertEquals(value3, map.getOrDefault(key3, value3));
+ assertEquals2(value1, map.getOrDefault(key1, value3));
+ assertEquals2(value3, map.getOrDefault(key3, value3));
map.remove(key1);
- assertEquals(value3, map.getOrDefault(key1, value3));
+ assertEquals2(value3, map.getOrDefault(key1, value3));
}
/* */
@@ -235,22 +238,22 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.put(key1, value1);
assertTrue(map.containsKey(key1));
- assertEquals(value1, map.get(key1));
+ assertEquals2(value1, map.get(key1));
}
/* */
@Test
public void testPutOverExistingKey() {
map.put(key1, value1);
- assertEquals(value1, map.put(key1, value3));
- assertEquals(value3, map.get(key1));
+ assertEquals2(value1, map.put(key1, value3));
+ assertEquals2(value3, map.get(key1));
}
/* */
@Test
public void testPutWithExpansions() {
final int COUNT = 10000;
- final Random rnd = new Random(random().nextLong());
+ final Random rnd = new Random(random().nextInt());
final HashSet<Object> values = new HashSet<Object>();
for (int i = 0; i < COUNT; i++) {
@@ -271,7 +274,7 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.put(key1, value1);
map.put(key2, value1);
- IntIntHashMap map2 = newInstance();
+ IntDoubleHashMap map2 = newInstance();
map2.put(key2, value2);
map2.put(keyE, value1);
@@ -280,10 +283,10 @@ public class TestIntIntHashMap extends LuceneTestCase {
assertEquals(1, map.putAll(map2));
// Assert the value under key2 has been replaced.
- assertEquals(value2, map.get(key2));
+ assertEquals2(value2, map.get(key2));
// And key3 has been added.
- assertEquals(value1, map.get(keyE));
+ assertEquals2(value1, map.get(keyE));
assertEquals(3, map.size());
}
@@ -292,27 +295,27 @@ public class TestIntIntHashMap extends LuceneTestCase {
public void testPutIfAbsent() {
assertTrue(map.putIfAbsent(key1, value1));
assertFalse(map.putIfAbsent(key1, value2));
- assertEquals(value1, map.get(key1));
+ assertEquals2(value1, map.get(key1));
}
@Test
public void testPutOrAdd() {
- assertEquals(value1, map.putOrAdd(key1, value1, value2));
- assertEquals(value3, map.putOrAdd(key1, value1, value2));
+ assertEquals2(value1, map.putOrAdd(key1, value1, value2));
+ assertEquals2(value3, map.putOrAdd(key1, value1, value2));
}
@Test
public void testAddTo() {
- assertEquals(value1, map.addTo(key1, value1));
- assertEquals(value3, map.addTo(key1, value2));
+ assertEquals2(value1, map.addTo(key1, value1));
+ assertEquals2(value3, map.addTo(key1, value2));
}
/* */
@Test
public void testRemove() {
map.put(key1, value1);
- assertEquals(value1, map.remove(key1));
- assertEquals(0, map.remove(key1));
+ assertEquals2(value1, map.remove(key1));
+ assertEquals2(0, map.remove(key1));
assertEquals(0, map.size());
// These are internals, but perhaps worth asserting too.
@@ -326,24 +329,24 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.put(empty, value1);
assertEquals(1, map.size());
- assertEquals(false, map.isEmpty());
- assertEquals(value1, map.get(empty));
- assertEquals(value1, map.getOrDefault(empty, value2));
- assertEquals(true, map.iterator().hasNext());
+ assertFalse(map.isEmpty());
+ assertEquals2(value1, map.get(empty));
+ assertEquals2(value1, map.getOrDefault(empty, value2));
+ assertTrue(map.iterator().hasNext());
assertEquals(empty, map.iterator().next().key);
- assertEquals(value1, map.iterator().next().value);
+ assertEquals2(value1, map.iterator().next().value);
map.remove(empty);
- assertEquals(0, map.get(empty));
+ assertEquals2(0, map.get(empty));
assertEquals(0, map.size());
- assertEquals(0, map.put(empty, value1));
- assertEquals(value1, map.put(empty, value2));
+ assertEquals2(0, map.put(empty, value1));
+ assertEquals2(value1, map.put(empty, value2));
map.clear();
assertFalse(map.indexExists(map.indexOf(empty)));
- assertEquals(0, map.put(empty, value1));
+ assertEquals2(0, map.put(empty, value1));
map.clear();
- assertEquals(0, map.remove(empty));
+ assertEquals2(0, map.remove(empty));
}
/* */
@@ -383,8 +386,8 @@ public class TestIntIntHashMap extends LuceneTestCase {
assertEquals(0, map.assigned);
// Check values are cleared.
- assertEquals(0, map.put(key1, value1));
- assertEquals(0, map.remove(key2));
+ assertEquals2(0, map.put(key1, value1));
+ assertEquals2(0, map.remove(key2));
map.clear();
// Check if the map behaves properly upon subsequent use.
@@ -415,12 +418,12 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.remove(key2);
int count = 0;
- for (IntIntHashMap.IntIntCursor cursor : map) {
+ for (IntDoubleHashMap.IntDoubleCursor cursor : map) {
count++;
assertTrue(map.containsKey(cursor.key));
- assertEquals(cursor.value, map.get(cursor.key));
+ assertEquals2(cursor.value, map.get(cursor.key));
- assertEquals(cursor.value, map.values[cursor.index]);
+ assertEquals2(cursor.value, map.values[cursor.index]);
assertEquals(cursor.key, map.keys[cursor.index]);
}
assertEquals(count, map.size());
@@ -435,7 +438,7 @@ public class TestIntIntHashMap extends LuceneTestCase {
final AtomicInteger reallocations = new AtomicInteger();
final int elements = 0x7F;
map =
- new IntIntHashMap(elements, 1f) {
+ new IntDoubleHashMap(elements, 1f) {
@Override
protected double verifyLoadFactor(double loadFactor) {
// Skip load factor sanity range checking.
@@ -477,33 +480,33 @@ public class TestIntIntHashMap extends LuceneTestCase {
@Test
public void testHashCodeEquals() {
- IntIntHashMap l0 = newInstance();
+ IntDoubleHashMap l0 = newInstance();
assertEquals(0, l0.hashCode());
assertEquals(l0, newInstance());
- IntIntHashMap l1 =
- IntIntHashMap.from(newArray(key1, key2, key3), newvArray(value1, value2, value3));
+ IntDoubleHashMap l1 =
+ IntDoubleHashMap.from(newArray(key1, key2, key3), newvArray(value1, value2, value3));
- IntIntHashMap l2 =
- IntIntHashMap.from(newArray(key2, key1, key3), newvArray(value2, value1, value3));
+ IntDoubleHashMap l2 =
+ IntDoubleHashMap.from(newArray(key2, key1, key3), newvArray(value2, value1, value3));
- IntIntHashMap l3 = IntIntHashMap.from(newArray(key1, key2), newvArray(value2, value1));
+ IntDoubleHashMap l3 = IntDoubleHashMap.from(newArray(key1, key2), newvArray(value2, value1));
assertEquals(l1.hashCode(), l2.hashCode());
assertEquals(l1, l2);
- assertFalse(l1.equals(l3));
- assertFalse(l2.equals(l3));
+ assertNotEquals(l1, l3);
+ assertNotEquals(l2, l3);
}
@Test
public void testBug_HPPC37() {
- IntIntHashMap l1 = IntIntHashMap.from(newArray(key1), newvArray(value1));
+ IntDoubleHashMap l1 = IntDoubleHashMap.from(newArray(key1), newvArray(value1));
- IntIntHashMap l2 = IntIntHashMap.from(newArray(key2), newvArray(value1));
+ IntDoubleHashMap l2 = IntDoubleHashMap.from(newArray(key2), newvArray(value1));
- assertFalse(l1.equals(l2));
- assertFalse(l2.equals(l1));
+ assertNotEquals(l1, l2);
+ assertNotEquals(l2, l1);
}
/** Runs random insertions/deletions/clearing and compares the results against {@link HashMap}. */
@@ -523,11 +526,11 @@ public class TestIntIntHashMap extends LuceneTestCase {
key = 0;
}
- int value = vcast(rnd.nextInt());
+ double value = vcast(rnd.nextInt());
boolean hadOldValue = map.containsKey(key);
if (rnd.nextBoolean()) {
- int previousValue;
+ double previousValue;
if (rnd.nextBoolean()) {
int index = map.indexOf(key);
if (map.indexExists(index)) {
@@ -542,13 +545,13 @@ public class TestIntIntHashMap extends LuceneTestCase {
assertEquals(
other.put(key, value), ((previousValue) == 0) && !hadOldValue ? null : previousValue);
- assertEquals(value, map.get(key));
- assertEquals(value, map.indexGet(map.indexOf(key)));
+ assertEquals2(value, map.get(key));
+ assertEquals2(value, map.indexGet(map.indexOf(key)));
assertTrue(map.containsKey(key));
assertTrue(map.indexExists(map.indexOf(key)));
} else {
assertEquals(other.containsKey(key), map.containsKey(key));
- int previousValue =
+ double previousValue =
map.containsKey(key) && rnd.nextBoolean()
? map.indexRemove(map.indexOf(key))
: map.remove(key);
@@ -570,7 +573,7 @@ public class TestIntIntHashMap extends LuceneTestCase {
this.map.put(key2, value2);
this.map.put(key3, value3);
- IntIntHashMap cloned = map.clone();
+ IntDoubleHashMap cloned = map.clone();
cloned.remove(key1);
assertSortedListEquals(map.keys().toArray(), key1, key2, key3);
@@ -600,8 +603,8 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.put(key3, value1);
int counted = 0;
- for (IntCursor c : map.values()) {
- assertEquals(map.values[c.index], c.value);
+ for (DoubleCursor c : map.values()) {
+ assertEquals2(map.values[c.index], c.value);
counted++;
}
assertEquals(counted, map.size());
@@ -610,15 +613,15 @@ public class TestIntIntHashMap extends LuceneTestCase {
/* */
@Test
public void testEqualsSameClass() {
- IntIntHashMap l1 = newInstance();
+ IntDoubleHashMap l1 = newInstance();
l1.put(key1, value0);
l1.put(key2, value1);
l1.put(key3, value2);
- IntIntHashMap l2 = new IntIntHashMap(l1);
+ IntDoubleHashMap l2 = new IntDoubleHashMap(l1);
l2.putAll(l1);
- IntIntHashMap l3 = new IntIntHashMap(l2);
+ IntDoubleHashMap l3 = new IntDoubleHashMap(l2);
l3.putAll(l2);
l3.put(key4, value0);
@@ -630,18 +633,18 @@ public class TestIntIntHashMap extends LuceneTestCase {
/* */
@Test
public void testEqualsSubClass() {
- class Sub extends IntIntHashMap {}
+ class Sub extends IntDoubleHashMap {}
- IntIntHashMap l1 = newInstance();
+ IntDoubleHashMap l1 = newInstance();
l1.put(key1, value0);
l1.put(key2, value1);
l1.put(key3, value2);
- IntIntHashMap l2 = new Sub();
+ IntDoubleHashMap l2 = new Sub();
l2.putAll(l1);
l2.put(key4, value3);
- IntIntHashMap l3 = new Sub();
+ IntDoubleHashMap l3 = new Sub();
l3.putAll(l2);
assertNotEquals(l1, l2);
diff --git a/lucene/core/src/test/org/apache/lucene/util/hppc/TestIntIntHashMap.java b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntFloatHashMap.java
similarity index 72%
copy from lucene/core/src/test/org/apache/lucene/util/hppc/TestIntIntHashMap.java
copy to lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntFloatHashMap.java
index f1c036d2458..842ca75e4b5 100644
--- a/lucene/core/src/test/org/apache/lucene/util/hppc/TestIntIntHashMap.java
+++ b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntFloatHashMap.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import java.util.Arrays;
@@ -24,17 +24,16 @@ import java.util.HashSet;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.tests.util.LuceneTestCase;
-import org.junit.After;
import org.junit.Test;
/**
- * Tests for {@link IntIntHashMap}.
+ * Tests for {@link IntFloatHashMap}.
*
- * <p>Mostly forked and trimmed from com.carrotsearch.hppc.IntIntHashMapTest
+ * <p>Mostly forked and trimmed from com.carrotsearch.hppc.IntFloatHashMapTest
*
* <p>github: https://github.com/carrotsearch/hppc release: 0.9.0
*/
-public class TestIntIntHashMap extends LuceneTestCase {
+public class TestIntFloatHashMap extends LuceneTestCase {
/* Ready to use key values. */
private final int keyE = 0;
@@ -65,6 +64,14 @@ public class TestIntIntHashMap extends LuceneTestCase {
assertArrayEquals(elements, array);
}
+ /** Check if the array's content is identical to a given sequence of elements. */
+ private static void assertSortedListEquals(float[] array, float... elements) {
+ assertEquals(elements.length, array.length);
+ Arrays.sort(array);
+ Arrays.sort(elements);
+ assertArrayEquals(elements, array);
+ }
+
private final int value0 = vcast(0);
private final int value1 = vcast(1);
private final int value2 = vcast(2);
@@ -72,27 +79,10 @@ public class TestIntIntHashMap extends LuceneTestCase {
private final int value4 = vcast(4);
/** Per-test fresh initialized instance. */
- private IntIntHashMap map = newInstance();
-
- private IntIntHashMap newInstance() {
- return new IntIntHashMap();
- }
-
- @After
- public void checkEmptySlotsUninitialized() {
- if (map != null) {
- int occupied = 0;
- for (int i = 0; i <= map.mask; i++) {
- if (((map.keys[i]) == 0)) {
-
- } else {
- occupied++;
- }
- }
- assertEquals(occupied, map.assigned);
+ private IntFloatHashMap map = newInstance();
- if (!map.hasEmptyKey) {}
- }
+ private IntFloatHashMap newInstance() {
+ return new IntFloatHashMap();
}
/** Convert to target type from an integer used to test stuff. */
@@ -101,25 +91,38 @@ public class TestIntIntHashMap extends LuceneTestCase {
}
/** Create a new array of a given type and copy the arguments to this array. */
- private int[] newvArray(int... elements) {
- return elements;
+ /* */
+ private float[] newvArray(int... elements) {
+ float[] v = new float[elements.length];
+ for (int i = 0; i < elements.length; i++) {
+ v[i] = elements[i];
+ }
+ return v;
}
- private void assertSameMap(final IntIntHashMap c1, final IntIntHashMap c2) {
+ private void assertSameMap(final IntFloatHashMap c1, final IntFloatHashMap c2) {
assertEquals(c1.size(), c2.size());
- for (IntIntHashMap.IntIntCursor entry : c1) {
+ for (IntFloatHashMap.IntFloatCursor entry : c1) {
assertTrue(c2.containsKey(entry.key));
- assertEquals(entry.value, c2.get(entry.key));
+ assertEquals2(entry.value, c2.get(entry.key));
}
}
+ private static void assertEquals2(float v1, float v2) {
+ assertEquals(v1, v2, 0f);
+ }
+
+ private static void assertArrayEquals(float[] v1, float[] v2) {
+ assertArrayEquals(v1, v2, 0f);
+ }
+
/* */
@Test
public void testEnsureCapacity() {
final AtomicInteger expands = new AtomicInteger();
- IntIntHashMap map =
- new IntIntHashMap(0) {
+ IntFloatHashMap map =
+ new IntFloatHashMap(0) {
@Override
protected void allocateBuffers(int arraySize) {
super.allocateBuffers(arraySize);
@@ -148,9 +151,9 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.put(key1, value2);
map.put(key2, value3);
- for (IntIntHashMap.IntIntCursor c : map) {
+ for (IntFloatHashMap.IntFloatCursor c : map) {
assertTrue(map.indexExists(c.index));
- assertEquals(c.value, map.indexGet(c.index));
+ assertEquals2(c.value, map.indexGet(c.index));
}
}
@@ -167,8 +170,8 @@ public class TestIntIntHashMap extends LuceneTestCase {
assertTrue(map.indexExists(map.indexOf(key1)));
assertFalse(map.indexExists(map.indexOf(key2)));
- assertEquals(value1, map.indexGet(map.indexOf(keyE)));
- assertEquals(value2, map.indexGet(map.indexOf(key1)));
+ assertEquals2(value1, map.indexGet(map.indexOf(keyE)));
+ assertEquals2(value2, map.indexGet(map.indexOf(key1)));
expectThrows(
AssertionError.class,
@@ -176,18 +179,18 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.indexGet(map.indexOf(key2));
});
- assertEquals(value1, map.indexReplace(map.indexOf(keyE), value3));
- assertEquals(value2, map.indexReplace(map.indexOf(key1), value4));
- assertEquals(value3, map.indexGet(map.indexOf(keyE)));
- assertEquals(value4, map.indexGet(map.indexOf(key1)));
+ assertEquals2(value1, map.indexReplace(map.indexOf(keyE), value3));
+ assertEquals2(value2, map.indexReplace(map.indexOf(key1), value4));
+ assertEquals2(value3, map.indexGet(map.indexOf(keyE)));
+ assertEquals2(value4, map.indexGet(map.indexOf(key1)));
map.indexInsert(map.indexOf(key2), key2, value1);
- assertEquals(value1, map.indexGet(map.indexOf(key2)));
+ assertEquals2(value1, map.indexGet(map.indexOf(key2)));
assertEquals(3, map.size());
- assertEquals(value3, map.indexRemove(map.indexOf(keyE)));
+ assertEquals2(value3, map.indexRemove(map.indexOf(keyE)));
assertEquals(2, map.size());
- assertEquals(value1, map.indexRemove(map.indexOf(key2)));
+ assertEquals2(value1, map.indexRemove(map.indexOf(key2)));
assertEquals(1, map.size());
assertTrue(map.indexOf(keyE) < 0);
assertTrue(map.indexOf(key1) >= 0);
@@ -201,7 +204,7 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.put(key2, value2);
map.put(key3, value3);
- assertSameMap(map, new IntIntHashMap(map));
+ assertSameMap(map, new IntFloatHashMap(map));
}
/* */
@@ -211,8 +214,8 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.put(key2, value2);
map.put(key3, value3);
- IntIntHashMap map2 =
- IntIntHashMap.from(newArray(key1, key2, key3), newvArray(value1, value2, value3));
+ IntFloatHashMap map2 =
+ IntFloatHashMap.from(newArray(key1, key2, key3), newvArray(value1, value2, value3));
assertSameMap(map, map2);
}
@@ -223,10 +226,10 @@ public class TestIntIntHashMap extends LuceneTestCase {
assertTrue(map.containsKey(key2));
map.put(key1, value1);
- assertEquals(value1, map.getOrDefault(key1, value3));
- assertEquals(value3, map.getOrDefault(key3, value3));
+ assertEquals2(value1, map.getOrDefault(key1, value3));
+ assertEquals2(value3, map.getOrDefault(key3, value3));
map.remove(key1);
- assertEquals(value3, map.getOrDefault(key1, value3));
+ assertEquals2(value3, map.getOrDefault(key1, value3));
}
/* */
@@ -235,22 +238,22 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.put(key1, value1);
assertTrue(map.containsKey(key1));
- assertEquals(value1, map.get(key1));
+ assertEquals2(value1, map.get(key1));
}
/* */
@Test
public void testPutOverExistingKey() {
map.put(key1, value1);
- assertEquals(value1, map.put(key1, value3));
- assertEquals(value3, map.get(key1));
+ assertEquals2(value1, map.put(key1, value3));
+ assertEquals2(value3, map.get(key1));
}
/* */
@Test
public void testPutWithExpansions() {
final int COUNT = 10000;
- final Random rnd = new Random(random().nextLong());
+ final Random rnd = new Random(random().nextInt());
final HashSet<Object> values = new HashSet<Object>();
for (int i = 0; i < COUNT; i++) {
@@ -271,7 +274,7 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.put(key1, value1);
map.put(key2, value1);
- IntIntHashMap map2 = newInstance();
+ IntFloatHashMap map2 = newInstance();
map2.put(key2, value2);
map2.put(keyE, value1);
@@ -280,10 +283,10 @@ public class TestIntIntHashMap extends LuceneTestCase {
assertEquals(1, map.putAll(map2));
// Assert the value under key2 has been replaced.
- assertEquals(value2, map.get(key2));
+ assertEquals2(value2, map.get(key2));
// And key3 has been added.
- assertEquals(value1, map.get(keyE));
+ assertEquals2(value1, map.get(keyE));
assertEquals(3, map.size());
}
@@ -292,27 +295,27 @@ public class TestIntIntHashMap extends LuceneTestCase {
public void testPutIfAbsent() {
assertTrue(map.putIfAbsent(key1, value1));
assertFalse(map.putIfAbsent(key1, value2));
- assertEquals(value1, map.get(key1));
+ assertEquals2(value1, map.get(key1));
}
@Test
public void testPutOrAdd() {
- assertEquals(value1, map.putOrAdd(key1, value1, value2));
- assertEquals(value3, map.putOrAdd(key1, value1, value2));
+ assertEquals2(value1, map.putOrAdd(key1, value1, value2));
+ assertEquals2(value3, map.putOrAdd(key1, value1, value2));
}
@Test
public void testAddTo() {
- assertEquals(value1, map.addTo(key1, value1));
- assertEquals(value3, map.addTo(key1, value2));
+ assertEquals2(value1, map.addTo(key1, value1));
+ assertEquals2(value3, map.addTo(key1, value2));
}
/* */
@Test
public void testRemove() {
map.put(key1, value1);
- assertEquals(value1, map.remove(key1));
- assertEquals(0, map.remove(key1));
+ assertEquals2(value1, map.remove(key1));
+ assertEquals2(0, map.remove(key1));
assertEquals(0, map.size());
// These are internals, but perhaps worth asserting too.
@@ -326,24 +329,24 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.put(empty, value1);
assertEquals(1, map.size());
- assertEquals(false, map.isEmpty());
- assertEquals(value1, map.get(empty));
- assertEquals(value1, map.getOrDefault(empty, value2));
- assertEquals(true, map.iterator().hasNext());
+ assertFalse(map.isEmpty());
+ assertEquals2(value1, map.get(empty));
+ assertEquals2(value1, map.getOrDefault(empty, value2));
+ assertTrue(map.iterator().hasNext());
assertEquals(empty, map.iterator().next().key);
- assertEquals(value1, map.iterator().next().value);
+ assertEquals2(value1, map.iterator().next().value);
map.remove(empty);
- assertEquals(0, map.get(empty));
+ assertEquals2(0, map.get(empty));
assertEquals(0, map.size());
- assertEquals(0, map.put(empty, value1));
- assertEquals(value1, map.put(empty, value2));
+ assertEquals2(0, map.put(empty, value1));
+ assertEquals2(value1, map.put(empty, value2));
map.clear();
assertFalse(map.indexExists(map.indexOf(empty)));
- assertEquals(0, map.put(empty, value1));
+ assertEquals2(0, map.put(empty, value1));
map.clear();
- assertEquals(0, map.remove(empty));
+ assertEquals2(0, map.remove(empty));
}
/* */
@@ -383,8 +386,8 @@ public class TestIntIntHashMap extends LuceneTestCase {
assertEquals(0, map.assigned);
// Check values are cleared.
- assertEquals(0, map.put(key1, value1));
- assertEquals(0, map.remove(key2));
+ assertEquals2(0, map.put(key1, value1));
+ assertEquals2(0, map.remove(key2));
map.clear();
// Check if the map behaves properly upon subsequent use.
@@ -415,12 +418,12 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.remove(key2);
int count = 0;
- for (IntIntHashMap.IntIntCursor cursor : map) {
+ for (IntFloatHashMap.IntFloatCursor cursor : map) {
count++;
assertTrue(map.containsKey(cursor.key));
- assertEquals(cursor.value, map.get(cursor.key));
+ assertEquals2(cursor.value, map.get(cursor.key));
- assertEquals(cursor.value, map.values[cursor.index]);
+ assertEquals2(cursor.value, map.values[cursor.index]);
assertEquals(cursor.key, map.keys[cursor.index]);
}
assertEquals(count, map.size());
@@ -435,7 +438,7 @@ public class TestIntIntHashMap extends LuceneTestCase {
final AtomicInteger reallocations = new AtomicInteger();
final int elements = 0x7F;
map =
- new IntIntHashMap(elements, 1f) {
+ new IntFloatHashMap(elements, 1f) {
@Override
protected double verifyLoadFactor(double loadFactor) {
// Skip load factor sanity range checking.
@@ -477,33 +480,33 @@ public class TestIntIntHashMap extends LuceneTestCase {
@Test
public void testHashCodeEquals() {
- IntIntHashMap l0 = newInstance();
+ IntFloatHashMap l0 = newInstance();
assertEquals(0, l0.hashCode());
assertEquals(l0, newInstance());
- IntIntHashMap l1 =
- IntIntHashMap.from(newArray(key1, key2, key3), newvArray(value1, value2, value3));
+ IntFloatHashMap l1 =
+ IntFloatHashMap.from(newArray(key1, key2, key3), newvArray(value1, value2, value3));
- IntIntHashMap l2 =
- IntIntHashMap.from(newArray(key2, key1, key3), newvArray(value2, value1, value3));
+ IntFloatHashMap l2 =
+ IntFloatHashMap.from(newArray(key2, key1, key3), newvArray(value2, value1, value3));
- IntIntHashMap l3 = IntIntHashMap.from(newArray(key1, key2), newvArray(value2, value1));
+ IntFloatHashMap l3 = IntFloatHashMap.from(newArray(key1, key2), newvArray(value2, value1));
assertEquals(l1.hashCode(), l2.hashCode());
assertEquals(l1, l2);
- assertFalse(l1.equals(l3));
- assertFalse(l2.equals(l3));
+ assertNotEquals(l1, l3);
+ assertNotEquals(l2, l3);
}
@Test
public void testBug_HPPC37() {
- IntIntHashMap l1 = IntIntHashMap.from(newArray(key1), newvArray(value1));
+ IntFloatHashMap l1 = IntFloatHashMap.from(newArray(key1), newvArray(value1));
- IntIntHashMap l2 = IntIntHashMap.from(newArray(key2), newvArray(value1));
+ IntFloatHashMap l2 = IntFloatHashMap.from(newArray(key2), newvArray(value1));
- assertFalse(l1.equals(l2));
- assertFalse(l2.equals(l1));
+ assertNotEquals(l1, l2);
+ assertNotEquals(l2, l1);
}
/** Runs random insertions/deletions/clearing and compares the results against {@link HashMap}. */
@@ -523,11 +526,11 @@ public class TestIntIntHashMap extends LuceneTestCase {
key = 0;
}
- int value = vcast(rnd.nextInt());
+ float value = vcast(rnd.nextInt());
boolean hadOldValue = map.containsKey(key);
if (rnd.nextBoolean()) {
- int previousValue;
+ float previousValue;
if (rnd.nextBoolean()) {
int index = map.indexOf(key);
if (map.indexExists(index)) {
@@ -542,13 +545,13 @@ public class TestIntIntHashMap extends LuceneTestCase {
assertEquals(
other.put(key, value), ((previousValue) == 0) && !hadOldValue ? null : previousValue);
- assertEquals(value, map.get(key));
- assertEquals(value, map.indexGet(map.indexOf(key)));
+ assertEquals2(value, map.get(key));
+ assertEquals2(value, map.indexGet(map.indexOf(key)));
assertTrue(map.containsKey(key));
assertTrue(map.indexExists(map.indexOf(key)));
} else {
assertEquals(other.containsKey(key), map.containsKey(key));
- int previousValue =
+ float previousValue =
map.containsKey(key) && rnd.nextBoolean()
? map.indexRemove(map.indexOf(key))
: map.remove(key);
@@ -570,7 +573,7 @@ public class TestIntIntHashMap extends LuceneTestCase {
this.map.put(key2, value2);
this.map.put(key3, value3);
- IntIntHashMap cloned = map.clone();
+ IntFloatHashMap cloned = map.clone();
cloned.remove(key1);
assertSortedListEquals(map.keys().toArray(), key1, key2, key3);
@@ -600,8 +603,8 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.put(key3, value1);
int counted = 0;
- for (IntCursor c : map.values()) {
- assertEquals(map.values[c.index], c.value);
+ for (FloatCursor c : map.values()) {
+ assertEquals2(map.values[c.index], c.value);
counted++;
}
assertEquals(counted, map.size());
@@ -610,15 +613,15 @@ public class TestIntIntHashMap extends LuceneTestCase {
/* */
@Test
public void testEqualsSameClass() {
- IntIntHashMap l1 = newInstance();
+ IntFloatHashMap l1 = newInstance();
l1.put(key1, value0);
l1.put(key2, value1);
l1.put(key3, value2);
- IntIntHashMap l2 = new IntIntHashMap(l1);
+ IntFloatHashMap l2 = new IntFloatHashMap(l1);
l2.putAll(l1);
- IntIntHashMap l3 = new IntIntHashMap(l2);
+ IntFloatHashMap l3 = new IntFloatHashMap(l2);
l3.putAll(l2);
l3.put(key4, value0);
@@ -630,18 +633,18 @@ public class TestIntIntHashMap extends LuceneTestCase {
/* */
@Test
public void testEqualsSubClass() {
- class Sub extends IntIntHashMap {}
+ class Sub extends IntFloatHashMap {}
- IntIntHashMap l1 = newInstance();
+ IntFloatHashMap l1 = newInstance();
l1.put(key1, value0);
l1.put(key2, value1);
l1.put(key3, value2);
- IntIntHashMap l2 = new Sub();
+ IntFloatHashMap l2 = new Sub();
l2.putAll(l1);
l2.put(key4, value3);
- IntIntHashMap l3 = new Sub();
+ IntFloatHashMap l3 = new Sub();
l3.putAll(l2);
assertNotEquals(l1, l2);
diff --git a/lucene/core/src/test/org/apache/lucene/util/hppc/TestIntHashSet.java b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntHashSet.java
similarity index 99%
rename from lucene/core/src/test/org/apache/lucene/util/hppc/TestIntHashSet.java
rename to lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntHashSet.java
index 2e76b18a6bc..eb4ce02b577 100644
--- a/lucene/core/src/test/org/apache/lucene/util/hppc/TestIntHashSet.java
+++ b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntHashSet.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
diff --git a/lucene/core/src/test/org/apache/lucene/util/hppc/TestIntIntHashMap.java b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntIntHashMap.java
similarity index 96%
rename from lucene/core/src/test/org/apache/lucene/util/hppc/TestIntIntHashMap.java
rename to lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntIntHashMap.java
index f1c036d2458..6869ab82710 100644
--- a/lucene/core/src/test/org/apache/lucene/util/hppc/TestIntIntHashMap.java
+++ b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntIntHashMap.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import java.util.Arrays;
@@ -24,7 +24,6 @@ import java.util.HashSet;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.tests.util.LuceneTestCase;
-import org.junit.After;
import org.junit.Test;
/**
@@ -78,23 +77,6 @@ public class TestIntIntHashMap extends LuceneTestCase {
return new IntIntHashMap();
}
- @After
- public void checkEmptySlotsUninitialized() {
- if (map != null) {
- int occupied = 0;
- for (int i = 0; i <= map.mask; i++) {
- if (((map.keys[i]) == 0)) {
-
- } else {
- occupied++;
- }
- }
- assertEquals(occupied, map.assigned);
-
- if (!map.hasEmptyKey) {}
- }
- }
-
/** Convert to target type from an integer used to test stuff. */
private int vcast(int value) {
return value;
@@ -326,10 +308,10 @@ public class TestIntIntHashMap extends LuceneTestCase {
map.put(empty, value1);
assertEquals(1, map.size());
- assertEquals(false, map.isEmpty());
+ assertFalse(map.isEmpty());
assertEquals(value1, map.get(empty));
assertEquals(value1, map.getOrDefault(empty, value2));
- assertEquals(true, map.iterator().hasNext());
+ assertTrue(map.iterator().hasNext());
assertEquals(empty, map.iterator().next().key);
assertEquals(value1, map.iterator().next().value);
@@ -492,8 +474,8 @@ public class TestIntIntHashMap extends LuceneTestCase {
assertEquals(l1.hashCode(), l2.hashCode());
assertEquals(l1, l2);
- assertFalse(l1.equals(l3));
- assertFalse(l2.equals(l3));
+ assertNotEquals(l1, l3);
+ assertNotEquals(l2, l3);
}
@Test
@@ -502,8 +484,8 @@ public class TestIntIntHashMap extends LuceneTestCase {
IntIntHashMap l2 = IntIntHashMap.from(newArray(key2), newvArray(value1));
- assertFalse(l1.equals(l2));
- assertFalse(l2.equals(l1));
+ assertNotEquals(l1, l2);
+ assertNotEquals(l2, l1);
}
/** Runs random insertions/deletions/clearing and compares the results against {@link HashMap}. */
diff --git a/lucene/core/src/test/org/apache/lucene/util/hppc/TestIntObjectHashMap.java b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntObjectHashMap.java
similarity index 95%
rename from lucene/core/src/test/org/apache/lucene/util/hppc/TestIntObjectHashMap.java
rename to lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntObjectHashMap.java
index e450e17f7cb..6c6c0872ede 100644
--- a/lucene/core/src/test/org/apache/lucene/util/hppc/TestIntObjectHashMap.java
+++ b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestIntObjectHashMap.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import java.util.Arrays;
@@ -24,7 +24,6 @@ import java.util.HashSet;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.tests.util.LuceneTestCase;
-import org.junit.After;
import org.junit.Test;
/**
@@ -86,23 +85,6 @@ public class TestIntObjectHashMap extends LuceneTestCase {
return new IntObjectHashMap();
}
- @After
- public void checkEmptySlotsUninitialized() {
- if (map != null) {
- int occupied = 0;
- for (int i = 0; i <= map.mask; i++) {
- if (((map.keys[i]) == 0)) {
-
- } else {
- occupied++;
- }
- }
- assertEquals(occupied, map.assigned);
-
- if (!map.hasEmptyKey) {}
- }
- }
-
/** Convert to target type from an integer used to test stuff. */
private int vcast(int value) {
return value;
@@ -324,7 +306,7 @@ public class TestIntObjectHashMap extends LuceneTestCase {
public void testRemove() {
map.put(key1, value1);
assertEquals(value1, map.remove(key1));
- assertEquals(null, map.remove(key1));
+ assertNull(map.remove(key1));
assertEquals(0, map.size());
// These are internals, but perhaps worth asserting too.
@@ -338,15 +320,15 @@ public class TestIntObjectHashMap extends LuceneTestCase {
map.put(empty, value1);
assertEquals(1, map.size());
- assertEquals(false, map.isEmpty());
+ assertFalse(map.isEmpty());
assertEquals(value1, map.get(empty));
assertEquals(value1, map.getOrDefault(empty, value2));
- assertEquals(true, map.iterator().hasNext());
+ assertTrue(map.iterator().hasNext());
assertEquals(empty, map.iterator().next().key);
assertEquals(value1, map.iterator().next().value);
map.remove(empty);
- assertEquals(null, map.get(empty));
+ assertNull(map.get(empty));
assertEquals(0, map.size());
map.put(empty, null);
@@ -359,13 +341,13 @@ public class TestIntObjectHashMap extends LuceneTestCase {
assertFalse(map.containsKey(empty));
assertNull(map.get(empty));
- assertEquals(null, map.put(empty, value1));
+ assertNull(map.put(empty, value1));
assertEquals(value1, map.put(empty, value2));
map.clear();
assertFalse(map.indexExists(map.indexOf(empty)));
- assertEquals(null, map.put(empty, value1));
+ assertNull(map.put(empty, value1));
map.clear();
- assertEquals(null, map.remove(empty));
+ assertNull(map.remove(empty));
}
/* */
@@ -405,8 +387,8 @@ public class TestIntObjectHashMap extends LuceneTestCase {
assertEquals(0, map.assigned);
// Check values are cleared.
- assertEquals(null, map.put(key1, value1));
- assertEquals(null, map.remove(key2));
+ assertNull(map.put(key1, value1));
+ assertNull(map.remove(key2));
map.clear();
// Check if the map behaves properly upon subsequent use.
@@ -514,8 +496,8 @@ public class TestIntObjectHashMap extends LuceneTestCase {
assertEquals(l1.hashCode(), l2.hashCode());
assertEquals(l1, l2);
- assertFalse(l1.equals(l3));
- assertFalse(l2.equals(l3));
+ assertNotEquals(l1, l3);
+ assertNotEquals(l2, l3);
}
@Test
@@ -524,8 +506,8 @@ public class TestIntObjectHashMap extends LuceneTestCase {
IntObjectHashMap l2 = IntObjectHashMap.from(newArray(key2), newvArray(value1));
- assertFalse(l1.equals(l2));
- assertFalse(l2.equals(l1));
+ assertNotEquals(l1, l2);
+ assertNotEquals(l2, l1);
}
/** Runs random insertions/deletions/clearing and compares the results against {@link HashMap}. */
diff --git a/lucene/core/src/test/org/apache/lucene/util/hppc/TestLongArrayList.java b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestLongArrayList.java
similarity index 98%
rename from lucene/core/src/test/org/apache/lucene/util/hppc/TestLongArrayList.java
rename to lucene/core/src/test/org/apache/lucene/internal/hppc/TestLongArrayList.java
index 0f53a9f3749..0a3c6a9a486 100644
--- a/lucene/core/src/test/org/apache/lucene/util/hppc/TestLongArrayList.java
+++ b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestLongArrayList.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import java.util.Arrays;
import java.util.Iterator;
@@ -418,13 +418,12 @@ public class TestLongArrayList extends LuceneTestCase {
@Test
public void testSort() {
- list.add(key1, key3, key2);
-
+ list.add(key3, key1, key3, key2);
LongArrayList list2 = new LongArrayList();
list2.ensureCapacity(100);
list2.addAll(list);
assertSame(list2, list2.sort());
- assertEquals(LongArrayList.from(list.stream().sorted().toArray()), list2);
+ assertEquals(LongArrayList.from(key1, key2, key3, key3), list2);
}
@Test
diff --git a/lucene/core/src/test/org/apache/lucene/util/hppc/TestLongIntHashMap.java b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestLongFloatHashMap.java
similarity index 73%
copy from lucene/core/src/test/org/apache/lucene/util/hppc/TestLongIntHashMap.java
copy to lucene/core/src/test/org/apache/lucene/internal/hppc/TestLongFloatHashMap.java
index 0d3468c4b5b..a482966a5d5 100644
--- a/lucene/core/src/test/org/apache/lucene/util/hppc/TestLongIntHashMap.java
+++ b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestLongFloatHashMap.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import java.util.Arrays;
@@ -24,17 +24,16 @@ import java.util.HashSet;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.tests.util.LuceneTestCase;
-import org.junit.After;
import org.junit.Test;
/**
- * Tests for {@link LongIntHashMap}.
+ * Tests for {@link LongFloatHashMap}.
*
- * <p>Mostly forked and trimmed from com.carrotsearch.hppc.LongIntHashMapTest
+ * <p>Mostly forked and trimmed from com.carrotsearch.hppc.LongFloatHashMapTest
*
* <p>github: https://github.com/carrotsearch/hppc release: 0.9.0
*/
-public class TestLongIntHashMap extends LuceneTestCase {
+public class TestLongFloatHashMap extends LuceneTestCase {
/* Ready to use key values. */
private final long keyE = 0;
@@ -66,7 +65,7 @@ public class TestLongIntHashMap extends LuceneTestCase {
}
/** Check if the array's content is identical to a given sequence of elements. */
- private static void assertSortedListEquals(int[] array, int... elements) {
+ private static void assertSortedListEquals(float[] array, float... elements) {
assertEquals(elements.length, array.length);
Arrays.sort(array);
Arrays.sort(elements);
@@ -80,27 +79,10 @@ public class TestLongIntHashMap extends LuceneTestCase {
private final int value4 = vcast(4);
/** Per-test fresh initialized instance. */
- private LongIntHashMap map = newInstance();
+ private LongFloatHashMap map = newInstance();
- private LongIntHashMap newInstance() {
- return new LongIntHashMap();
- }
-
- @After
- public void checkEmptySlotsUninitialized() {
- if (map != null) {
- int occupied = 0;
- for (int i = 0; i <= map.mask; i++) {
- if (((map.keys[i]) == 0)) {
-
- } else {
- occupied++;
- }
- }
- assertEquals(occupied, map.assigned);
-
- if (!map.hasEmptyKey) {}
- }
+ private LongFloatHashMap newInstance() {
+ return new LongFloatHashMap();
}
/** Convert to target type from an integer used to test stuff. */
@@ -110,25 +92,37 @@ public class TestLongIntHashMap extends LuceneTestCase {
/** Create a new array of a given type and copy the arguments to this array. */
/* */
- private int[] newvArray(int... elements) {
- return elements;
+ private float[] newvArray(int... elements) {
+ float[] v = new float[elements.length];
+ for (int i = 0; i < elements.length; i++) {
+ v[i] = elements[i];
+ }
+ return v;
}
- private void assertSameMap(final LongIntHashMap c1, final LongIntHashMap c2) {
+ private void assertSameMap(final LongFloatHashMap c1, final LongFloatHashMap c2) {
assertEquals(c1.size(), c2.size());
- for (LongIntHashMap.LongIntCursor entry : c1) {
+ for (LongFloatHashMap.LongFloatCursor entry : c1) {
assertTrue(c2.containsKey(entry.key));
- assertEquals(entry.value, c2.get(entry.key));
+ assertEquals2(entry.value, c2.get(entry.key));
}
}
+ private static void assertEquals2(float v1, float v2) {
+ assertEquals(v1, v2, 0f);
+ }
+
+ private static void assertArrayEquals(float[] v1, float[] v2) {
+ assertArrayEquals(v1, v2, 0f);
+ }
+
/* */
@Test
public void testEnsureCapacity() {
final AtomicInteger expands = new AtomicInteger();
- LongIntHashMap map =
- new LongIntHashMap(0) {
+ LongFloatHashMap map =
+ new LongFloatHashMap(0) {
@Override
protected void allocateBuffers(int arraySize) {
super.allocateBuffers(arraySize);
@@ -157,9 +151,9 @@ public class TestLongIntHashMap extends LuceneTestCase {
map.put(key1, value2);
map.put(key2, value3);
- for (LongIntHashMap.LongIntCursor c : map) {
+ for (LongFloatHashMap.LongFloatCursor c : map) {
assertTrue(map.indexExists(c.index));
- assertEquals(c.value, map.indexGet(c.index));
+ assertEquals2(c.value, map.indexGet(c.index));
}
}
@@ -176,8 +170,8 @@ public class TestLongIntHashMap extends LuceneTestCase {
assertTrue(map.indexExists(map.indexOf(key1)));
assertFalse(map.indexExists(map.indexOf(key2)));
- assertEquals(value1, map.indexGet(map.indexOf(keyE)));
- assertEquals(value2, map.indexGet(map.indexOf(key1)));
+ assertEquals2(value1, map.indexGet(map.indexOf(keyE)));
+ assertEquals2(value2, map.indexGet(map.indexOf(key1)));
expectThrows(
AssertionError.class,
@@ -185,18 +179,18 @@ public class TestLongIntHashMap extends LuceneTestCase {
map.indexGet(map.indexOf(key2));
});
- assertEquals(value1, map.indexReplace(map.indexOf(keyE), value3));
- assertEquals(value2, map.indexReplace(map.indexOf(key1), value4));
- assertEquals(value3, map.indexGet(map.indexOf(keyE)));
- assertEquals(value4, map.indexGet(map.indexOf(key1)));
+ assertEquals2(value1, map.indexReplace(map.indexOf(keyE), value3));
+ assertEquals2(value2, map.indexReplace(map.indexOf(key1), value4));
+ assertEquals2(value3, map.indexGet(map.indexOf(keyE)));
+ assertEquals2(value4, map.indexGet(map.indexOf(key1)));
map.indexInsert(map.indexOf(key2), key2, value1);
- assertEquals(value1, map.indexGet(map.indexOf(key2)));
+ assertEquals2(value1, map.indexGet(map.indexOf(key2)));
assertEquals(3, map.size());
- assertEquals(value3, map.indexRemove(map.indexOf(keyE)));
+ assertEquals2(value3, map.indexRemove(map.indexOf(keyE)));
assertEquals(2, map.size());
- assertEquals(value1, map.indexRemove(map.indexOf(key2)));
+ assertEquals2(value1, map.indexRemove(map.indexOf(key2)));
assertEquals(1, map.size());
assertTrue(map.indexOf(keyE) < 0);
assertTrue(map.indexOf(key1) >= 0);
@@ -210,7 +204,7 @@ public class TestLongIntHashMap extends LuceneTestCase {
map.put(key2, value2);
map.put(key3, value3);
- assertSameMap(map, new LongIntHashMap(map));
+ assertSameMap(map, new LongFloatHashMap(map));
}
/* */
@@ -220,8 +214,8 @@ public class TestLongIntHashMap extends LuceneTestCase {
map.put(key2, value2);
map.put(key3, value3);
- LongIntHashMap map2 =
- LongIntHashMap.from(newArray(key1, key2, key3), newvArray(value1, value2, value3));
+ LongFloatHashMap map2 =
+ LongFloatHashMap.from(newArray(key1, key2, key3), newvArray(value1, value2, value3));
assertSameMap(map, map2);
}
@@ -232,10 +226,10 @@ public class TestLongIntHashMap extends LuceneTestCase {
assertTrue(map.containsKey(key2));
map.put(key1, value1);
- assertEquals(value1, map.getOrDefault(key1, value3));
- assertEquals(value3, map.getOrDefault(key3, value3));
+ assertEquals2(value1, map.getOrDefault(key1, value3));
+ assertEquals2(value3, map.getOrDefault(key3, value3));
map.remove(key1);
- assertEquals(value3, map.getOrDefault(key1, value3));
+ assertEquals2(value3, map.getOrDefault(key1, value3));
}
/* */
@@ -244,15 +238,15 @@ public class TestLongIntHashMap extends LuceneTestCase {
map.put(key1, value1);
assertTrue(map.containsKey(key1));
- assertEquals(value1, map.get(key1));
+ assertEquals2(value1, map.get(key1));
}
/* */
@Test
public void testPutOverExistingKey() {
map.put(key1, value1);
- assertEquals(value1, map.put(key1, value3));
- assertEquals(value3, map.get(key1));
+ assertEquals2(value1, map.put(key1, value3));
+ assertEquals2(value3, map.get(key1));
}
/* */
@@ -280,7 +274,7 @@ public class TestLongIntHashMap extends LuceneTestCase {
map.put(key1, value1);
map.put(key2, value1);
- LongIntHashMap map2 = newInstance();
+ LongFloatHashMap map2 = newInstance();
map2.put(key2, value2);
map2.put(keyE, value1);
@@ -289,10 +283,10 @@ public class TestLongIntHashMap extends LuceneTestCase {
assertEquals(1, map.putAll(map2));
// Assert the value under key2 has been replaced.
- assertEquals(value2, map.get(key2));
+ assertEquals2(value2, map.get(key2));
// And key3 has been added.
- assertEquals(value1, map.get(keyE));
+ assertEquals2(value1, map.get(keyE));
assertEquals(3, map.size());
}
@@ -301,27 +295,27 @@ public class TestLongIntHashMap extends LuceneTestCase {
public void testPutIfAbsent() {
assertTrue(map.putIfAbsent(key1, value1));
assertFalse(map.putIfAbsent(key1, value2));
- assertEquals(value1, map.get(key1));
+ assertEquals2(value1, map.get(key1));
}
@Test
public void testPutOrAdd() {
- assertEquals(value1, map.putOrAdd(key1, value1, value2));
- assertEquals(value3, map.putOrAdd(key1, value1, value2));
+ assertEquals2(value1, map.putOrAdd(key1, value1, value2));
+ assertEquals2(value3, map.putOrAdd(key1, value1, value2));
}
@Test
public void testAddTo() {
- assertEquals(value1, map.addTo(key1, value1));
- assertEquals(value3, map.addTo(key1, value2));
+ assertEquals2(value1, map.addTo(key1, value1));
+ assertEquals2(value3, map.addTo(key1, value2));
}
/* */
@Test
public void testRemove() {
map.put(key1, value1);
- assertEquals(value1, map.remove(key1));
- assertEquals(0, map.remove(key1));
+ assertEquals2(value1, map.remove(key1));
+ assertEquals2(0, map.remove(key1));
assertEquals(0, map.size());
// These are internals, but perhaps worth asserting too.
@@ -331,28 +325,28 @@ public class TestLongIntHashMap extends LuceneTestCase {
/* */
@Test
public void testEmptyKey() {
- final long empty = 0;
+ final int empty = 0;
map.put(empty, value1);
assertEquals(1, map.size());
- assertEquals(false, map.isEmpty());
- assertEquals(value1, map.get(empty));
- assertEquals(value1, map.getOrDefault(empty, value2));
- assertEquals(true, map.iterator().hasNext());
+ assertFalse(map.isEmpty());
+ assertEquals2(value1, map.get(empty));
+ assertEquals2(value1, map.getOrDefault(empty, value2));
+ assertTrue(map.iterator().hasNext());
assertEquals(empty, map.iterator().next().key);
- assertEquals(value1, map.iterator().next().value);
+ assertEquals2(value1, map.iterator().next().value);
map.remove(empty);
- assertEquals(0, map.get(empty));
+ assertEquals2(0, map.get(empty));
assertEquals(0, map.size());
- assertEquals(0, map.put(empty, value1));
- assertEquals(value1, map.put(empty, value2));
+ assertEquals2(0, map.put(empty, value1));
+ assertEquals2(value1, map.put(empty, value2));
map.clear();
assertFalse(map.indexExists(map.indexOf(empty)));
- assertEquals(0, map.put(empty, value1));
+ assertEquals2(0, map.put(empty, value1));
map.clear();
- assertEquals(0, map.remove(empty));
+ assertEquals2(0, map.remove(empty));
}
/* */
@@ -392,8 +386,8 @@ public class TestLongIntHashMap extends LuceneTestCase {
assertEquals(0, map.assigned);
// Check values are cleared.
- assertEquals(0, map.put(key1, value1));
- assertEquals(0, map.remove(key2));
+ assertEquals2(0, map.put(key1, value1));
+ assertEquals2(0, map.remove(key2));
map.clear();
// Check if the map behaves properly upon subsequent use.
@@ -424,12 +418,12 @@ public class TestLongIntHashMap extends LuceneTestCase {
map.remove(key2);
int count = 0;
- for (LongIntHashMap.LongIntCursor cursor : map) {
+ for (LongFloatHashMap.LongFloatCursor cursor : map) {
count++;
assertTrue(map.containsKey(cursor.key));
- assertEquals(cursor.value, map.get(cursor.key));
+ assertEquals2(cursor.value, map.get(cursor.key));
- assertEquals(cursor.value, map.values[cursor.index]);
+ assertEquals2(cursor.value, map.values[cursor.index]);
assertEquals(cursor.key, map.keys[cursor.index]);
}
assertEquals(count, map.size());
@@ -444,7 +438,7 @@ public class TestLongIntHashMap extends LuceneTestCase {
final AtomicInteger reallocations = new AtomicInteger();
final int elements = 0x7F;
map =
- new LongIntHashMap(elements, 1f) {
+ new LongFloatHashMap(elements, 1f) {
@Override
protected double verifyLoadFactor(double loadFactor) {
// Skip load factor sanity range checking.
@@ -486,33 +480,33 @@ public class TestLongIntHashMap extends LuceneTestCase {
@Test
public void testHashCodeEquals() {
- LongIntHashMap l0 = newInstance();
+ LongFloatHashMap l0 = newInstance();
assertEquals(0, l0.hashCode());
assertEquals(l0, newInstance());
- LongIntHashMap l1 =
- LongIntHashMap.from(newArray(key1, key2, key3), newvArray(value1, value2, value3));
+ LongFloatHashMap l1 =
+ LongFloatHashMap.from(newArray(key1, key2, key3), newvArray(value1, value2, value3));
- LongIntHashMap l2 =
- LongIntHashMap.from(newArray(key2, key1, key3), newvArray(value2, value1, value3));
+ LongFloatHashMap l2 =
+ LongFloatHashMap.from(newArray(key2, key1, key3), newvArray(value2, value1, value3));
- LongIntHashMap l3 = LongIntHashMap.from(newArray(key1, key2), newvArray(value2, value1));
+ LongFloatHashMap l3 = LongFloatHashMap.from(newArray(key1, key2), newvArray(value2, value1));
assertEquals(l1.hashCode(), l2.hashCode());
assertEquals(l1, l2);
- assertFalse(l1.equals(l3));
- assertFalse(l2.equals(l3));
+ assertNotEquals(l1, l3);
+ assertNotEquals(l2, l3);
}
@Test
public void testBug_HPPC37() {
- LongIntHashMap l1 = LongIntHashMap.from(newArray(key1), newvArray(value1));
+ LongFloatHashMap l1 = LongFloatHashMap.from(newArray(key1), newvArray(value1));
- LongIntHashMap l2 = LongIntHashMap.from(newArray(key2), newvArray(value1));
+ LongFloatHashMap l2 = LongFloatHashMap.from(newArray(key2), newvArray(value1));
- assertFalse(l1.equals(l2));
- assertFalse(l2.equals(l1));
+ assertNotEquals(l1, l2);
+ assertNotEquals(l2, l1);
}
/** Runs random insertions/deletions/clearing and compares the results against {@link HashMap}. */
@@ -532,11 +526,11 @@ public class TestLongIntHashMap extends LuceneTestCase {
key = 0;
}
- int value = vcast(rnd.nextInt());
+ float value = vcast(rnd.nextInt());
boolean hadOldValue = map.containsKey(key);
if (rnd.nextBoolean()) {
- int previousValue;
+ float previousValue;
if (rnd.nextBoolean()) {
int index = map.indexOf(key);
if (map.indexExists(index)) {
@@ -551,13 +545,13 @@ public class TestLongIntHashMap extends LuceneTestCase {
assertEquals(
other.put(key, value), ((previousValue) == 0) && !hadOldValue ? null : previousValue);
- assertEquals(value, map.get(key));
- assertEquals(value, map.indexGet(map.indexOf(key)));
+ assertEquals2(value, map.get(key));
+ assertEquals2(value, map.indexGet(map.indexOf(key)));
assertTrue(map.containsKey(key));
assertTrue(map.indexExists(map.indexOf(key)));
} else {
assertEquals(other.containsKey(key), map.containsKey(key));
- int previousValue =
+ float previousValue =
map.containsKey(key) && rnd.nextBoolean()
? map.indexRemove(map.indexOf(key))
: map.remove(key);
@@ -579,7 +573,7 @@ public class TestLongIntHashMap extends LuceneTestCase {
this.map.put(key2, value2);
this.map.put(key3, value3);
- LongIntHashMap cloned = map.clone();
+ LongFloatHashMap cloned = map.clone();
cloned.remove(key1);
assertSortedListEquals(map.keys().toArray(), key1, key2, key3);
@@ -609,8 +603,8 @@ public class TestLongIntHashMap extends LuceneTestCase {
map.put(key3, value1);
int counted = 0;
- for (IntCursor c : map.values()) {
- assertEquals(map.values[c.index], c.value);
+ for (FloatCursor c : map.values()) {
+ assertEquals2(map.values[c.index], c.value);
counted++;
}
assertEquals(counted, map.size());
@@ -619,15 +613,15 @@ public class TestLongIntHashMap extends LuceneTestCase {
/* */
@Test
public void testEqualsSameClass() {
- LongIntHashMap l1 = newInstance();
+ LongFloatHashMap l1 = newInstance();
l1.put(key1, value0);
l1.put(key2, value1);
l1.put(key3, value2);
- LongIntHashMap l2 = new LongIntHashMap(l1);
+ LongFloatHashMap l2 = new LongFloatHashMap(l1);
l2.putAll(l1);
- LongIntHashMap l3 = new LongIntHashMap(l2);
+ LongFloatHashMap l3 = new LongFloatHashMap(l2);
l3.putAll(l2);
l3.put(key4, value0);
@@ -639,18 +633,18 @@ public class TestLongIntHashMap extends LuceneTestCase {
/* */
@Test
public void testEqualsSubClass() {
- class Sub extends LongIntHashMap {}
+ class Sub extends LongFloatHashMap {}
- LongIntHashMap l1 = newInstance();
+ LongFloatHashMap l1 = newInstance();
l1.put(key1, value0);
l1.put(key2, value1);
l1.put(key3, value2);
- LongIntHashMap l2 = new Sub();
+ LongFloatHashMap l2 = new Sub();
l2.putAll(l1);
l2.put(key4, value3);
- LongIntHashMap l3 = new Sub();
+ LongFloatHashMap l3 = new Sub();
l3.putAll(l2);
assertNotEquals(l1, l2);
diff --git a/lucene/core/src/test/org/apache/lucene/util/hppc/TestLongHashSet.java b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestLongHashSet.java
similarity index 99%
rename from lucene/core/src/test/org/apache/lucene/util/hppc/TestLongHashSet.java
rename to lucene/core/src/test/org/apache/lucene/internal/hppc/TestLongHashSet.java
index 4c309cea8e3..71761df5d4e 100644
--- a/lucene/core/src/test/org/apache/lucene/util/hppc/TestLongHashSet.java
+++ b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestLongHashSet.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import static org.hamcrest.Matchers.*;
diff --git a/lucene/core/src/test/org/apache/lucene/util/hppc/TestLongIntHashMap.java b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestLongIntHashMap.java
similarity index 96%
rename from lucene/core/src/test/org/apache/lucene/util/hppc/TestLongIntHashMap.java
rename to lucene/core/src/test/org/apache/lucene/internal/hppc/TestLongIntHashMap.java
index 0d3468c4b5b..ba6f8e58755 100644
--- a/lucene/core/src/test/org/apache/lucene/util/hppc/TestLongIntHashMap.java
+++ b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestLongIntHashMap.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import java.util.Arrays;
@@ -24,7 +24,6 @@ import java.util.HashSet;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.tests.util.LuceneTestCase;
-import org.junit.After;
import org.junit.Test;
/**
@@ -86,23 +85,6 @@ public class TestLongIntHashMap extends LuceneTestCase {
return new LongIntHashMap();
}
- @After
- public void checkEmptySlotsUninitialized() {
- if (map != null) {
- int occupied = 0;
- for (int i = 0; i <= map.mask; i++) {
- if (((map.keys[i]) == 0)) {
-
- } else {
- occupied++;
- }
- }
- assertEquals(occupied, map.assigned);
-
- if (!map.hasEmptyKey) {}
- }
- }
-
/** Convert to target type from an integer used to test stuff. */
private int vcast(int value) {
return value;
@@ -335,10 +317,10 @@ public class TestLongIntHashMap extends LuceneTestCase {
map.put(empty, value1);
assertEquals(1, map.size());
- assertEquals(false, map.isEmpty());
+ assertFalse(map.isEmpty());
assertEquals(value1, map.get(empty));
assertEquals(value1, map.getOrDefault(empty, value2));
- assertEquals(true, map.iterator().hasNext());
+ assertTrue(map.iterator().hasNext());
assertEquals(empty, map.iterator().next().key);
assertEquals(value1, map.iterator().next().value);
@@ -501,8 +483,8 @@ public class TestLongIntHashMap extends LuceneTestCase {
assertEquals(l1.hashCode(), l2.hashCode());
assertEquals(l1, l2);
- assertFalse(l1.equals(l3));
- assertFalse(l2.equals(l3));
+ assertNotEquals(l1, l3);
+ assertNotEquals(l2, l3);
}
@Test
@@ -511,8 +493,8 @@ public class TestLongIntHashMap extends LuceneTestCase {
LongIntHashMap l2 = LongIntHashMap.from(newArray(key2), newvArray(value1));
- assertFalse(l1.equals(l2));
- assertFalse(l2.equals(l1));
+ assertNotEquals(l1, l2);
+ assertNotEquals(l2, l1);
}
/** Runs random insertions/deletions/clearing and compares the results against {@link HashMap}. */
diff --git a/lucene/core/src/test/org/apache/lucene/util/hppc/TestLongObjectHashMap.java b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestLongObjectHashMap.java
similarity index 95%
rename from lucene/core/src/test/org/apache/lucene/util/hppc/TestLongObjectHashMap.java
rename to lucene/core/src/test/org/apache/lucene/internal/hppc/TestLongObjectHashMap.java
index 10b661c258a..f5d6176e24b 100644
--- a/lucene/core/src/test/org/apache/lucene/util/hppc/TestLongObjectHashMap.java
+++ b/lucene/core/src/test/org/apache/lucene/internal/hppc/TestLongObjectHashMap.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.lucene.util.hppc;
+package org.apache.lucene.internal.hppc;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import java.util.Arrays;
@@ -24,7 +24,6 @@ import java.util.HashSet;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.tests.util.LuceneTestCase;
-import org.junit.After;
import org.junit.Test;
/**
@@ -86,23 +85,6 @@ public class TestLongObjectHashMap extends LuceneTestCase {
return new LongObjectHashMap();
}
- @After
- public void checkEmptySlotsUninitialized() {
- if (map != null) {
- int occupied = 0;
- for (int i = 0; i <= map.mask; i++) {
- if (((map.keys[i]) == 0)) {
-
- } else {
- occupied++;
- }
- }
- assertEquals(occupied, map.assigned);
-
- if (!map.hasEmptyKey) {}
- }
- }
-
/** Convert to target type from an integer used to test stuff. */
private int vcast(int value) {
return value;
@@ -325,7 +307,7 @@ public class TestLongObjectHashMap extends LuceneTestCase {
public void testRemove() {
map.put(key1, value1);
assertEquals(value1, map.remove(key1));
- assertEquals(null, map.remove(key1));
+ assertNull(map.remove(key1));
assertEquals(0, map.size());
// These are internals, but perhaps worth asserting too.
@@ -339,15 +321,15 @@ public class TestLongObjectHashMap extends LuceneTestCase {
map.put(empty, value1);
assertEquals(1, map.size());
- assertEquals(false, map.isEmpty());
+ assertFalse(map.isEmpty());
assertEquals(value1, map.get(empty));
assertEquals(value1, map.getOrDefault(empty, value2));
- assertEquals(true, map.iterator().hasNext());
+ assertTrue(map.iterator().hasNext());
assertEquals(empty, map.iterator().next().key);
assertEquals(value1, map.iterator().next().value);
map.remove(empty);
- assertEquals(null, map.get(empty));
+ assertNull(map.get(empty));
assertEquals(0, map.size());
map.put(empty, null);
@@ -360,13 +342,13 @@ public class TestLongObjectHashMap extends LuceneTestCase {
assertFalse(map.containsKey(empty));
assertNull(map.get(empty));
- assertEquals(null, map.put(empty, value1));
+ assertNull(map.put(empty, value1));
assertEquals(value1, map.put(empty, value2));
map.clear();
assertFalse(map.indexExists(map.indexOf(empty)));
- assertEquals(null, map.put(empty, value1));
+ assertNull(map.put(empty, value1));
map.clear();
- assertEquals(null, map.remove(empty));
+ assertNull(map.remove(empty));
}
/* */
@@ -406,8 +388,8 @@ public class TestLongObjectHashMap extends LuceneTestCase {
assertEquals(0, map.assigned);
// Check values are cleared.
- assertEquals(null, map.put(key1, value1));
- assertEquals(null, map.remove(key2));
+ assertNull(map.put(key1, value1));
+ assertNull(map.remove(key2));
map.clear();
// Check if the map behaves properly upon subsequent use.
@@ -515,8 +497,8 @@ public class TestLongObjectHashMap extends LuceneTestCase {
assertEquals(l1.hashCode(), l2.hashCode());
assertEquals(l1, l2);
- assertFalse(l1.equals(l3));
- assertFalse(l2.equals(l3));
+ assertNotEquals(l1, l3);
+ assertNotEquals(l2, l3);
}
@Test
@@ -525,8 +507,8 @@ public class TestLongObjectHashMap extends LuceneTestCase {
LongObjectHashMap l2 = LongObjectHashMap.from(newArray(key2), newvArray(value1));
- assertFalse(l1.equals(l2));
- assertFalse(l2.equals(l1));
+ assertNotEquals(l1, l2);
+ assertNotEquals(l2, l1);
}
/** Runs random insertions/deletions/clearing and compares the results against {@link HashMap}. */
diff --git a/lucene/distribution.tests/src/test/org/apache/lucene/distribution/TestModularLayer.java b/lucene/distribution.tests/src/test/org/apache/lucene/distribution/TestModularLayer.java
index a5b8f6409e9..87d18a169cc 100644
--- a/lucene/distribution.tests/src/test/org/apache/lucene/distribution/TestModularLayer.java
+++ b/lucene/distribution.tests/src/test/org/apache/lucene/distribution/TestModularLayer.java
@@ -116,7 +116,7 @@ public class TestModularLayer extends AbstractLuceneDistributionTest {
public void testExpectedDistributionModuleNames() {
Assertions.assertThat(
allLuceneModules.stream().map(module -> module.descriptor().name()).sorted())
- .containsExactly(
+ .containsOnly(
"org.apache.lucene.analysis.common",
"org.apache.lucene.analysis.icu",
"org.apache.lucene.analysis.kuromoji",
@@ -352,6 +352,9 @@ public class TestModularLayer extends AbstractLuceneDistributionTest {
moduleExports.removeIf(
export -> {
boolean isInternal = export.source().startsWith("org.apache.lucene.internal");
+ if (isInternal && export.source().equals("org.apache.lucene.internal.hppc")) {
+ return true;
+ }
if (isInternal) {
Assertions.assertThat(export.targets())
.containsExactlyInAnyOrder("org.apache.lucene.test_framework");
diff --git a/lucene/facet/build.gradle b/lucene/facet/build.gradle
index 87b1950fcc3..ad7dc4bf864 100644
--- a/lucene/facet/build.gradle
+++ b/lucene/facet/build.gradle
@@ -22,7 +22,6 @@ description = 'Faceted indexing and search capabilities'
dependencies {
moduleApi project(':lucene:core')
- moduleImplementation 'com.carrotsearch:hppc'
moduleTestImplementation project(':lucene:test-framework')
moduleTestImplementation project(':lucene:queries')
diff --git a/lucene/facet/src/java/module-info.java b/lucene/facet/src/java/module-info.java
index b1583142747..2aa1e3e494e 100644
--- a/lucene/facet/src/java/module-info.java
+++ b/lucene/facet/src/java/module-info.java
@@ -16,9 +16,7 @@
*/
/** Faceted indexing and search capabilities */
-@SuppressWarnings({"requires-automatic"})
module org.apache.lucene.facet {
- requires com.carrotsearch.hppc;
requires org.apache.lucene.core;
exports org.apache.lucene.facet;
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/DrillDownQuery.java b/lucene/facet/src/java/org/apache/lucene/facet/DrillDownQuery.java
index d0120d47ec8..6f3b1d572d3 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/DrillDownQuery.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/DrillDownQuery.java
@@ -23,6 +23,8 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.lucene.index.Term;
+import org.apache.lucene.internal.hppc.IntCursor;
+import org.apache.lucene.internal.hppc.IntHashSet;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.BoostQuery;
@@ -31,8 +33,6 @@ import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryVisitor;
import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.util.hppc.IntCursor;
-import org.apache.lucene.util.hppc.IntHashSet;
/**
* A {@link Query} for drill-down over facet categories. You should call {@link #add(String,
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/LongValueFacetCounts.java b/lucene/facet/src/java/org/apache/lucene/facet/LongValueFacetCounts.java
index a8d9411ccda..7936babb736 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/LongValueFacetCounts.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/LongValueFacetCounts.java
@@ -17,8 +17,6 @@
package org.apache.lucene.facet;
-import com.carrotsearch.hppc.LongIntHashMap;
-import com.carrotsearch.hppc.cursors.LongIntCursor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -30,6 +28,7 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.SortedNumericDocValues;
+import org.apache.lucene.internal.hppc.LongIntHashMap;
import org.apache.lucene.search.ConjunctionUtils;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.LongValues;
@@ -391,7 +390,7 @@ public class LongValueFacetCounts extends Facets {
}
}
if (hashCounts.size() != 0) {
- for (LongIntCursor c : hashCounts) {
+ for (LongIntHashMap.LongIntCursor c : hashCounts) {
int count = c.value;
if (count != 0) {
labelValues.add(new LabelAndValue(Long.toString(c.key), c.value));
@@ -459,7 +458,7 @@ public class LongValueFacetCounts extends Facets {
if (hashCounts.size() != 0) {
childCount += hashCounts.size();
- for (LongIntCursor c : hashCounts) {
+ for (LongIntHashMap.LongIntCursor c : hashCounts) {
int count = c.value;
if (count != 0) {
if (e == null) {
@@ -503,7 +502,7 @@ public class LongValueFacetCounts extends Facets {
long[] hashValues = new long[this.hashCounts.size()];
int upto = 0;
- for (LongIntCursor c : this.hashCounts) {
+ for (LongIntHashMap.LongIntCursor c : this.hashCounts) {
if (c.value != 0) {
hashCounts[upto] = c.value;
hashValues[upto] = c.key;
@@ -602,7 +601,7 @@ public class LongValueFacetCounts extends Facets {
}
if (hashCounts.size() != 0) {
- for (LongIntCursor c : hashCounts) {
+ for (LongIntHashMap.LongIntCursor c : hashCounts) {
if (c.value != 0) {
b.append(" ");
b.append(c.key);
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/StringValueFacetCounts.java b/lucene/facet/src/java/org/apache/lucene/facet/StringValueFacetCounts.java
index 9b1435bc316..2992342ecff 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/StringValueFacetCounts.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/StringValueFacetCounts.java
@@ -16,8 +16,6 @@
*/
package org.apache.lucene.facet;
-import com.carrotsearch.hppc.IntIntHashMap;
-import com.carrotsearch.hppc.cursors.IntIntCursor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -31,6 +29,7 @@ import org.apache.lucene.index.OrdinalMap;
import org.apache.lucene.index.ReaderUtil;
import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.index.SortedSetDocValues;
+import org.apache.lucene.internal.hppc.IntIntHashMap;
import org.apache.lucene.search.ConjunctionUtils;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.MatchAllDocsQuery;
@@ -150,7 +149,7 @@ public class StringValueFacetCounts extends Facets {
List<LabelAndValue> labelValues = new ArrayList<>();
if (sparseCounts != null) {
- for (IntIntCursor sparseCount : sparseCounts) {
+ for (IntIntHashMap.IntIntCursor sparseCount : sparseCounts) {
int count = sparseCount.value;
final BytesRef term = docValues.lookupOrd(sparseCount.key);
labelValues.add(new LabelAndValue(term.utf8ToString(), count));
@@ -186,7 +185,7 @@ public class StringValueFacetCounts extends Facets {
int childCount = 0; // total number of labels with non-zero count
if (sparseCounts != null) {
- for (IntIntCursor sparseCount : sparseCounts) {
+ for (IntIntHashMap.IntIntCursor sparseCount : sparseCounts) {
childCount++; // every count in sparseValues should be non-zero
int ord = sparseCount.key;
int count = sparseCount.value;
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/range/OverlappingLongRangeCounter.java b/lucene/facet/src/java/org/apache/lucene/facet/range/OverlappingLongRangeCounter.java
index 9c09f29841f..c980eff0dd6 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/range/OverlappingLongRangeCounter.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/range/OverlappingLongRangeCounter.java
@@ -16,13 +16,13 @@
*/
package org.apache.lucene.facet.range;
-import com.carrotsearch.hppc.IntArrayList;
-import com.carrotsearch.hppc.LongArrayList;
-import com.carrotsearch.hppc.LongIntHashMap;
-import com.carrotsearch.hppc.cursors.IntCursor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.apache.lucene.internal.hppc.IntArrayList;
+import org.apache.lucene.internal.hppc.IntCursor;
+import org.apache.lucene.internal.hppc.LongArrayList;
+import org.apache.lucene.internal.hppc.LongIntHashMap;
import org.apache.lucene.util.FixedBitSet;
/**
@@ -260,7 +260,8 @@ class OverlappingLongRangeCounter extends LongRangeCounter {
}
}
- LongArrayList endsList = new LongArrayList(endsMap.keys());
+ LongArrayList endsList = new LongArrayList(endsMap.size());
+ endsList.addAll(endsMap.keys());
Arrays.sort(endsList.buffer, 0, endsList.size());
// Build elementaryIntervals (a 1D Venn diagram):
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FloatTaxonomyFacets.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FloatTaxonomyFacets.java
index 469606f13b1..82fa3c2bd77 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FloatTaxonomyFacets.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FloatTaxonomyFacets.java
@@ -16,12 +16,12 @@
*/
package org.apache.lucene.facet.taxonomy;
-import com.carrotsearch.hppc.IntFloatHashMap;
import java.io.IOException;
import org.apache.lucene.facet.FacetsCollector;
import org.apache.lucene.facet.FacetsConfig;
import org.apache.lucene.facet.TopOrdAndFloatNumberQueue;
import org.apache.lucene.facet.TopOrdAndNumberQueue;
+import org.apache.lucene.internal.hppc.IntFloatHashMap;
/**
* Base class for all taxonomy-based facets that aggregate to a per-ords float[].
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/IntTaxonomyFacets.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/IntTaxonomyFacets.java
index 1da39eb335d..dda87078cf8 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/IntTaxonomyFacets.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/IntTaxonomyFacets.java
@@ -16,13 +16,13 @@
*/
package org.apache.lucene.facet.taxonomy;
-import com.carrotsearch.hppc.IntIntHashMap;
import java.io.IOException;
import java.util.Comparator;
import org.apache.lucene.facet.FacetsCollector;
import org.apache.lucene.facet.FacetsConfig;
import org.apache.lucene.facet.TopOrdAndIntNumberQueue;
import org.apache.lucene.facet.TopOrdAndNumberQueue;
+import org.apache.lucene.internal.hppc.IntIntHashMap;
/**
* Base class for all taxonomy-based facets that aggregate to a per-ords int[].
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/OrdinalMappingLeafReader.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/OrdinalMappingLeafReader.java
index 0b6912eb3e2..f9810d414e5 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/OrdinalMappingLeafReader.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/OrdinalMappingLeafReader.java
@@ -16,7 +16,6 @@
*/
package org.apache.lucene.facet.taxonomy;
-import com.carrotsearch.hppc.IntArrayList;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
@@ -31,6 +30,7 @@ import org.apache.lucene.index.FilterLeafReader;
import org.apache.lucene.index.FilterSortedNumericDocValues;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.SortedNumericDocValues;
+import org.apache.lucene.internal.hppc.IntArrayList;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IntsRef;
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacets.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacets.java
index ef4aeda1c0e..0d5d93c9512 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacets.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacets.java
@@ -17,9 +17,6 @@
package org.apache.lucene.facet.taxonomy;
-import com.carrotsearch.hppc.IntArrayList;
-import com.carrotsearch.hppc.IntIntHashMap;
-import com.carrotsearch.hppc.cursors.IntIntCursor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -38,6 +35,8 @@ import org.apache.lucene.facet.LabelAndValue;
import org.apache.lucene.facet.TopOrdAndFloatNumberQueue;
import org.apache.lucene.facet.TopOrdAndIntNumberQueue;
import org.apache.lucene.facet.TopOrdAndNumberQueue;
+import org.apache.lucene.internal.hppc.IntArrayList;
+import org.apache.lucene.internal.hppc.IntIntHashMap;
import org.apache.lucene.util.PriorityQueue;
/**
@@ -407,7 +406,7 @@ public abstract class TaxonomyFacets extends Facets {
List<Number> ordValues = new ArrayList<>();
if (sparseCounts != null) {
- for (IntIntCursor ordAndCount : sparseCounts) {
+ for (IntIntHashMap.IntIntCursor ordAndCount : sparseCounts) {
int ord = ordAndCount.key;
int count = ordAndCount.value;
Number value = getAggregationValue(ord);
@@ -533,7 +532,7 @@ public abstract class TaxonomyFacets extends Facets {
// TODO: would be faster if we had a "get the following children" API? then we
// can make a single pass over the hashmap
if (sparseCounts != null) {
- for (IntIntCursor c : sparseCounts) {
+ for (IntIntHashMap.IntIntCursor c : sparseCounts) {
int ord = c.key;
int count = c.value;
if (parents.get(ord) == pathOrd && count > 0) {
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java
index 0b0ea71a58a..d4f8cd5c696 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java
@@ -16,8 +16,6 @@
*/
package org.apache.lucene.facet.taxonomy.directory;
-import com.carrotsearch.hppc.IntArrayList;
-import com.carrotsearch.hppc.cursors.IntCursor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -42,6 +40,8 @@ import org.apache.lucene.index.MultiTerms;
import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.index.ReaderUtil;
import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.internal.hppc.IntArrayList;
+import org.apache.lucene.internal.hppc.IntCursor;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.Accountable;
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/TaxonomyIndexArrays.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/TaxonomyIndexArrays.java
index 88cde1cd279..e8caa405d7d 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/TaxonomyIndexArrays.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/TaxonomyIndexArrays.java
@@ -16,7 +16,6 @@
*/
package org.apache.lucene.facet.taxonomy.directory;
-import com.carrotsearch.hppc.IntHashSet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -30,6 +29,7 @@ import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.MultiTerms;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.PostingsEnum;
+import org.apache.lucene.internal.hppc.IntHashSet;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.Accountables;
diff --git a/lucene/grouping/src/java/org/apache/lucene/search/grouping/TermGroupSelector.java b/lucene/grouping/src/java/org/apache/lucene/search/grouping/TermGroupSelector.java
index 2d3677ef1df..9a96ec89808 100644
--- a/lucene/grouping/src/java/org/apache/lucene/search/grouping/TermGroupSelector.java
+++ b/lucene/grouping/src/java/org/apache/lucene/search/grouping/TermGroupSelector.java
@@ -22,10 +22,10 @@ import java.util.Collection;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.SortedDocValues;
+import org.apache.lucene.internal.hppc.IntIntHashMap;
import org.apache.lucene.search.Scorable;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefHash;
-import org.apache.lucene.util.hppc.IntIntHashMap;
/** A GroupSelector implementation that groups via SortedDocValues */
public class TermGroupSelector extends GroupSelector<BytesRef> {
diff --git a/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/SimpleBoundaryScanner.java b/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/SimpleBoundaryScanner.java
index b46d7a5d08d..a2fa030d15e 100644
--- a/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/SimpleBoundaryScanner.java
+++ b/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/SimpleBoundaryScanner.java
@@ -18,7 +18,7 @@ package org.apache.lucene.search.vectorhighlight;
import java.util.Iterator;
import java.util.Set;
-import org.apache.lucene.util.hppc.CharHashSet;
+import org.apache.lucene.internal.hppc.CharHashSet;
/**
* Simple boundary scanner implementation that divides fragments based on a set of separator
diff --git a/lucene/join/build.gradle b/lucene/join/build.gradle
index 5cf8f80bb79..6ed9da28e3d 100644
--- a/lucene/join/build.gradle
+++ b/lucene/join/build.gradle
@@ -21,7 +21,6 @@ description = 'Index-time and Query-time joins for normalized content'
dependencies {
moduleApi project(':lucene:core')
- moduleImplementation 'com.carrotsearch:hppc'
moduleTestImplementation project(':lucene:test-framework')
}
\ No newline at end of file
diff --git a/lucene/join/src/java/module-info.java b/lucene/join/src/java/module-info.java
index 9ab3c8152dd..80d2261b5a5 100644
--- a/lucene/join/src/java/module-info.java
+++ b/lucene/join/src/java/module-info.java
@@ -16,10 +16,8 @@
*/
/** Index-time and Query-time joins for normalized content */
-@SuppressWarnings({"requires-automatic"})
module org.apache.lucene.join {
requires org.apache.lucene.core;
- requires com.carrotsearch.hppc;
exports org.apache.lucene.search.join;
}
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/DiversifyingNearestChildrenKnnCollector.java b/lucene/join/src/java/org/apache/lucene/search/join/DiversifyingNearestChildrenKnnCollector.java
index f79958e812b..afab8ac57d9 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/DiversifyingNearestChildrenKnnCollector.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/DiversifyingNearestChildrenKnnCollector.java
@@ -17,7 +17,7 @@
package org.apache.lucene.search.join;
-import com.carrotsearch.hppc.IntIntHashMap;
+import org.apache.lucene.internal.hppc.IntIntHashMap;
import org.apache.lucene.search.AbstractKnnCollector;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopDocs;
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/JoinUtil.java b/lucene/join/src/java/org/apache/lucene/search/join/JoinUtil.java
index cc5faa1e283..80f77cc912e 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/JoinUtil.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/JoinUtil.java
@@ -16,12 +16,6 @@
*/
package org.apache.lucene.search.join;
-import com.carrotsearch.hppc.LongArrayList;
-import com.carrotsearch.hppc.LongFloatHashMap;
-import com.carrotsearch.hppc.LongHashSet;
-import com.carrotsearch.hppc.LongIntHashMap;
-import com.carrotsearch.hppc.cursors.LongCursor;
-import com.carrotsearch.hppc.procedures.LongFloatProcedure;
import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
@@ -39,6 +33,11 @@ import org.apache.lucene.index.OrdinalMap;
import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.index.SortedNumericDocValues;
import org.apache.lucene.index.SortedSetDocValues;
+import org.apache.lucene.internal.hppc.LongArrayList;
+import org.apache.lucene.internal.hppc.LongCursor;
+import org.apache.lucene.internal.hppc.LongFloatHashMap;
+import org.apache.lucene.internal.hppc.LongHashSet;
+import org.apache.lucene.internal.hppc.LongIntHashMap;
import org.apache.lucene.search.Collector;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchNoDocsQuery;
@@ -292,7 +291,8 @@ public final class JoinUtil {
}
fromSearcher.search(fromQuery, collector);
- LongArrayList joinValuesList = new LongArrayList(joinValues);
+ LongArrayList joinValuesList = new LongArrayList(joinValues.size());
+ joinValuesList.addAll(joinValues);
Arrays.sort(joinValuesList.buffer, 0, joinValuesList.size());
Iterator<LongCursor> iterator = joinValuesList.iterator();
@@ -588,4 +588,10 @@ public final class JoinUtil {
float apply(long value);
}
+
+ /** Similar to {@link java.util.function.BiConsumer} for primitive arguments. */
+ private interface LongFloatProcedure {
+
+ void apply(long key, float value);
+ }
}
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/PointInSetIncludingScoreQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/PointInSetIncludingScoreQuery.java
index 1cdf62920de..51026f38fa3 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/PointInSetIncludingScoreQuery.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/PointInSetIncludingScoreQuery.java
@@ -17,8 +17,6 @@
package org.apache.lucene.search.join;
-import com.carrotsearch.hppc.FloatArrayList;
-import com.carrotsearch.hppc.cursors.FloatCursor;
import java.io.IOException;
import java.util.Iterator;
import java.util.function.BiFunction;
@@ -34,6 +32,8 @@ import org.apache.lucene.index.PointValues.IntersectVisitor;
import org.apache.lucene.index.PointValues.Relation;
import org.apache.lucene.index.PrefixCodedTerms;
import org.apache.lucene.index.PrefixCodedTerms.TermIterator;
+import org.apache.lucene.internal.hppc.FloatArrayList;
+import org.apache.lucene.internal.hppc.FloatCursor;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.IndexSearcher;
diff --git a/lucene/licenses/hppc-0.9.1.jar.sha1 b/lucene/licenses/hppc-0.9.1.jar.sha1
deleted file mode 100644
index 5cedaaa6433..00000000000
--- a/lucene/licenses/hppc-0.9.1.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-4bf4c51e06aec600894d841c4c004566b20dd357
diff --git a/lucene/licenses/hppc-LICENSE-ASL.txt b/lucene/licenses/hppc-LICENSE-ASL.txt
deleted file mode 100644
index f433b1a53f5..00000000000
--- a/lucene/licenses/hppc-LICENSE-ASL.txt
+++ /dev/null
@@ -1,177 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
diff --git a/lucene/licenses/hppc-NOTICE.txt b/lucene/licenses/hppc-NOTICE.txt
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/lucene/misc/src/java/org/apache/lucene/misc/document/LazyDocument.java b/lucene/misc/src/java/org/apache/lucene/misc/document/LazyDocument.java
index b6818d5e72a..f09989c0294 100644
--- a/lucene/misc/src/java/org/apache/lucene/misc/document/LazyDocument.java
+++ b/lucene/misc/src/java/org/apache/lucene/misc/document/LazyDocument.java
@@ -31,8 +31,8 @@ import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.IndexableFieldType;
+import org.apache.lucene.internal.hppc.IntObjectHashMap;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.hppc.IntObjectHashMap;
/**
* Defers actually loading a field's value until you ask for it. You must not use the returned Field
diff --git a/lucene/misc/src/java/org/apache/lucene/misc/search/DiversifiedTopDocsCollector.java b/lucene/misc/src/java/org/apache/lucene/misc/search/DiversifiedTopDocsCollector.java
index e7a24964c96..1aaa6937051 100644
--- a/lucene/misc/src/java/org/apache/lucene/misc/search/DiversifiedTopDocsCollector.java
+++ b/lucene/misc/src/java/org/apache/lucene/misc/search/DiversifiedTopDocsCollector.java
@@ -21,6 +21,7 @@ import java.util.ArrayDeque;
import java.util.Deque;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.NumericDocValues;
+import org.apache.lucene.internal.hppc.LongObjectHashMap;
import org.apache.lucene.misc.search.DiversifiedTopDocsCollector.ScoreDocKey;
import org.apache.lucene.search.LeafCollector;
import org.apache.lucene.search.Scorable;
@@ -30,7 +31,6 @@ import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.TopDocsCollector;
import org.apache.lucene.search.TotalHits;
import org.apache.lucene.util.PriorityQueue;
-import org.apache.lucene.util.hppc.LongObjectHashMap;
/**
* A {@link TopDocsCollector} that controls diversity in results by ensuring no more than
diff --git a/lucene/queryparser/src/generated/checksums/javaccParserClassic.json b/lucene/queryparser/src/generated/checksums/javaccParserClassic.json
index eeb0d527027..0659521cdcf 100644
--- a/lucene/queryparser/src/generated/checksums/javaccParserClassic.json
+++ b/lucene/queryparser/src/generated/checksums/javaccParserClassic.json
@@ -1,7 +1,7 @@
{
"lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/ParseException.java": "7a8a8fd5b2ea78f9a17f54cbae8b0e4496e8988e",
- "lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java": "380daae0f6e27b3872d117fc4aef955b1e4296ca",
- "lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.jj": "968452b64449655b035fffb45944086c3032732b",
+ "lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java": "a2b7d21092d21cbac290cb1ddde5ac161824fb83",
+ "lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.jj": "ed9f248e1a48cadeeab8f0a79e77e986e34ff721",
"lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserConstants.java": "e59a3fd38b66a3d56779c55955c1e014225a1f50",
"lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.java": "dc99a1083bfa50e429d40e114fabe7dd5d434693",
"lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/Token.java": "310665ba37d982327fcb55cc3523d629ef29ef54",
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java
index 9299377a908..d390894170e 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java
@@ -14,7 +14,7 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermRangeQuery;
import org.apache.lucene.queryparser.charstream.CharStream;
import org.apache.lucene.queryparser.charstream.FastCharStream;
-import org.apache.lucene.util.hppc.IntHashSet;
+import org.apache.lucene.internal.hppc.IntHashSet;
/**
* This class is generated by JavaCC. The most important method is
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.jj b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.jj
index af558d556ca..2a67dcd68ec 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.jj
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.jj
@@ -37,7 +37,7 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermRangeQuery;
import org.apache.lucene.queryparser.charstream.CharStream;
import org.apache.lucene.queryparser.charstream.FastCharStream;
-import org.apache.lucene.util.hppc.IntHashSet;
+import org.apache.lucene.internal.hppc.IntHashSet;
/**
* This class is generated by JavaCC. The most important method is
diff --git a/lucene/sandbox/src/java/org/apache/lucene/sandbox/document/FloatPointNearestNeighbor.java b/lucene/sandbox/src/java/org/apache/lucene/sandbox/document/FloatPointNearestNeighbor.java
index 3f0ced4f520..bb18ecc1bcb 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/sandbox/document/FloatPointNearestNeighbor.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/sandbox/document/FloatPointNearestNeighbor.java
@@ -25,13 +25,13 @@ import org.apache.lucene.document.FloatPoint;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.PointValues;
import org.apache.lucene.index.PointValues.PointTree;
+import org.apache.lucene.internal.hppc.IntArrayList;
import org.apache.lucene.search.FieldDoc;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopFieldDocs;
import org.apache.lucene.search.TotalHits;
import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.hppc.IntArrayList;
/**
* KNN search on top of N dimensional indexed float points.
diff --git a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/LatLonPointPrototypeQueries.java b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/LatLonPointPrototypeQueries.java
index 712a0fd2842..1bb151e62e0 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/LatLonPointPrototypeQueries.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/LatLonPointPrototypeQueries.java
@@ -25,6 +25,7 @@ import org.apache.lucene.document.LatLonPoint;
import org.apache.lucene.geo.GeoUtils;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.PointValues;
+import org.apache.lucene.internal.hppc.IntArrayList;
import org.apache.lucene.search.FieldDoc;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
@@ -33,7 +34,6 @@ import org.apache.lucene.search.TopFieldDocs;
import org.apache.lucene.search.TotalHits;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.SloppyMath;
-import org.apache.lucene.util.hppc.IntArrayList;
/**
* Holder class for prototype sandboxed queries
diff --git a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/NearestNeighbor.java b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/NearestNeighbor.java
index c35a16e97a2..51ba7667981 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/NearestNeighbor.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/NearestNeighbor.java
@@ -28,9 +28,9 @@ import org.apache.lucene.index.PointValues;
import org.apache.lucene.index.PointValues.IntersectVisitor;
import org.apache.lucene.index.PointValues.PointTree;
import org.apache.lucene.index.PointValues.Relation;
+import org.apache.lucene.internal.hppc.IntArrayList;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.SloppyMath;
-import org.apache.lucene.util.hppc.IntArrayList;
/**
* KNN search on top of 2D lat/lon indexed points.
diff --git a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/QueryProfilerTree.java b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/QueryProfilerTree.java
index 1044b0aa44c..83335e5334b 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/QueryProfilerTree.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/QueryProfilerTree.java
@@ -22,9 +22,9 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Deque;
import java.util.List;
+import org.apache.lucene.internal.hppc.IntArrayList;
+import org.apache.lucene.internal.hppc.IntCursor;
import org.apache.lucene.search.Query;
-import org.apache.lucene.util.hppc.IntArrayList;
-import org.apache.lucene.util.hppc.IntCursor;
/**
* This class tracks the dependency tree for queries (scoring and rewriting) and generates {@link
diff --git a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/TermAutomatonQuery.java b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/TermAutomatonQuery.java
index bce315613a8..4894c4be105 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/TermAutomatonQuery.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/TermAutomatonQuery.java
@@ -30,6 +30,7 @@ import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermState;
import org.apache.lucene.index.TermStates;
import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.internal.hppc.IntObjectHashMap;
import org.apache.lucene.queries.spans.SpanNearQuery;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.Explanation;
@@ -53,7 +54,6 @@ import org.apache.lucene.util.RamUsageEstimator;
import org.apache.lucene.util.automaton.Automaton;
import org.apache.lucene.util.automaton.Operations;
import org.apache.lucene.util.automaton.Transition;
-import org.apache.lucene.util.hppc.IntObjectHashMap;
// TODO
// - compare perf to PhraseQuery exact and sloppy
diff --git a/lucene/spatial-extras/build.gradle b/lucene/spatial-extras/build.gradle
index 7ba6648eede..baa772f3053 100644
--- a/lucene/spatial-extras/build.gradle
+++ b/lucene/spatial-extras/build.gradle
@@ -30,8 +30,6 @@ dependencies {
moduleApi 'org.locationtech.spatial4j:spatial4j'
moduleApi 'io.sgr:s2-geometry-library-java'
- moduleImplementation 'com.carrotsearch:hppc'
-
moduleTestImplementation project(':lucene:test-framework')
moduleTestImplementation project(':lucene:spatial-test-fixtures')
moduleTestImplementation 'org.locationtech.jts:jts-core'
diff --git a/lucene/spatial-extras/src/java/module-info.java b/lucene/spatial-extras/src/java/module-info.java
index 608684764fd..30fb97668ef 100644
--- a/lucene/spatial-extras/src/java/module-info.java
+++ b/lucene/spatial-extras/src/java/module-info.java
@@ -20,7 +20,6 @@
module org.apache.lucene.spatial_extras {
requires spatial4j;
requires s2.geometry.library.java;
- requires com.carrotsearch.hppc;
requires org.apache.lucene.core;
requires org.apache.lucene.spatial3d;
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/util/CachingDoubleValueSource.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/util/CachingDoubleValueSource.java
index 234efc45de5..223ef2bfd9e 100644
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/util/CachingDoubleValueSource.java
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/util/CachingDoubleValueSource.java
@@ -16,9 +16,9 @@
*/
package org.apache.lucene.spatial.util;
-import com.carrotsearch.hppc.IntDoubleHashMap;
import java.io.IOException;
import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.internal.hppc.IntDoubleHashMap;
import org.apache.lucene.search.DoubleValues;
import org.apache.lucene.search.DoubleValuesSource;
import org.apache.lucene.search.Explanation;
diff --git a/lucene/spatial3d/build.gradle b/lucene/spatial3d/build.gradle
index 184c39cd4bb..f7e3618bef5 100644
--- a/lucene/spatial3d/build.gradle
+++ b/lucene/spatial3d/build.gradle
@@ -22,8 +22,6 @@ description = '3D spatial planar geometry APIs'
dependencies {
moduleApi project(':lucene:core')
- moduleImplementation 'com.carrotsearch:hppc'
-
moduleTestImplementation project(':lucene:test-framework')
// We have to exclude ourselves because spatial-test-fixtures depend
diff --git a/lucene/spatial3d/src/java/module-info.java b/lucene/spatial3d/src/java/module-info.java
index 7fd67a03b55..9bffb23a468 100644
--- a/lucene/spatial3d/src/java/module-info.java
+++ b/lucene/spatial3d/src/java/module-info.java
@@ -16,10 +16,8 @@
*/
/** 3D spatial planar geometry APIs */
-@SuppressWarnings({"requires-automatic"})
module org.apache.lucene.spatial3d {
requires org.apache.lucene.core;
- requires com.carrotsearch.hppc;
exports org.apache.lucene.spatial3d;
exports org.apache.lucene.spatial3d.geom;
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
index e100b51563d..5611662f300 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
@@ -16,7 +16,6 @@
*/
package org.apache.lucene.spatial3d.geom;
-import com.carrotsearch.hppc.IntArrayList;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -25,6 +24,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import org.apache.lucene.internal.hppc.IntArrayList;
/**
* GeoShape representing a path across the surface of the globe, with a specified half-width. Path
@@ -1989,9 +1989,9 @@ class GeoStandardPath extends GeoBasePath {
}
private void mergeTop() {
- depthStack.remove(depthStack.size() - 1);
+ depthStack.removeAt(depthStack.size() - 1);
PathComponent secondComponent = componentStack.remove(componentStack.size() - 1);
- int newDepth = depthStack.remove(depthStack.size() - 1) + 1;
+ int newDepth = depthStack.removeAt(depthStack.size() - 1) + 1;
PathComponent firstComponent = componentStack.remove(componentStack.size() - 1);
depthStack.add(newDepth);
componentStack.add(new PathNode(firstComponent, secondComponent));
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardObjects.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardObjects.java
index 22e949bbd97..d9efdecb4ff 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardObjects.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardObjects.java
@@ -17,9 +17,9 @@
package org.apache.lucene.spatial3d.geom;
-import com.carrotsearch.hppc.IntObjectHashMap;
import java.util.HashMap;
import java.util.Map;
+import org.apache.lucene.internal.hppc.IntObjectHashMap;
/**
* Lookup tables for classes that can be serialized using a code.
diff --git a/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/ContextQuery.java b/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/ContextQuery.java
index 999cf97832e..c727b1e621c 100644
--- a/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/ContextQuery.java
+++ b/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/ContextQuery.java
@@ -21,6 +21,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.apache.lucene.analysis.miscellaneous.ConcatenateGraphFilter;
+import org.apache.lucene.internal.hppc.IntHashSet;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.QueryVisitor;
import org.apache.lucene.search.ScoreMode;
@@ -36,7 +37,6 @@ import org.apache.lucene.util.automaton.Automata;
import org.apache.lucene.util.automaton.Automaton;
import org.apache.lucene.util.automaton.Operations;
import org.apache.lucene.util.fst.Util;
-import org.apache.lucene.util.hppc.IntHashSet;
/**
* A {@link CompletionQuery} that matches documents specified by a wrapped {@link CompletionQuery}
diff --git a/versions.lock b/versions.lock
index 184dbee2c89..db1c3154cff 100644
--- a/versions.lock
+++ b/versions.lock
@@ -1,5 +1,4 @@
# Run ./gradlew --write-locks to regenerate this file
-com.carrotsearch:hppc:0.9.1 (1 constraints: 0c050736)
com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.8.1 (1 constraints: 0d050e36)
com.ibm.icu:icu4j:74.2 (1 constraints: e1041731)
commons-codec:commons-codec:1.13 (1 constraints: d904f430)
diff --git a/versions.props b/versions.props
index 764b7972c8e..35d91f79471 100644
--- a/versions.props
+++ b/versions.props
@@ -1,5 +1,4 @@
com.carrotsearch.randomizedtesting:*=2.8.1
-com.carrotsearch:hppc=0.9.1
com.carrotsearch:procfork=1.0.6
com.google.errorprone:*=2.18.0
com.ibm.icu:icu4j=74.2