public final class DocIdSetBuilder
extends java.lang.Object
DocIdSet
s. 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
.Modifier and Type | Class and Description |
---|---|
private static class |
DocIdSetBuilder.Buffer |
private static class |
DocIdSetBuilder.BufferAdder |
static class |
DocIdSetBuilder.BulkAdder
Utility class to efficiently add many docs in one go.
|
private static class |
DocIdSetBuilder.FixedBitSetAdder |
Modifier and Type | Field and Description |
---|---|
private DocIdSetBuilder.BulkAdder |
adder |
private FixedBitSet |
bitSet |
private java.util.List<DocIdSetBuilder.Buffer> |
buffers |
private long |
counter |
private int |
maxDoc |
(package private) boolean |
multivalued |
(package private) double |
numValuesPerDoc |
private int |
threshold |
private int |
totalAllocated |
Constructor and Description |
---|
DocIdSetBuilder(int maxDoc)
Create a builder that can contain doc IDs between
0 and maxDoc . |
DocIdSetBuilder(int maxDoc,
int docCount,
long valueCount) |
DocIdSetBuilder(int maxDoc,
PointValues values,
java.lang.String field)
Create a
DocIdSetBuilder instance that is optimized for
accumulating docs that match the given PointValues . |
DocIdSetBuilder(int maxDoc,
Terms terms)
Create a
DocIdSetBuilder instance that is optimized for
accumulating docs that match the given Terms . |
Modifier and Type | Method and Description |
---|---|
void |
add(DocIdSetIterator iter)
Add the content of the provided
DocIdSetIterator to this builder. |
private DocIdSetBuilder.Buffer |
addBuffer(int len) |
private int |
additionalCapacity(int numDocs) |
DocIdSet |
build()
Build a
DocIdSet from the accumulated doc IDs. |
private static DocIdSetBuilder.Buffer |
concat(java.util.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 arrays
|
private static int |
dedup(int[] arr,
int length) |
private void |
ensureBufferCapacity(int numDocs) |
DocIdSetBuilder.BulkAdder |
grow(int numDocs)
Reserve space and return a
DocIdSetBuilder.BulkAdder object that can be used to
add up to numDocs documents. |
private void |
growBuffer(DocIdSetBuilder.Buffer buffer,
int additionalCapacity) |
private static boolean |
noDups(int[] a,
int len) |
private void |
upgradeToBitSet() |
private final int maxDoc
private final int threshold
final boolean multivalued
final double numValuesPerDoc
private java.util.List<DocIdSetBuilder.Buffer> buffers
private int totalAllocated
private FixedBitSet bitSet
private long counter
private DocIdSetBuilder.BulkAdder adder
public DocIdSetBuilder(int maxDoc)
0
and maxDoc
.public DocIdSetBuilder(int maxDoc, Terms terms) throws java.io.IOException
DocIdSetBuilder
instance that is optimized for
accumulating docs that match the given Terms
.java.io.IOException
public DocIdSetBuilder(int maxDoc, PointValues values, java.lang.String field) throws java.io.IOException
DocIdSetBuilder
instance that is optimized for
accumulating docs that match the given PointValues
.java.io.IOException
DocIdSetBuilder(int maxDoc, int docCount, long valueCount)
public void add(DocIdSetIterator iter) throws java.io.IOException
DocIdSetIterator
to this builder.
NOTE: if you need to build a DocIdSet
out of a single
DocIdSetIterator
, you should rather use RoaringDocIdSet.Builder
.java.io.IOException
public DocIdSetBuilder.BulkAdder grow(int numDocs)
DocIdSetBuilder.BulkAdder
object that can be used to
add up to numDocs
documents.private void ensureBufferCapacity(int numDocs)
private int additionalCapacity(int numDocs)
private DocIdSetBuilder.Buffer addBuffer(int len)
private void growBuffer(DocIdSetBuilder.Buffer buffer, int additionalCapacity)
private void upgradeToBitSet()
private static DocIdSetBuilder.Buffer concat(java.util.List<DocIdSetBuilder.Buffer> buffers)
private static int dedup(int[] arr, int length)
private static boolean noDups(int[] a, int len)