Class OrdinalsBuilder
java.lang.Object
org.elasticsearch.index.fielddata.ordinals.OrdinalsBuilder
- All Implemented Interfaces:
Closeable,AutoCloseable
Simple class to build document ID <-> ordinal mapping. Note: Ordinals are
1 based monotonically increasing positive integers. 0
donates the missing value in this context.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic floatDefault acceptable overhead ratio. -
Constructor Summary
ConstructorsConstructorDescriptionOrdinalsBuilder(int maxDoc)OrdinalsBuilder(int maxDoc, float acceptableOverheadRatio) -
Method Summary
Modifier and TypeMethodDescriptionaddDoc(int doc)Associates the given document id with the current ordinal.build()Builds anOrdinalsinstance from the builders current state.voidclose()Closes this builder and release all resources.longReturns the current ordinal or0if this build has not been advanced vianextOrdinal().org.apache.lucene.util.LongsRefdocOrds(int docID)Returns a sharedLongsRefinstance for the given doc ID holding all ordinals associated with it.org.apache.lucene.util.packed.PackedInts.ReaderReturn aPackedInts.Readerinstance mapping every doc ID to its first ordinal + 1 if it exists and 0 otherwise.intReturns the number distinct of document IDs associated with two or more values.intReturns the number of document ID to ordinal pairs in this builder.longReturns the number of distinct ordinals in this builder.intmaxDoc()Returns the maximum document ID this builder can associate with an ordinallongAdvances theOrdinalsBuilderto the next ordinal and return the current ordinal.
-
Field Details
-
DEFAULT_ACCEPTABLE_OVERHEAD_RATIO
public static final float DEFAULT_ACCEPTABLE_OVERHEAD_RATIODefault acceptable overhead ratio.OrdinalsBuildermemory usage is mostly transient so it is likely a better trade-off to trade memory for speed in order to resize less often.- See Also:
- Constant Field Values
-
-
Constructor Details
-
OrdinalsBuilder
public OrdinalsBuilder(int maxDoc, float acceptableOverheadRatio) -
OrdinalsBuilder
public OrdinalsBuilder(int maxDoc)
-
-
Method Details
-
docOrds
public org.apache.lucene.util.LongsRef docOrds(int docID)Returns a sharedLongsRefinstance for the given doc ID holding all ordinals associated with it. -
getFirstOrdinals
public org.apache.lucene.util.packed.PackedInts.Reader getFirstOrdinals()Return aPackedInts.Readerinstance mapping every doc ID to its first ordinal + 1 if it exists and 0 otherwise. -
nextOrdinal
public long nextOrdinal()Advances theOrdinalsBuilderto the next ordinal and return the current ordinal. -
currentOrdinal
public long currentOrdinal()Returns the current ordinal or0if this build has not been advanced vianextOrdinal(). -
addDoc
Associates the given document id with the current ordinal. -
getNumMultiValuesDocs
public int getNumMultiValuesDocs()Returns the number distinct of document IDs associated with two or more values. -
getTotalNumOrds
public int getTotalNumOrds()Returns the number of document ID to ordinal pairs in this builder. -
getValueCount
public long getValueCount()Returns the number of distinct ordinals in this builder. -
build
Builds anOrdinalsinstance from the builders current state. -
maxDoc
public int maxDoc()Returns the maximum document ID this builder can associate with an ordinal -
close
Closes this builder and release all resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-