public final class OrdinalsBuilder
extends java.lang.Object
implements java.io.Closeable
| Modifier and Type | Field and Description |
|---|---|
static float |
DEFAULT_ACCEPTABLE_OVERHEAD_RATIO
Default acceptable overhead ratio.
|
static java.lang.String |
FORCE_MULTI_ORDINALS
Whether to for the use of
MultiOrdinals to store the ordinals for testing purposes. |
| Constructor and Description |
|---|
OrdinalsBuilder(int maxDoc) |
OrdinalsBuilder(int maxDoc,
float acceptableOverheadRatio) |
| Modifier and Type | Method and Description |
|---|---|
OrdinalsBuilder |
addDoc(int doc)
Associates the given document id with the current ordinal.
|
Ordinals |
build()
Builds an
Ordinals instance from the builders current state. |
org.apache.lucene.util.BitSet |
buildDocsWithValuesSet()
Builds a
BitSet where each documents bit is that that has one or more ordinals associated with it. |
org.apache.lucene.util.BytesRefIterator |
buildFromTerms(org.apache.lucene.index.TermsEnum termsEnum)
This method iterates all terms in the given
TermsEnum and
associates each terms ordinal with the terms documents. |
void |
close()
Closes this builder and release all resources.
|
long |
currentOrdinal()
Returns the current ordinal or 0 if this build has not been advanced via
nextOrdinal(). |
org.apache.lucene.util.LongsRef |
docOrds(int docID)
Returns a shared
LongsRef instance for the given doc ID holding all ordinals associated with it. |
org.apache.lucene.util.packed.PackedInts.Reader |
getFirstOrdinals()
Return a
PackedInts.Reader instance mapping every doc ID to its first ordinal + 1 if it exists and 0 otherwise. |
int |
getNumDocsWithValue()
Returns the number distinct of document IDs with one or more values.
|
int |
getNumMultiValuesDocs()
Returns the number distinct of document IDs associated with two or more values.
|
int |
getNumSingleValuedDocs()
Returns the number distinct of document IDs associated with exactly one value.
|
int |
getTotalNumOrds()
Returns the number of document ID to ordinal pairs in this builder.
|
long |
getValueCount()
Returns the number of distinct ordinals in this builder.
|
boolean |
isMultiValued()
Returns
true iff this builder contains a document ID that is associated with more than one ordinal. |
int |
maxDoc()
Returns the maximum document ID this builder can associate with an ordinal
|
long |
nextOrdinal()
Advances the
OrdinalsBuilder to the next ordinal and
return the current ordinal. |
static org.apache.lucene.index.TermsEnum |
wrapGeoPointTerms(org.apache.lucene.index.TermsEnum termsEnum)
A
TermsEnum that iterates only highest resolution geo prefix coded terms. |
static org.apache.lucene.index.TermsEnum |
wrapNumeric32Bit(org.apache.lucene.index.TermsEnum termsEnum)
A
TermsEnum that iterates only full precision prefix coded 32 bit values. |
static org.apache.lucene.index.TermsEnum |
wrapNumeric64Bit(org.apache.lucene.index.TermsEnum termsEnum)
A
TermsEnum that iterates only full precision prefix coded 64 bit values. |
public static final java.lang.String FORCE_MULTI_ORDINALS
MultiOrdinals to store the ordinals for testing purposes.public static final float DEFAULT_ACCEPTABLE_OVERHEAD_RATIO
OrdinalsBuilder memory usage is mostly transient so it is likely a better trade-off to
trade memory for speed in order to resize less often.public OrdinalsBuilder(int maxDoc,
float acceptableOverheadRatio)
throws java.io.IOException
java.io.IOExceptionpublic OrdinalsBuilder(int maxDoc)
throws java.io.IOException
java.io.IOExceptionpublic org.apache.lucene.util.LongsRef docOrds(int docID)
LongsRef instance for the given doc ID holding all ordinals associated with it.public org.apache.lucene.util.packed.PackedInts.Reader getFirstOrdinals()
PackedInts.Reader instance mapping every doc ID to its first ordinal + 1 if it exists and 0 otherwise.public long nextOrdinal()
OrdinalsBuilder to the next ordinal and
return the current ordinal.public long currentOrdinal()
nextOrdinal().public OrdinalsBuilder addDoc(int doc)
public boolean isMultiValued()
true iff this builder contains a document ID that is associated with more than one ordinal. Otherwise false;public int getNumDocsWithValue()
public int getNumSingleValuedDocs()
public int getNumMultiValuesDocs()
public int getTotalNumOrds()
public long getValueCount()
public org.apache.lucene.util.BitSet buildDocsWithValuesSet()
BitSet where each documents bit is that that has one or more ordinals associated with it.
if every document has an ordinal associated with it this method returns nullpublic static org.apache.lucene.index.TermsEnum wrapGeoPointTerms(org.apache.lucene.index.TermsEnum termsEnum)
TermsEnum that iterates only highest resolution geo prefix coded terms.buildFromTerms(TermsEnum)public int maxDoc()
public static org.apache.lucene.index.TermsEnum wrapNumeric64Bit(org.apache.lucene.index.TermsEnum termsEnum)
TermsEnum that iterates only full precision prefix coded 64 bit values.buildFromTerms(TermsEnum)public static org.apache.lucene.index.TermsEnum wrapNumeric32Bit(org.apache.lucene.index.TermsEnum termsEnum)
TermsEnum that iterates only full precision prefix coded 32 bit values.buildFromTerms(TermsEnum)public org.apache.lucene.util.BytesRefIterator buildFromTerms(org.apache.lucene.index.TermsEnum termsEnum)
throws java.io.IOException
TermsEnum and
associates each terms ordinal with the terms documents. The caller must
exhaust the returned BytesRefIterator which returns all values
where the first returned value is associated with the ordinal 1
etc.
If the TermsEnum contains prefix coded numerical values the terms
enum should be wrapped with either wrapNumeric32Bit(TermsEnum)
or wrapNumeric64Bit(TermsEnum) depending on its precision. If
the TermsEnum is not wrapped the returned
BytesRefIterator will contain partial precision terms rather than
only full-precision terms.
java.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException