Module org.elasticsearch.server
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,GlobalOrdinalsAccounting
public final class GlobalOrdinalsIndexFieldData
extends Object
implements IndexOrdinalsFieldData, org.apache.lucene.util.Accountable, GlobalOrdinalsAccounting
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
Nested ClassesModifier and TypeClassDescriptionclassA non-thread safeIndexOrdinalsFieldDatafor global ordinals that creates theTermsEnumof 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 -
Method Summary
Modifier and TypeMethodDescriptionThe field name.org.apache.lucene.index.OrdinalMapReturns the underlyingOrdinalMapfor this fielddata or null if global ordinals are not needed (constant value or single segment).longThe 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) longorg.apache.lucene.search.SortFieldsortField(Object missingValue, MultiValueMode sortMode, IndexFieldData.XFieldComparatorSource.Nested nested, boolean reverse) Returns theSortFieldto use for sorting.booleanWhether this field data is able to provide a mapping between global and segment ordinals, by returning the underlyingOrdinalMap.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResourcesMethods inherited from interface org.elasticsearch.index.fielddata.IndexFieldData
sortField
-
Method Details
-
newConsumer
-
loadDirect
Description copied from interface:IndexFieldDataLoads directly the atomic field data for the reader, ignoring any caching involved.- Specified by:
loadDirectin interfaceIndexFieldData<LeafOrdinalsFieldData>
-
loadGlobal
Description copied from interface:IndexOrdinalsFieldDataLoad a global view of the ordinals for the givenIndexReader, potentially from a cache.- Specified by:
loadGlobalin interfaceIndexFieldData.Global<LeafOrdinalsFieldData>- Specified by:
loadGlobalin interfaceIndexOrdinalsFieldData
-
loadGlobalDirect
Description copied from interface:IndexOrdinalsFieldDataLoad a global view of the ordinals for the givenIndexReader.- Specified by:
loadGlobalDirectin interfaceIndexFieldData.Global<LeafOrdinalsFieldData>- Specified by:
loadGlobalDirectin interfaceIndexOrdinalsFieldData
-
getFieldName
Description copied from interface:IndexFieldDataThe field name.- Specified by:
getFieldNamein interfaceIndexFieldData<LeafOrdinalsFieldData>
-
getValuesSourceType
Description copied from interface:IndexFieldDataThe 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:
getValuesSourceTypein 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:IndexFieldDataReturns theSortFieldto use for sorting.- Specified by:
sortFieldin 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:IndexFieldDataBuild a sort implementation specialized for aggregations.- Specified by:
newBucketedSortin interfaceIndexFieldData<LeafOrdinalsFieldData>
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable
-
load
Description copied from interface:IndexFieldDataLoads the atomic field data for the reader, possibly cached.- Specified by:
loadin interfaceIndexFieldData<LeafOrdinalsFieldData>
-
getOrdinalMap
public org.apache.lucene.index.OrdinalMap getOrdinalMap()Description copied from interface:IndexOrdinalsFieldDataReturns the underlyingOrdinalMapfor this fielddata or null if global ordinals are not needed (constant value or single segment).- Specified by:
getOrdinalMapin interfaceIndexOrdinalsFieldData
-
supportsGlobalOrdinalsMapping
public boolean supportsGlobalOrdinalsMapping()Description copied from interface:IndexOrdinalsFieldDataWhether 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:
supportsGlobalOrdinalsMappingin interfaceIndexOrdinalsFieldData
-
getValueCount
public long getValueCount()- Specified by:
getValueCountin interfaceGlobalOrdinalsAccounting- Returns:
- unique value count of global ordinals implementing this interface.
-
getBuildingTime
- Specified by:
getBuildingTimein interfaceGlobalOrdinalsAccounting- Returns:
- the total time spent building this global ordinal instance.
-