Module org.elasticsearch.compute
Class BooleanArrowBufBlock
java.lang.Object
org.elasticsearch.compute.data.AbstractNonThreadSafeRefCounted
org.elasticsearch.compute.data.arrow.AbstractArrowBufBlock<BooleanVector,BooleanBlock>
org.elasticsearch.compute.data.arrow.BooleanArrowBufBlock
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.lucene.util.Accountable,Writeable,Block,BooleanBlock,RefCounted,Releasable,BlockLoader.Block
public final class BooleanArrowBufBlock
extends AbstractArrowBufBlock<BooleanVector,BooleanBlock>
implements BooleanBlock
Arrow buffer backed
BooleanBlock. Booleans are bit-packed in Arrow (1 bit per value),
so this class overrides filter(boolean, int[], int, int) and lookup(org.elasticsearch.compute.data.IntBlock, org.elasticsearch.common.unit.ByteSizeValue) with bit-level implementations.
The inherited AbstractArrowBufBlock.keepMask(org.elasticsearch.compute.data.BooleanVector) and AbstractArrowBufBlock.expand() work unchanged since they only manipulate
validity and offset buffers.-
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.BooleanBlock
BooleanBlock.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.core.RefCounted
ALWAYS_REFERENCED -
Constructor Summary
ConstructorsConstructorDescriptionBooleanArrowBufBlock(org.apache.arrow.memory.ArrowBuf valueBuffer, org.apache.arrow.memory.ArrowBuf validityBuffer, org.apache.arrow.memory.ArrowBuf offsetBuffer, int valueCount, int offsetCount, BlockFactory blockFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected ArrowBufBlockConstructor<BooleanBlock> protected intbyteSize()Returns the element type of this block.filter(boolean mayContainDuplicates, int[] positions, int offset, int length) Creates a new block that only exposes the positions provided.booleangetBoolean(int valueIndex) Retrieves the boolean value stored at the given value index.ReleasableIterator<? extends BooleanBlock> 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 BooleanBlockof(org.apache.arrow.vector.BitVector bitVector, BlockFactory blockFactory) toMask()Convert this to a"mask"that's appropriate for passing toBooleanBlock.keepMask(org.elasticsearch.compute.data.BooleanVector).intThe maximum size in bytes of any single value stored in this block, or0if there are no values.protected ArrowBufVectorConstructor<BooleanVector> Methods inherited from class org.elasticsearch.compute.data.arrow.AbstractArrowBufBlock
allowPassingToDifferentDriver, areAllValuesNull, asVector, blockFactory, closeInternal, doesHaveMultivaluedFields, expand, getFirstValueIndex, getPositionCount, getTotalValueCount, getValueCount, isNull, keepMask, mayHaveMultivaluedFields, mayHaveNulls, mvOrdering, ramBytesUsed, releaseBuffers, retainBuffers, setValidityBit, validityBufferLengthMethods inherited from class org.elasticsearch.compute.data.AbstractNonThreadSafeRefCounted
attachReleasable, close, decRef, hasReferences, incRef, isReleased, tryIncRefMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResources, ramBytesUsedMethods inherited from interface org.elasticsearch.compute.data.Block
allowPassingToDifferentDriver, areAllValuesNull, attachReleasable, blockFactory, doesHaveMultivaluedFields, getFirstValueIndex, getPositionCount, getTotalValueCount, getValueCount, insertNulls, isNull, isReleased, mayHaveMultivaluedFields, mayHaveNulls, mvDeduplicated, mvOrdering, mvSortedAscendingMethods inherited from interface org.elasticsearch.compute.data.BooleanBlock
asVector, deepCopy, equals, expand, filter, hashCode, hasValue, keepMask, slice, writeToMethods inherited from interface org.elasticsearch.core.RefCounted
decRef, hasReferences, incRef, mustIncRef, tryIncRefMethods inherited from interface org.elasticsearch.core.Releasable
close
-
Constructor Details
-
BooleanArrowBufBlock
public BooleanArrowBufBlock(org.apache.arrow.memory.ArrowBuf valueBuffer, @Nullable org.apache.arrow.memory.ArrowBuf validityBuffer, @Nullable org.apache.arrow.memory.ArrowBuf offsetBuffer, int valueCount, int offsetCount, BlockFactory blockFactory)
-
-
Method Details
-
of
public static BooleanBlock of(org.apache.arrow.vector.BitVector bitVector, BlockFactory blockFactory) -
byteSize
protected int byteSize()- Specified by:
byteSizein classAbstractArrowBufBlock<BooleanVector,BooleanBlock>
-
vectorConstructor
- Specified by:
vectorConstructorin classAbstractArrowBufBlock<BooleanVector,BooleanBlock>
-
blockConstructor
- Specified by:
blockConstructorin classAbstractArrowBufBlock<BooleanVector,BooleanBlock>
-
getBoolean
public boolean getBoolean(int valueIndex) Description copied from interface:BooleanBlockRetrieves the boolean value stored at the given value index.The
valueIndexfor a position is between.int start = getFirstValueIndex(position); int end = start + getValueCount(position);- Specified by:
getBooleanin interfaceBooleanBlock- Parameters:
valueIndex- the value index- Returns:
- the data value (as a boolean)
-
elementType
Description copied from interface:BlockReturns the element type of this block.- Specified by:
elementTypein interfaceBlock- Returns:
- the element type of this block
-
valueMaxByteSize
public int valueMaxByteSize()Description copied from interface:BooleanBlockThe maximum size in bytes of any single value stored in this block, or0if there are no values. AlwaysByte.BYTESsince all boolean values encode to the same number of bytes.- Specified by:
valueMaxByteSizein interfaceBlock- Specified by:
valueMaxByteSizein interfaceBooleanBlock- Returns:
- the maximum byte size of any single value in this block
-
toMask
Description copied from interface:BooleanBlockConvert this to a"mask"that's appropriate for passing toBooleanBlock.keepMask(org.elasticsearch.compute.data.BooleanVector). Null and multivalued positions will be converted tofalse.- Specified by:
toMaskin interfaceBooleanBlock
-
filter
Description copied from interface:BlockCreates a new block that only exposes the positions provided.- Specified by:
filterin interfaceBlock- Specified by:
filterin interfaceBooleanBlock- Overrides:
filterin classAbstractArrowBufBlock<BooleanVector,BooleanBlock> - Parameters:
mayContainDuplicates- may the positions array contain duplicate positions?positions- the positions to retainoffset- the start index in the positions arraylength- the number of positions to use from the array- Returns:
- a filtered block
-
lookup
public ReleasableIterator<? extends BooleanBlock> 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 interfaceBooleanBlock- Overrides:
lookupin classAbstractArrowBufBlock<BooleanVector,BooleanBlock>
-