java.lang.Object
org.apache.lucene.index.OrdinalMap
- All Implemented Interfaces:
Accountable
Maps per-segment ordinals to/from global ordinal space, using a compact packed-ints
representation.
NOTE: this is a costly operation, as it must merge sort all terms, and may require non-trivial RAM once done. It's better to operate in segment-private ordinal space instead when possible.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long(package private) final LongValues(package private) final LongValuesfinal IndexReader.CacheKeyCache key of whoever asked for this awful thing(package private) final long(package private) final OrdinalMap.SegmentMap(package private) final LongValues[](package private) final longFields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE -
Constructor Summary
ConstructorsConstructorDescriptionOrdinalMap(IndexReader.CacheKey owner, TermsEnum[] subs, OrdinalMap.SegmentMap segmentMap, float acceptableOverheadRatio) -
Method Summary
Modifier and TypeMethodDescriptionstatic OrdinalMapbuild(IndexReader.CacheKey owner, SortedDocValues[] values, float acceptableOverheadRatio) Create an ordinal map that uses the number of unique values of eachSortedDocValuesinstance as a weight.static OrdinalMapbuild(IndexReader.CacheKey owner, SortedSetDocValues[] values, float acceptableOverheadRatio) Create an ordinal map that uses the number of unique values of eachSortedSetDocValuesinstance as a weight.static OrdinalMapbuild(IndexReader.CacheKey owner, TermsEnum[] subs, long[] weights, float acceptableOverheadRatio) Creates an ordinal map that allows mapping ords to/from a merged space fromsubs.Returns nested resources of this class.intgetFirstSegmentNumber(long globalOrd) Given a global ordinal, returns the index of the first segment that contains this term.longgetFirstSegmentOrd(long globalOrd) Given global ordinal, returns the ordinal of the first segment which contains this ordinal (the corresponding to the segment returngetFirstSegmentNumber(long)).getGlobalOrds(int segmentIndex) Given a segment number, return aLongValuesinstance that maps segment ordinals to global ordinals.longReturns the total number of unique terms in global ord space.longReturn the memory usage of this object in bytes.
-
Field Details
-
BASE_RAM_BYTES_USED
private static final long BASE_RAM_BYTES_USED -
owner
Cache key of whoever asked for this awful thing -
valueCount
final long valueCount -
globalOrdDeltas
-
firstSegments
-
segmentToGlobalOrds
-
segmentMap
-
ramBytesUsed
final long ramBytesUsed
-
-
Constructor Details
-
OrdinalMap
OrdinalMap(IndexReader.CacheKey owner, TermsEnum[] subs, OrdinalMap.SegmentMap segmentMap, float acceptableOverheadRatio) throws IOException - Throws:
IOException
-
-
Method Details
-
build
public static OrdinalMap build(IndexReader.CacheKey owner, SortedDocValues[] values, float acceptableOverheadRatio) throws IOException Create an ordinal map that uses the number of unique values of eachSortedDocValuesinstance as a weight.- Throws:
IOException- See Also:
-
build
public static OrdinalMap build(IndexReader.CacheKey owner, SortedSetDocValues[] values, float acceptableOverheadRatio) throws IOException Create an ordinal map that uses the number of unique values of eachSortedSetDocValuesinstance as a weight.- Throws:
IOException- See Also:
-
build
public static OrdinalMap build(IndexReader.CacheKey owner, TermsEnum[] subs, long[] weights, float acceptableOverheadRatio) throws IOException Creates an ordinal map that allows mapping ords to/from a merged space fromsubs.- Parameters:
owner- a cache keysubs- TermsEnums that supportTermsEnum.ord(). They need not be dense (e.g. can be FilteredTermsEnums}.weights- a weight for each sub. This is ideally correlated with the number of unique terms that each sub introduces compared to the other subs- Throws:
IOException- if an I/O error occurred.
-
getGlobalOrds
Given a segment number, return aLongValuesinstance that maps segment ordinals to global ordinals. -
getFirstSegmentOrd
public long getFirstSegmentOrd(long globalOrd) Given global ordinal, returns the ordinal of the first segment which contains this ordinal (the corresponding to the segment returngetFirstSegmentNumber(long)). -
getFirstSegmentNumber
public int getFirstSegmentNumber(long globalOrd) Given a global ordinal, returns the index of the first segment that contains this term. -
getValueCount
public long getValueCount()Returns the total number of unique terms in global ord space. -
ramBytesUsed
public long ramBytesUsed()Description copied from interface:AccountableReturn the memory usage of this object in bytes. Negative values are illegal.- Specified by:
ramBytesUsedin interfaceAccountable
-
getChildResources
Description copied from interface:AccountableReturns nested resources of this class. The result should be a point-in-time snapshot (to avoid race conditions).- Specified by:
getChildResourcesin interfaceAccountable- See Also:
-