Class BytesRefArrowBufVector
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.lucene.util.Accountable,BytesRefVector,Vector,RefCounted,Releasable
BytesRefVector. Variable-length values use an additional offsets buffer
that maps each value index to a byte range in the data buffer.-
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 class org.elasticsearch.compute.data.arrow.AbstractArrowBufVector
blockFactory, closed, positionCount, valueBufferFields 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
ConstructorsConstructorDescriptionBytesRefArrowBufVector(org.apache.arrow.memory.ArrowBuf valueBuffer, org.apache.arrow.memory.ArrowBuf valueOffsetsBuffer, int positionCount, BlockFactory blockFactory) -
Method Summary
Modifier and TypeMethodDescriptionasBlock()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.protected ArrowBufBlockConstructor<BytesRefBlock> protected intbyteSize()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 dest) Build a contiguous array of bytes for the value stored at the given position.inthashCode()Returns the hash code of this vector, as defined byBytesRefVector.hash(BytesRefVector).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 BytesRefArrowBufVectorof(org.apache.arrow.vector.VarCharVector arrowVec, BlockFactory blockFactory) longvoidReleases (decrements the reference count) this vector's Arrow buffersvoidRetains (increments the reference count) this vector's Arrow buffersslice(int beginInclusive, int endExclusive) Return a subset of this vector frombeginInclusivetoendExclusive.intThe maximum size in bytes of any single value stored in this vector, or0if there are no values.protected ArrowBufVectorConstructor<BytesRefVector> voidwriteTo(StreamOutput out) Serializes this Vector to the given stream output.Methods inherited from class org.elasticsearch.compute.data.arrow.AbstractArrowBufVector
allowPassingToDifferentDriver, blockFactory, closeInternal, getPositionCount, isConstant, keepMask, valuesSegmentMethods 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, toString, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResourcesMethods inherited from interface org.elasticsearch.compute.data.BytesRefVector
deepCopy, filter, keepMaskMethods 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, isConstant, isReleased
-
Constructor Details
-
BytesRefArrowBufVector
public BytesRefArrowBufVector(org.apache.arrow.memory.ArrowBuf valueBuffer, org.apache.arrow.memory.ArrowBuf valueOffsetsBuffer, int positionCount, BlockFactory blockFactory)
-
-
Method Details
-
of
public static BytesRefArrowBufVector of(org.apache.arrow.vector.VarCharVector arrowVec, BlockFactory blockFactory) -
vectorConstructor
- Specified by:
vectorConstructorin classAbstractArrowBufVector<BytesRefVector,BytesRefBlock>
-
blockConstructor
- Specified by:
blockConstructorin classAbstractArrowBufVector<BytesRefVector,BytesRefBlock>
-
retainBuffers
public void retainBuffers()Description copied from class:AbstractArrowBufVectorRetains (increments the reference count) this vector's Arrow buffers- Overrides:
retainBuffersin classAbstractArrowBufVector<BytesRefVector,BytesRefBlock>
-
releaseBuffers
public void releaseBuffers()Description copied from class:AbstractArrowBufVectorReleases (decrements the reference count) this vector's Arrow buffers- Overrides:
releaseBuffersin classAbstractArrowBufVector<BytesRefVector,BytesRefBlock>
-
getBytesRef
public org.apache.lucene.util.BytesRef getBytesRef(int position, org.apache.lucene.util.BytesRef dest) 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 indexdest- 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
-
byteSize
protected int byteSize()- Specified by:
byteSizein classAbstractArrowBufVector<BytesRefVector,BytesRefBlock>
-
elementType
Description copied from interface:VectorReturns the element type of this vector.- Specified by:
elementTypein interfaceVector- Returns:
- the element type of this vector
-
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
-
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
-
asBlock
Description copied from interface:VectorReturns a new Block containing this vector.- Specified by:
asBlockin interfaceBytesRefVector- Specified by:
asBlockin interfaceVector- Overrides:
asBlockin classAbstractArrowBufVector<BytesRefVector,BytesRefBlock> - Returns:
- a new Block containing this vector
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable- Overrides:
ramBytesUsedin classAbstractArrowBufVector<BytesRefVector,BytesRefBlock>
-
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
-
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
-
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- Overrides:
filterin classAbstractArrowBufVector<BytesRefVector,BytesRefBlock> - 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
-
writeTo
Description copied from interface:BytesRefVectorSerializes this Vector to the given stream output.- Specified by:
writeToin interfaceBytesRefVector- Throws:
IOException
-
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
-