Class GlobalOrdinalsIndexFieldData
java.lang.Object
org.elasticsearch.index.fielddata.ordinals.GlobalOrdinalsIndexFieldData
- All Implemented Interfaces:
org.apache.lucene.util.Accountable
,IndexFieldData<LeafOrdinalsFieldData>
,IndexFieldData.Global<LeafOrdinalsFieldData>
,IndexOrdinalsFieldData
public final class GlobalOrdinalsIndexFieldData
extends Object
implements IndexOrdinalsFieldData, org.apache.lucene.util.Accountable
Concrete implementation of
IndexOrdinalsFieldData
for global ordinals.
A single instance of this class should be used to cache global ordinals per DirectoryReader
.
However loadGlobal(DirectoryReader)
always creates a new instance of GlobalOrdinalsIndexFieldData.Consumer
from the cached
value in order to reuse the segment's TermsEnum
that are needed to retrieve terms from global ordinals.
Each instance of GlobalOrdinalsIndexFieldData.Consumer
uses a new set of TermsEnum
that can be reused during the collection,
this is done to avoid creating all segment's TermsEnum
each time we want to access the values of a single
segment.-
Nested Class Summary
Modifier and TypeClassDescriptionclass
A non-thread safeIndexOrdinalsFieldData
for global ordinals that creates theTermsEnum
of each segment once and use them to provide a single lookup per segment.Nested classes/interfaces inherited from interface org.elasticsearch.index.fielddata.IndexFieldData
IndexFieldData.Builder, IndexFieldData.Global<FD extends LeafFieldData>, IndexFieldData.XFieldComparatorSource
-
Field Summary
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
Constructor Summary
ModifierConstructorDescriptionprotected
GlobalOrdinalsIndexFieldData(String fieldName, ValuesSourceType valuesSourceType, LeafOrdinalsFieldData[] segmentAfd, org.apache.lucene.index.OrdinalMap ordinalMap, long memorySizeInBytes, Function<org.apache.lucene.index.SortedSetDocValues,ScriptDocValues<?>> scriptFunction)
-
Method Summary
Modifier and TypeMethodDescriptionCollection<org.apache.lucene.util.Accountable>
The field name.org.apache.lucene.index.OrdinalMap
Returns the underlyingOrdinalMap
for this fielddata or null if global ordinals are not needed (constant value or single segment).The ValuesSourceType of the underlying data.load(org.apache.lucene.index.LeafReaderContext context)
Loads the atomic field data for the reader, possibly cached.loadDirect(org.apache.lucene.index.LeafReaderContext context)
Loads directly the atomic field data for the reader, ignoring any caching involved.loadGlobal(org.apache.lucene.index.DirectoryReader indexReader)
Load a global view of the ordinals for the givenIndexReader
, potentially from a cache.loadGlobalDirect(org.apache.lucene.index.DirectoryReader indexReader)
Load a global view of the ordinals for the givenIndexReader
.newBucketedSort(BigArrays bigArrays, Object missingValue, MultiValueMode sortMode, IndexFieldData.XFieldComparatorSource.Nested nested, SortOrder sortOrder, DocValueFormat format, int bucketSize, BucketedSort.ExtraData extra)
Build a sort implementation specialized for aggregations.newConsumer(org.apache.lucene.index.DirectoryReader source)
long
org.apache.lucene.search.SortField
sortField(Object missingValue, MultiValueMode sortMode, IndexFieldData.XFieldComparatorSource.Nested nested, boolean reverse)
Returns theSortField
to use for sorting.boolean
Whether this field data is able to provide a mapping between global and segment ordinals, by returning the underlyingOrdinalMap
.
-
Constructor Details
-
GlobalOrdinalsIndexFieldData
protected GlobalOrdinalsIndexFieldData(String fieldName, ValuesSourceType valuesSourceType, LeafOrdinalsFieldData[] segmentAfd, org.apache.lucene.index.OrdinalMap ordinalMap, long memorySizeInBytes, Function<org.apache.lucene.index.SortedSetDocValues,ScriptDocValues<?>> scriptFunction)
-
-
Method Details
-
newConsumer
-
loadDirect
public LeafOrdinalsFieldData loadDirect(org.apache.lucene.index.LeafReaderContext context) throws ExceptionDescription copied from interface:IndexFieldData
Loads directly the atomic field data for the reader, ignoring any caching involved.- Specified by:
loadDirect
in interfaceIndexFieldData<LeafOrdinalsFieldData>
- Throws:
Exception
-
loadGlobal
Description copied from interface:IndexOrdinalsFieldData
Load a global view of the ordinals for the givenIndexReader
, potentially from a cache.- Specified by:
loadGlobal
in interfaceIndexFieldData.Global<LeafOrdinalsFieldData>
- Specified by:
loadGlobal
in interfaceIndexOrdinalsFieldData
-
loadGlobalDirect
public IndexOrdinalsFieldData loadGlobalDirect(org.apache.lucene.index.DirectoryReader indexReader) throws ExceptionDescription copied from interface:IndexOrdinalsFieldData
Load a global view of the ordinals for the givenIndexReader
.- Specified by:
loadGlobalDirect
in interfaceIndexFieldData.Global<LeafOrdinalsFieldData>
- Specified by:
loadGlobalDirect
in interfaceIndexOrdinalsFieldData
- Throws:
Exception
-
getFieldName
Description copied from interface:IndexFieldData
The field name.- Specified by:
getFieldName
in interfaceIndexFieldData<LeafOrdinalsFieldData>
-
getValuesSourceType
Description copied from interface:IndexFieldData
The ValuesSourceType of the underlying data. It's possible for fields that use the same IndexFieldData implementation to have different ValuesSourceTypes, such as in the case of Longs and Dates.- Specified by:
getValuesSourceType
in interfaceIndexFieldData<LeafOrdinalsFieldData>
-
sortField
public org.apache.lucene.search.SortField sortField(@Nullable Object missingValue, MultiValueMode sortMode, IndexFieldData.XFieldComparatorSource.Nested nested, boolean reverse)Description copied from interface:IndexFieldData
Returns theSortField
to use for sorting.- Specified by:
sortField
in interfaceIndexFieldData<LeafOrdinalsFieldData>
-
newBucketedSort
public BucketedSort newBucketedSort(BigArrays bigArrays, Object missingValue, MultiValueMode sortMode, IndexFieldData.XFieldComparatorSource.Nested nested, SortOrder sortOrder, DocValueFormat format, int bucketSize, BucketedSort.ExtraData extra)Description copied from interface:IndexFieldData
Build a sort implementation specialized for aggregations.- Specified by:
newBucketedSort
in interfaceIndexFieldData<LeafOrdinalsFieldData>
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsed
in interfaceorg.apache.lucene.util.Accountable
-
getChildResources
- Specified by:
getChildResources
in interfaceorg.apache.lucene.util.Accountable
-
load
Description copied from interface:IndexFieldData
Loads the atomic field data for the reader, possibly cached.- Specified by:
load
in interfaceIndexFieldData<LeafOrdinalsFieldData>
-
getOrdinalMap
public org.apache.lucene.index.OrdinalMap getOrdinalMap()Description copied from interface:IndexOrdinalsFieldData
Returns the underlyingOrdinalMap
for this fielddata or null if global ordinals are not needed (constant value or single segment).- Specified by:
getOrdinalMap
in interfaceIndexOrdinalsFieldData
-
supportsGlobalOrdinalsMapping
public boolean supportsGlobalOrdinalsMapping()Description copied from interface:IndexOrdinalsFieldData
Whether this field data is able to provide a mapping between global and segment ordinals, by returning the underlyingOrdinalMap
. If this method returns false, then callingIndexOrdinalsFieldData.getOrdinalMap()
will result in anUnsupportedOperationException
.- Specified by:
supportsGlobalOrdinalsMapping
in interfaceIndexOrdinalsFieldData
-