java.lang.Object
org.apache.lucene.util.DocIdSetBuilder
A builder of
DocIdSets. At first it uses a sparse structure to gather documents, and then
upgrades to a non-sparse bit set once enough hits match.
To add documents, you first need to call grow(int) in order to reserve space, and then
call DocIdSetBuilder.BulkAdder.add(int) on the returned DocIdSetBuilder.BulkAdder.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static classstatic classUtility class to efficiently add many docs in one go.private static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DocIdSetBuilder.BulkAdderprivate FixedBitSetprivate List<DocIdSetBuilder.Buffer> private longprivate final int(package private) final boolean(package private) final doubleprivate final intprivate int -
Constructor Summary
ConstructorsConstructorDescriptionDocIdSetBuilder(int maxDoc) Create a builder that can contain doc IDs between0andmaxDoc.DocIdSetBuilder(int maxDoc, int docCount, long valueCount) DocIdSetBuilder(int maxDoc, PointValues values, String field) Create aDocIdSetBuilderinstance that is optimized for accumulating docs that match the givenPointValues.DocIdSetBuilder(int maxDoc, Terms terms) Create aDocIdSetBuilderinstance that is optimized for accumulating docs that match the givenTerms. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(DocIdSetIterator iter) Add the content of the providedDocIdSetIteratorto this builder.private DocIdSetBuilder.BufferaddBuffer(int len) private intadditionalCapacity(int numDocs) build()Build aDocIdSetfrom the accumulated doc IDs.private static DocIdSetBuilder.Bufferconcat(List<DocIdSetBuilder.Buffer> buffers) Concatenate the buffers in any order, leaving at least one empty slot in the end NOTE: this method might reuse one of the arraysprivate static intdedup(int[] arr, int length) private voidensureBufferCapacity(int numDocs) grow(int numDocs) Reserve space and return aDocIdSetBuilder.BulkAdderobject that can be used to add up tonumDocsdocuments.private voidgrowBuffer(DocIdSetBuilder.Buffer buffer, int additionalCapacity) private static booleannoDups(int[] a, int len) private void
-
Field Details
-
maxDoc
private final int maxDoc -
threshold
private final int threshold -
multivalued
final boolean multivalued -
numValuesPerDoc
final double numValuesPerDoc -
buffers
-
totalAllocated
private int totalAllocated -
bitSet
-
counter
private long counter -
adder
-
-
Constructor Details
-
DocIdSetBuilder
public DocIdSetBuilder(int maxDoc) Create a builder that can contain doc IDs between0andmaxDoc. -
DocIdSetBuilder
Create aDocIdSetBuilderinstance that is optimized for accumulating docs that match the givenTerms.- Throws:
IOException
-
DocIdSetBuilder
Create aDocIdSetBuilderinstance that is optimized for accumulating docs that match the givenPointValues.- Throws:
IOException
-
DocIdSetBuilder
DocIdSetBuilder(int maxDoc, int docCount, long valueCount)
-
-
Method Details
-
add
Add the content of the providedDocIdSetIteratorto this builder. NOTE: if you need to build aDocIdSetout of a singleDocIdSetIterator, you should rather useRoaringDocIdSet.Builder.- Throws:
IOException
-
grow
Reserve space and return aDocIdSetBuilder.BulkAdderobject that can be used to add up tonumDocsdocuments. -
ensureBufferCapacity
private void ensureBufferCapacity(int numDocs) -
additionalCapacity
private int additionalCapacity(int numDocs) -
addBuffer
-
growBuffer
-
upgradeToBitSet
private void upgradeToBitSet() -
build
Build aDocIdSetfrom the accumulated doc IDs. -
concat
Concatenate the buffers in any order, leaving at least one empty slot in the end NOTE: this method might reuse one of the arrays -
dedup
private static int dedup(int[] arr, int length) -
noDups
private static boolean noDups(int[] a, int len)
-