Class GlobalOrdinalsIndexFieldData
- java.lang.Object
-
- org.elasticsearch.index.AbstractIndexComponent
-
- org.elasticsearch.index.fielddata.ordinals.GlobalOrdinalsIndexFieldData
-
- All Implemented Interfaces:
Accountable,IndexFieldData<AtomicOrdinalsFieldData>,IndexFieldData.Global<AtomicOrdinalsFieldData>,IndexOrdinalsFieldData,IndexComponent
public final class GlobalOrdinalsIndexFieldData extends AbstractIndexComponent implements IndexOrdinalsFieldData, Accountable
Concrete implementation ofIndexOrdinalsFieldDatafor global ordinals. A single instance of this class should be used to cache global ordinals perDirectoryReader. HoweverloadGlobal(DirectoryReader)always creates a new instance ofGlobalOrdinalsIndexFieldData.Consumerfrom the cached value in order to reuse the segment'sTermsEnumthat are needed to retrieve terms from global ordinals. Each instance ofGlobalOrdinalsIndexFieldData.Consumeruses a new set ofTermsEnumthat can be reused during the collection, this is done to avoid creating all segment'sTermsEnumeach time we want to access the values of a single segment.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classGlobalOrdinalsIndexFieldData.ConsumerA 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 AtomicFieldData>, IndexFieldData.XFieldComparatorSource
-
-
Field Summary
-
Fields inherited from class org.elasticsearch.index.AbstractIndexComponent
deprecationLogger, indexSettings, logger
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedGlobalOrdinalsIndexFieldData(IndexSettings indexSettings, String fieldName, AtomicOrdinalsFieldData[] segmentAfd, OrdinalMap ordinalMap, long memorySizeInBytes, Function<SortedSetDocValues,ScriptDocValues<?>> scriptFunction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears any resources associated with this field data.Collection<Accountable>getChildResources()Returns nested resources of this class.StringgetFieldName()The field name.OrdinalMapgetOrdinalMap()Returns the underlyingOrdinalMapfor this fielddata or null if global ordinals are not needed (constant value or single segment).AtomicOrdinalsFieldDataload(LeafReaderContext context)Loads the atomic field data for the reader, possibly cached.AtomicOrdinalsFieldDataloadDirect(LeafReaderContext context)Loads directly the atomic field data for the reader, ignoring any caching involved.IndexOrdinalsFieldDataloadGlobal(DirectoryReader indexReader)Load a global view of the ordinals for the givenIndexReader, potentially from a cache.IndexOrdinalsFieldDatalocalGlobalDirect(DirectoryReader indexReader)Load a global view of the ordinals for the givenIndexReader.IndexOrdinalsFieldDatanewConsumer(DirectoryReader source)longramBytesUsed()Return the memory usage of this object in bytes.SortFieldsortField(Object missingValue, MultiValueMode sortMode, IndexFieldData.XFieldComparatorSource.Nested nested, boolean reverse)Returns theSortFieldto use for sorting.booleansupportsGlobalOrdinalsMapping()Whether this field data is able to provide a mapping between global and segment ordinals, by returning the underlyingOrdinalMap.-
Methods inherited from class org.elasticsearch.index.AbstractIndexComponent
getIndexSettings, index
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.index.IndexComponent
index
-
-
-
-
Constructor Detail
-
GlobalOrdinalsIndexFieldData
protected GlobalOrdinalsIndexFieldData(IndexSettings indexSettings, String fieldName, AtomicOrdinalsFieldData[] segmentAfd, OrdinalMap ordinalMap, long memorySizeInBytes, Function<SortedSetDocValues,ScriptDocValues<?>> scriptFunction)
-
-
Method Detail
-
newConsumer
public IndexOrdinalsFieldData newConsumer(DirectoryReader source)
-
loadDirect
public AtomicOrdinalsFieldData loadDirect(LeafReaderContext context) throws Exception
Description copied from interface:IndexFieldDataLoads directly the atomic field data for the reader, ignoring any caching involved.- Specified by:
loadDirectin interfaceIndexFieldData<AtomicOrdinalsFieldData>- Throws:
Exception
-
loadGlobal
public IndexOrdinalsFieldData loadGlobal(DirectoryReader indexReader)
Description copied from interface:IndexOrdinalsFieldDataLoad a global view of the ordinals for the givenIndexReader, potentially from a cache.- Specified by:
loadGlobalin interfaceIndexFieldData.Global<AtomicOrdinalsFieldData>- Specified by:
loadGlobalin interfaceIndexOrdinalsFieldData
-
localGlobalDirect
public IndexOrdinalsFieldData localGlobalDirect(DirectoryReader indexReader) throws Exception
Description copied from interface:IndexOrdinalsFieldDataLoad a global view of the ordinals for the givenIndexReader.- Specified by:
localGlobalDirectin interfaceIndexFieldData.Global<AtomicOrdinalsFieldData>- Specified by:
localGlobalDirectin interfaceIndexOrdinalsFieldData- Throws:
Exception
-
getFieldName
public String getFieldName()
Description copied from interface:IndexFieldDataThe field name.- Specified by:
getFieldNamein interfaceIndexFieldData<AtomicOrdinalsFieldData>
-
sortField
public 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<AtomicOrdinalsFieldData>
-
clear
public void clear()
Description copied from interface:IndexFieldDataClears any resources associated with this field data.- Specified by:
clearin interfaceIndexFieldData<AtomicOrdinalsFieldData>
-
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
public Collection<Accountable> 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:
Accountables
-
load
public AtomicOrdinalsFieldData load(LeafReaderContext context)
Description copied from interface:IndexFieldDataLoads the atomic field data for the reader, possibly cached.- Specified by:
loadin interfaceIndexFieldData<AtomicOrdinalsFieldData>
-
getOrdinalMap
public 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
-
-