java.lang.Object
org.elasticsearch.compute.data.AbstractNonThreadSafeRefCounted
org.elasticsearch.compute.data.DocVector
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.lucene.util.Accountable,Vector,org.elasticsearch.core.RefCounted,org.elasticsearch.core.Releasable
Vector where each entry references a lucene document.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classNested classes/interfaces inherited from interface org.elasticsearch.compute.data.Vector
Vector.Builder -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intPer position memory cost to build the shard segment doc map required to load fields out of order.Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLEFields inherited from interface org.elasticsearch.core.RefCounted
ALWAYS_REFERENCEDFields inherited from interface org.elasticsearch.compute.data.Vector
SERIALIZE_VECTOR_ARRAY, SERIALIZE_VECTOR_BIG_ARRAY, SERIALIZE_VECTOR_CONSTANT, SERIALIZE_VECTOR_ORDINAL, SERIALIZE_VECTOR_VALUES -
Constructor Summary
ConstructorsConstructorDescriptionDocVector(IndexedByShardId<? extends org.elasticsearch.core.RefCounted> refCounteds, IntVector shards, IntVector segments, IntVector docs, DocVector.Config config) -
Method Summary
Modifier and TypeMethodDescriptionvoidBefore passing a Vector to another Driver, it is necessary to switch the owning block factory to its parent, which is associated with the global circuit breaker.asBlock()Returns a new Block containing this vector.The block factory associated with this vector.voidThis is called when the number of references reaches zero.static DocVector.Configconfig()Fancy wrapper around the ctor forDocVector.deepCopy(BlockFactory blockFactory) Make a deep copy of thisBlockusing the providedBlockFactory, likely copying all data.docs()Returns the element type of this vector.booleanfilter(boolean mayContainDuplicates, int... positions) Creates a new vector that only exposes the positions provided.final intReturns the number of positions (rows) in this vector.inthashCode()booleanReturns true iff this vector is a constant vector - returns the same constant value for every position.keepMask(BooleanVector mask) org.elasticsearch.core.ReleasableIterator<? extends Block> lookup(IntBlock positions, ByteSizeValue targetBlockSize) Builds an Iterator of newBlocks with the sameVector.elementType()as thisVectorwhose values are copied from positions in this Vector.booleanCan this vector reference duplicate documents? SomeBlockLoaders will run more slowly if this istrue.static DocVector.FixedBuildernewFixedBuilder(BlockFactory blockFactory, int estimatedSize) Builds a doc vector with a fixed lengthDocBlock.static longramBytesEstimated(IntVector shards, IntVector segments, IntVector docs, int[] shardSegmentDocMapForwards, int[] shardSegmentDocMapBackwards) longsegments()org.elasticsearch.core.RefCountedshardRefCounted(int position) shards()int[]Reverse ofshardSegmentDocMapForwards.int[]Map from the positions in this page to the positions in lucene's native order for loading doc values.booleanDoes this vector contain only documents from a single segment.booleanDoes this vector contain only documents from a single segment and are the documents always non-decreasing? Non-decreasing here means almost monotonically increasing.static longsizeOfSegmentDocMap(int positionCount) slice(int beginInclusive, int endExclusive) toString()Methods inherited from class org.elasticsearch.compute.data.AbstractNonThreadSafeRefCounted
close, decRef, hasReferences, incRef, isReleased, tryIncRefMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResourcesMethods inherited from interface org.elasticsearch.core.RefCounted
decRef, hasReferences, incRef, mustIncRef, tryIncRefMethods inherited from interface org.elasticsearch.core.Releasable
closeMethods inherited from interface org.elasticsearch.compute.data.Vector
blockFactory, getPositionCount, isReleased
-
Field Details
-
SHARD_SEGMENT_DOC_MAP_PER_ROW_OVERHEAD
public static final int SHARD_SEGMENT_DOC_MAP_PER_ROW_OVERHEADPer position memory cost to build the shard segment doc map required to load fields out of order.- See Also:
-
-
Constructor Details
-
DocVector
public DocVector(IndexedByShardId<? extends org.elasticsearch.core.RefCounted> refCounteds, IntVector shards, IntVector segments, IntVector docs, DocVector.Config config)
-
-
Method Details
-
config
Fancy wrapper around the ctor forDocVector. -
shards
-
segments
-
docs
-
singleSegment
public boolean singleSegment()Does this vector contain only documents from a single segment. -
mayContainDuplicates
public boolean mayContainDuplicates()Can this vector reference duplicate documents? SomeBlockLoaders will run more slowly if this istrue. These BlockLoaders will return incorrect results if there are duplicates and this isfalse. This exists because of a hierarchy of speeds:-
We can better optimize some
BlockLoaders when they receive DocVectors that don't contain duplicates. - It's rare that we want to load from duplicate doc ids. We don't need to spend that much time optimizing it.
- We sometimes really want to load from duplicate doc ids to minimize total amount of loading we have to do in fairly specific cases like resolving dimension values after time series aggregations.
-
We can better optimize some
-
singleSegmentNonDecreasing
public boolean singleSegmentNonDecreasing()Does this vector contain only documents from a single segment and are the documents always non-decreasing? Non-decreasing here means almost monotonically increasing. -
shardSegmentDocMapForwards
public int[] shardSegmentDocMapForwards()Map from the positions in this page to the positions in lucene's native order for loading doc values. -
shardSegmentDocMapBackwards
public int[] shardSegmentDocMapBackwards()Reverse ofshardSegmentDocMapForwards. If you load doc values in the "forward" order then you can callBlock.filter(boolean, int...)on the loaded values with this array to put them in the same order as thisPage. -
sizeOfSegmentDocMap
public static long sizeOfSegmentDocMap(int positionCount) -
asBlock
Description copied from interface:VectorReturns a new Block containing this vector. -
slice
Description copied from interface:VectorReturn a subset of thisVectorfrom positionbeginInclusiveto positionendExclusive. This may return the same instance if the range covers all positions, but if it does it willRefCounted.incRef()it.NOTE: Implementations will not try to optimize zero length slices as we expect them to be rare.
-
filter
Description copied from interface:VectorCreates a new vector that only exposes the positions provided. Materialization of the selected positions is avoided. -
deepCopy
Description copied from interface:VectorMake a deep copy of thisBlockusing the providedBlockFactory, likely copying all data. -
keepMask
Description copied from interface:Vector -
lookup
public org.elasticsearch.core.ReleasableIterator<? extends Block> lookup(IntBlock positions, ByteSizeValue targetBlockSize) Description copied from interface:VectorBuilds an Iterator of newBlocks with the sameVector.elementType()as thisVectorwhose values are copied from positions in this Vector. It has the same number ofpositionsas thepositionsparameter.For example, if this vector contained
[a, b, c]and were called with the block[0, 1, 1, [1, 2]]then the result would be[a, b, b, [b, c]].This process produces
count(positions)values per positions which could be quite large. Instead of returning a single Block, this returns an Iterator of Blocks containing all of the promised values.The returned
ReleasableIteratormay retain a reference to thepositionsparameter. Close it to release those references.This block is built using the same
BlockFactoryas was used to build thepositionsparameter. -
elementType
Description copied from interface:VectorReturns the element type of this vector.- Specified by:
elementTypein interfaceVector- Returns:
- the element type of this vector
-
isConstant
public boolean isConstant()Description copied from interface:VectorReturns true iff this vector is a constant vector - returns the same constant value for every position.- Specified by:
isConstantin interfaceVector- Returns:
- true iff this vector is a constant vector - returns the same constant value for every position
-
hashCode
public int hashCode() -
equals
-
toString
-
ramBytesEstimated
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable
-
allowPassingToDifferentDriver
public void allowPassingToDifferentDriver()Description copied from interface:VectorBefore passing a Vector to another Driver, it is necessary to switch the owning block factory to its parent, which is associated with the global circuit breaker. This ensures that when the new driver releases this Vector, it returns memory directly to the parent block factory instead of the local block factory of this Block. This is important because the local block factory is not thread safe and doesn't support simultaneous access by more than one thread.- Specified by:
allowPassingToDifferentDriverin interfaceVector
-
closeInternal
public void closeInternal()Description copied from class:AbstractNonThreadSafeRefCountedThis is called when the number of references reaches zero. This is where resources should be released (adjusting circuit breakers if needed). -
shardRefCounted
public org.elasticsearch.core.RefCounted shardRefCounted(int position) -
newFixedBuilder
Builds a doc vector with a fixed lengthDocBlock. -
getPositionCount
public final int getPositionCount()Description copied from interface:VectorReturns the number of positions (rows) in this vector. See class javadoc for the usual way to iterate these positions.- Specified by:
getPositionCountin interfaceVector- Returns:
- the number of positions (rows) in this vector
-
blockFactory
Description copied from interface:VectorThe block factory associated with this vector.- Specified by:
blockFactoryin interfaceVector
-