Class ConstantBytesRefVector
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.lucene.util.Accountable,BytesRefVector,Vector,RefCounted,Releasable
X-ConstantVector.java.st instead.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.compute.data.BytesRefVector
BytesRefVector.BuilderNested classes/interfaces inherited from interface org.elasticsearch.compute.data.Vector
Vector.Builder -
Field Summary
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 -
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.Returns an ordinal BytesRef vector if this vector is backed by a dictionary and ordinals; otherwise, returns null.The block factory associated with this vector.protected voidThis is called when the number of references reaches zero.deepCopy(BlockFactory blockFactory) Make a deep copy of thisVectorusing the providedBlockFactory, likely copying all data.Returns the element type of this vector.booleanCompares the given object with this vector for equality.filter(boolean mayContainDuplicates, int[] positions, int offset, int length) Creates a new vector that only exposes the positions provided.get(int position, PagedBytesCursor scratch) Retrieves the bytes value stored at the given value index using aPagedBytesCursorfor zero-copy access to the underlying paged byte storage.org.apache.lucene.util.BytesRefgetBytesRef(int position, org.apache.lucene.util.BytesRef scratch) Build a contiguous array of bytes for the value stored at the given position.final intReturns the number of positions (rows) in this vector.inthashCode()Returns the hash code of this vector, as defined byBytesRefVector.hash(BytesRefVector).booleanReturns true iff this vector is a constant vector - returns the same constant value for every position.keepMask(BooleanVector mask) lookup(IntBlock positions, ByteSizeValue targetBlockSize) Builds an Iterator of newBlocks with the sameVector.elementType()as thisVectorwhose values are copied from positions in this Vector.static longramBytesEstimated(org.apache.lucene.util.BytesRef value, long overestimateThreshold, double overestimateFactor) Estimates the RAM usage of this vector, applying an overestimate multiplier when the value's byte length exceedsoverestimateThreshold.longstatic longramBytesUsedWithLength(org.apache.lucene.util.BytesRef value) slice(int beginInclusive, int endExclusive) Return a subset of this vector frombeginInclusivetoendExclusive.toString()intThe maximum size in bytes of any single value stored in this vector, or0if there are no values.Methods inherited from class org.elasticsearch.compute.data.AbstractNonThreadSafeRefCounted
attachReleasable, 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.compute.data.BytesRefVector
filter, writeToMethods 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
allowPassingToDifferentDriver, attachReleasable, blockFactory, getPositionCount, isReleased
-
Method Details
-
getBytesRef
public org.apache.lucene.util.BytesRef getBytesRef(int position, org.apache.lucene.util.BytesRef scratch) Description copied from interface:BytesRefVectorBuild a contiguous array of bytes for the value stored at the given position. The underlying data is generally stored in pages that look likebyte[][]with some data spanning more than one of the innerbyte[]arrays. In that case, this builds abyte[]in theBytesRef, copies the bytes, and returns it. Otherwise, this returns a zero-copy snapshot of the underlying data. Except arrow. Arrow always copies.If possible, use
BytesRefVector.get(int, org.elasticsearch.common.bytes.PagedBytesCursor)because it only needs to copy in the arrow implementation.- Specified by:
getBytesRefin interfaceBytesRefVector- Parameters:
position- the position indexscratch- the destination- Returns:
- the data value (as a BytesRef)
-
get
Description copied from interface:BytesRefVectorRetrieves the bytes value stored at the given value index using aPagedBytesCursorfor zero-copy access to the underlying paged byte storage. Except arrow. Arrow always copies.- Specified by:
getin interfaceBytesRefVector- Parameters:
position- the position indexscratch- the cursor to initialize and return- Returns:
- the initialized cursor pointing to the value's bytes
-
asBlock
Description copied from interface:VectorReturns a new Block containing this vector.- Specified by:
asBlockin interfaceBytesRefVector- Specified by:
asBlockin interfaceVector- Returns:
- a new Block containing this vector
-
asOrdinals
Description copied from interface:BytesRefVectorReturns an ordinal BytesRef vector if this vector is backed by a dictionary and ordinals; otherwise, returns null. Callers must not release the returned vector as no extra reference is retained by this method.- Specified by:
asOrdinalsin interfaceBytesRefVector
-
valueMaxByteSize
public int valueMaxByteSize()Description copied from interface:BytesRefVectorThe maximum size in bytes of any single value stored in this vector, or0if there are no values. Scans all positions to find the maximum.- Specified by:
valueMaxByteSizein interfaceBytesRefVector- Specified by:
valueMaxByteSizein interfaceVector- Returns:
- the maximum byte size of any single value in this vector
-
filter
Description copied from interface:VectorCreates a new vector that only exposes the positions provided. Materialization of the selected positions is avoided.- Specified by:
filterin interfaceBytesRefVector- Specified by:
filterin interfaceVector- Parameters:
mayContainDuplicates- may the positions array contain duplicate positions?positions- the positions arrayoffset- the start index in the positions arraylength- the number of positions to use from the array- Returns:
- a filtered vector
-
keepMask
Description copied from interface:VectorBuild aBlockthe same values as thisVector, but replacing all values for whichmask.getBooleanValue(position)returnsfalsewithnull. Themaskvector must be at least as long as this Vector.- Specified by:
keepMaskin interfaceBytesRefVector- Specified by:
keepMaskin interfaceVector
-
lookup
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.- Specified by:
lookupin interfaceBytesRefVector- Specified by:
lookupin interfaceVector
-
slice
Description copied from interface:BytesRefVectorReturn a subset of this vector frombeginInclusivetoendExclusive. This may return the same instance if the range covers all positions, but if it does it willRefCounted.incRef()it.- Specified by:
slicein interfaceBytesRefVector- Specified by:
slicein interfaceVector
-
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
-
deepCopy
Description copied from interface:BytesRefVectorMake a deep copy of thisVectorusing the providedBlockFactory, likely copying all data.- Specified by:
deepCopyin interfaceBytesRefVector- Specified by:
deepCopyin interfaceVector
-
ramBytesUsedWithLength
public static long ramBytesUsedWithLength(org.apache.lucene.util.BytesRef value) -
ramBytesEstimated
public static long ramBytesEstimated(org.apache.lucene.util.BytesRef value, long overestimateThreshold, double overestimateFactor) Estimates the RAM usage of this vector, applying an overestimate multiplier when the value's byte length exceedsoverestimateThreshold. This compensates for heap overhead thatRamUsageEstimatordoes not track, such as when loading large text fields from_source. -
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable
-
equals
Description copied from interface:BytesRefVectorCompares the given object with this vector for equality. Returnstrueif and only if the given object is a BytesRefVector, and both vectors areequal.- Specified by:
equalsin interfaceBytesRefVector- Overrides:
equalsin classObject
-
hashCode
public int hashCode()Description copied from interface:BytesRefVectorReturns the hash code of this vector, as defined byBytesRefVector.hash(BytesRefVector).- Specified by:
hashCodein interfaceBytesRefVector- Overrides:
hashCodein classObject
-
toString
-
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
-
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
protected 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).- Specified by:
closeInternalin classAbstractNonThreadSafeRefCounted
-