Class BytesRefArrowBufBlock
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.lucene.util.Accountable,Writeable,Block,BytesRefBlock,org.elasticsearch.core.RefCounted,org.elasticsearch.core.Releasable,BlockLoader.Block
BytesRefBlock. Variable-length values use an additional offsets buffer
that maps each value index to a byte range in the data buffer, following the Arrow variable-length
binary layout. This is separate from the position-to-value-index offsets used for multi-valued fields.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.compute.data.Block
Block.Builder, Block.MvOrderingNested classes/interfaces inherited from interface org.elasticsearch.compute.data.BytesRefBlock
BytesRefBlock.BuilderNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields inherited from class org.elasticsearch.compute.data.arrow.AbstractArrowBufBlock
blockFactory, closed, offsetBuffer, offsetCount, validityBuffer, valueBuffer, valueCountFields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLEFields inherited from interface org.elasticsearch.compute.data.Block
ESQL_AGGREGATE_METRIC_DOUBLE_BLOCK, MAX_LOOKUP, PAGE_MEM_OVERHEAD_PER_BLOCK, SERIALIZE_BLOCK_ARRAY, SERIALIZE_BLOCK_BIG_ARRAY, SERIALIZE_BLOCK_ORDINAL, SERIALIZE_BLOCK_VALUES, SERIALIZE_BLOCK_VECTORFields inherited from interface org.elasticsearch.compute.data.BytesRefBlock
NULL_VALUEFields inherited from interface org.elasticsearch.core.RefCounted
ALWAYS_REFERENCED -
Constructor Summary
ConstructorsConstructorDescriptionBytesRefArrowBufBlock(org.apache.arrow.memory.ArrowBuf valueBuffer, org.apache.arrow.memory.ArrowBuf valueOffsetsBuffer, org.apache.arrow.memory.ArrowBuf validityBuffer, org.apache.arrow.memory.ArrowBuf offsetBuffer, int valueCount, int offsetCount, BlockFactory blockFactory) -
Method Summary
Modifier and TypeMethodDescriptionReturns an ordinal bytesref block if this block is backed by a dictionary and ordinals; otherwise, returns null.asVector()Returns an efficient dense single-value view of this block.protected ArrowBufBlockConstructor<BytesRefBlock> protected intbyteSize()Returns the element type of this block.booleanCompares the given object with this block for equality.expand()Expand multivalued fields into one row per value.filter(boolean mayContainDuplicates, int... positions) Creates a new block that only exposes the positions provided.org.apache.lucene.util.BytesRefgetBytesRef(int valueIndex, org.apache.lucene.util.BytesRef dest) Retrieves the BytesRef value stored at the given value index.inthashCode()Returns the hash code of this block, as defined byBytesRefBlock.hash(BytesRefBlock).keepMask(BooleanVector mask) org.elasticsearch.core.ReleasableIterator<? extends BytesRefBlock> lookup(IntBlock positions, ByteSizeValue targetBlockSize) Builds an Iterator of newBlocks with the sameBlock.elementType()as this Block whose values are copied from positions in this Block.static BytesRefArrowBufBlockof(org.apache.arrow.vector.ValueVector arrowVector, BlockFactory blockFactory) longvoidReleases (decrements the reference count) this block's Arrow buffersvoidRetains (increments the reference count) this block's Arrow buffersprotected ArrowBufVectorConstructor<BytesRefVector> Methods inherited from class org.elasticsearch.compute.data.arrow.AbstractArrowBufBlock
allowPassingToDifferentDriver, areAllValuesNull, blockFactory, closeInternal, doesHaveMultivaluedFields, getFirstValueIndex, getPositionCount, getTotalValueCount, getValueCount, isNull, mayHaveMultivaluedFields, mayHaveNulls, mvOrdering, setValidityBit, validityBufferLengthMethods 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, toString, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResourcesMethods inherited from interface org.elasticsearch.compute.data.Block
allowPassingToDifferentDriver, areAllValuesNull, blockFactory, doesHaveMultivaluedFields, getFirstValueIndex, getPositionCount, getTotalValueCount, getValueCount, insertNulls, isNull, isReleased, mayHaveMultivaluedFields, mayHaveNulls, mvDeduplicated, mvOrdering, mvSortedAscendingMethods inherited from interface org.elasticsearch.compute.data.BytesRefBlock
deepCopy, hasValue, slice, writeToMethods inherited from interface org.elasticsearch.core.RefCounted
decRef, hasReferences, incRef, mustIncRef, tryIncRefMethods inherited from interface org.elasticsearch.core.Releasable
close
-
Constructor Details
-
BytesRefArrowBufBlock
public BytesRefArrowBufBlock(org.apache.arrow.memory.ArrowBuf valueBuffer, org.apache.arrow.memory.ArrowBuf valueOffsetsBuffer, @Nullable org.apache.arrow.memory.ArrowBuf validityBuffer, @Nullable org.apache.arrow.memory.ArrowBuf offsetBuffer, int valueCount, int offsetCount, BlockFactory blockFactory) - Parameters:
valueBuffer- raw byte datavalueOffsetsBuffer- int32 offsets into valueBuffer for each value (Arrow variable-length layout)validityBuffer- null bitmap (nullable)offsetBuffer- position-to-value-index mapping for multi-valued fields (nullable)valueCount- number of positionsoffsetCount- number of position offset entriesblockFactory- block factory
-
-
Method Details
-
of
public static BytesRefArrowBufBlock of(org.apache.arrow.vector.ValueVector arrowVector, BlockFactory blockFactory) -
retainBuffers
public void retainBuffers()Description copied from class:AbstractArrowBufBlockRetains (increments the reference count) this block's Arrow buffers- Overrides:
retainBuffersin classAbstractArrowBufBlock<BytesRefVector,BytesRefBlock>
-
releaseBuffers
public void releaseBuffers()Description copied from class:AbstractArrowBufBlockReleases (decrements the reference count) this block's Arrow buffers- Overrides:
releaseBuffersin classAbstractArrowBufBlock<BytesRefVector,BytesRefBlock>
-
byteSize
protected int byteSize()- Specified by:
byteSizein classAbstractArrowBufBlock<BytesRefVector,BytesRefBlock>
-
vectorConstructor
- Specified by:
vectorConstructorin classAbstractArrowBufBlock<BytesRefVector,BytesRefBlock>
-
blockConstructor
- Specified by:
blockConstructorin classAbstractArrowBufBlock<BytesRefVector,BytesRefBlock>
-
getBytesRef
public org.apache.lucene.util.BytesRef getBytesRef(int valueIndex, org.apache.lucene.util.BytesRef dest) Description copied from interface:BytesRefBlockRetrieves the BytesRef value stored at the given value index.Values for a given position are between getFirstValueIndex(position) (inclusive) and getFirstValueIndex(position) + getValueCount(position) (exclusive).
- Specified by:
getBytesRefin interfaceBytesRefBlock- Parameters:
valueIndex- the value indexdest- the destination- Returns:
- the data value (as a BytesRef)
-
elementType
Description copied from interface:BlockReturns the element type of this block.- Specified by:
elementTypein interfaceBlock- Returns:
- the element type of this block
-
asOrdinals
Description copied from interface:BytesRefBlockReturns an ordinal bytesref block if this block is backed by a dictionary and ordinals; otherwise, returns null. Callers must not release the returned block as no extra reference is retained by this method.- Specified by:
asOrdinalsin interfaceBytesRefBlock
-
asVector
Description copied from interface:BlockReturns an efficient dense single-value view of this block. Null, if the block is not dense single-valued. That is, if mayHaveNulls returns true, or getTotalValueCount is not equal to getPositionCount.- Specified by:
asVectorin interfaceBlock- Specified by:
asVectorin interfaceBytesRefBlock- Overrides:
asVectorin classAbstractArrowBufBlock<BytesRefVector,BytesRefBlock> - Returns:
- an efficient dense single-value view of this block
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable- Overrides:
ramBytesUsedin classAbstractArrowBufBlock<BytesRefVector,BytesRefBlock>
-
filter
Description copied from interface:BlockCreates a new block that only exposes the positions provided.- Specified by:
filterin interfaceBlock- Specified by:
filterin interfaceBytesRefBlock- Overrides:
filterin classAbstractArrowBufBlock<BytesRefVector,BytesRefBlock> - Parameters:
mayContainDuplicates- may the positions array contain duplicate positions?positions- the positions to retain- Returns:
- a filtered block
-
keepMask
Description copied from interface:BlockBuild aBlockwith the same values as this Block, but replacing all values for whichmask.getBooleanValue(position)returnsfalsewithnull. Themaskvector must be at least as long as this Block.- Specified by:
keepMaskin interfaceBlock- Specified by:
keepMaskin interfaceBytesRefBlock- Overrides:
keepMaskin classAbstractArrowBufBlock<BytesRefVector,BytesRefBlock>
-
expand
Description copied from interface:BlockExpand multivalued fields into one row per value. Returns the same block if there aren't any multivalued fields to expand. The returned block needs to be closed by the caller to release the block's resources.- Specified by:
expandin interfaceBlock- Specified by:
expandin interfaceBytesRefBlock- Overrides:
expandin classAbstractArrowBufBlock<BytesRefVector,BytesRefBlock>
-
lookup
public org.elasticsearch.core.ReleasableIterator<? extends BytesRefBlock> lookup(IntBlock positions, ByteSizeValue targetBlockSize) Description copied from interface:BlockBuilds an Iterator of newBlocks with the sameBlock.elementType()as this Block whose values are copied from positions in this Block. It has the same number ofpositionsas thepositionsparameter.For example, if this block contained
[a, b, [b, c]]and were called with the block[0, 1, 1, [1, 2]]then the result would be[a, b, b, [b, b, c]].This process produces
count(this) * 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 interfaceBlock- Specified by:
lookupin interfaceBytesRefBlock- Overrides:
lookupin classAbstractArrowBufBlock<BytesRefVector,BytesRefBlock>
-
equals
Description copied from interface:BytesRefBlockCompares the given object with this block for equality. Returnstrueif and only if the given object is a BytesRefBlock, and both blocks areequal.- Specified by:
equalsin interfaceBytesRefBlock- Overrides:
equalsin classObject
-
hashCode
public int hashCode()Description copied from interface:BytesRefBlockReturns the hash code of this block, as defined byBytesRefBlock.hash(BytesRefBlock).- Specified by:
hashCodein interfaceBytesRefBlock- Overrides:
hashCodein classObject
-