Package org.apache.lucene.index
Class OrdinalMap
- java.lang.Object
-
- org.apache.lucene.index.OrdinalMap
-
- All Implemented Interfaces:
Accountable
public class OrdinalMap extends java.lang.Object implements 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 Classes Modifier and Type Class Description private static class
OrdinalMap.SegmentMap
private static class
OrdinalMap.TermsEnumIndex
-
Field Summary
Fields Modifier and Type Field Description private static long
BASE_RAM_BYTES_USED
(package private) LongValues
firstSegments
(package private) LongValues
globalOrdDeltas
IndexReader.CacheKey
owner
Cache key of whoever asked for this awful thing(package private) long
ramBytesUsed
(package private) OrdinalMap.SegmentMap
segmentMap
(package private) LongValues[]
segmentToGlobalOrds
(package private) long
valueCount
-
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
-
Constructor Summary
Constructors Constructor Description OrdinalMap(IndexReader.CacheKey owner, TermsEnum[] subs, OrdinalMap.SegmentMap segmentMap, float acceptableOverheadRatio)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static OrdinalMap
build(IndexReader.CacheKey owner, SortedDocValues[] values, float acceptableOverheadRatio)
Create an ordinal map that uses the number of unique values of eachSortedDocValues
instance as a weight.static OrdinalMap
build(IndexReader.CacheKey owner, SortedSetDocValues[] values, float acceptableOverheadRatio)
Create an ordinal map that uses the number of unique values of eachSortedSetDocValues
instance as a weight.static OrdinalMap
build(IndexReader.CacheKey owner, TermsEnum[] subs, long[] weights, float acceptableOverheadRatio)
Creates an ordinal map that allows mapping ords to/from a merged space fromsubs
.java.util.Collection<Accountable>
getChildResources()
Returns nested resources of this class.int
getFirstSegmentNumber(long globalOrd)
Given a global ordinal, returns the index of the first segment that contains this term.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)
).LongValues
getGlobalOrds(int segmentIndex)
Given a segment number, return aLongValues
instance that maps segment ordinals to global ordinals.long
getValueCount()
Returns the total number of unique terms in global ord space.long
ramBytesUsed()
Return the memory usage of this object in bytes.
-
-
-
Field Detail
-
BASE_RAM_BYTES_USED
private static final long BASE_RAM_BYTES_USED
-
owner
public final IndexReader.CacheKey owner
Cache key of whoever asked for this awful thing
-
valueCount
final long valueCount
-
globalOrdDeltas
final LongValues globalOrdDeltas
-
firstSegments
final LongValues firstSegments
-
segmentToGlobalOrds
final LongValues[] segmentToGlobalOrds
-
segmentMap
final OrdinalMap.SegmentMap segmentMap
-
ramBytesUsed
final long ramBytesUsed
-
-
Constructor Detail
-
OrdinalMap
OrdinalMap(IndexReader.CacheKey owner, TermsEnum[] subs, OrdinalMap.SegmentMap segmentMap, float acceptableOverheadRatio) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
build
public static OrdinalMap build(IndexReader.CacheKey owner, SortedDocValues[] values, float acceptableOverheadRatio) throws java.io.IOException
Create an ordinal map that uses the number of unique values of eachSortedDocValues
instance as a weight.- Throws:
java.io.IOException
- See Also:
build(IndexReader.CacheKey, TermsEnum[], long[], float)
-
build
public static OrdinalMap build(IndexReader.CacheKey owner, SortedSetDocValues[] values, float acceptableOverheadRatio) throws java.io.IOException
Create an ordinal map that uses the number of unique values of eachSortedSetDocValues
instance as a weight.- Throws:
java.io.IOException
- See Also:
build(IndexReader.CacheKey, TermsEnum[], long[], float)
-
build
public static OrdinalMap build(IndexReader.CacheKey owner, TermsEnum[] subs, long[] weights, float acceptableOverheadRatio) throws java.io.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:
java.io.IOException
- if an I/O error occurred.
-
getGlobalOrds
public LongValues getGlobalOrds(int segmentIndex)
Given a segment number, return aLongValues
instance 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:Accountable
Return the memory usage of this object in bytes. Negative values are illegal.- Specified by:
ramBytesUsed
in interfaceAccountable
-
getChildResources
public java.util.Collection<Accountable> getChildResources()
Description copied from interface:Accountable
Returns nested resources of this class. The result should be a point-in-time snapshot (to avoid race conditions).- Specified by:
getChildResources
in interfaceAccountable
- See Also:
Accountables
-
-