- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.lucene.util.Accountable,Writeable,AggregateMetricDoubleBlock,Block,BooleanBlock,BytesRefBlock,DoubleBlock,FloatBlock,IntBlock,LongBlock,org.elasticsearch.core.RefCounted,org.elasticsearch.core.Releasable,BlockLoader.Block
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.compute.data.Block
Block.MvOrderingNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLEFields inherited from interface org.elasticsearch.compute.data.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 -
Method Summary
Modifier and TypeMethodDescriptionvoidBefore passing a Block to another Driver, it is necessary to switch the owning block factory to its parent, which is associated with the global circuit breaker.booleanReturns 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.The block factory associated with this block.final voidclose()voidThis is called when the number of references reaches zero.final booleandecRef()booleanDoes this block have multivalued fields? UnlikeBlock.mayHaveMultivaluedFields()this will never return a false positive.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(int... positions) Creates a new block that only exposes the positions provided.booleangetBoolean(int valueIndex) Retrieves the boolean value stored at the given value index.org.apache.lucene.util.BytesRefgetBytesRef(int valueIndex, org.apache.lucene.util.BytesRef dest) Retrieves the BytesRef value stored at the given value index.doublegetDouble(int valueIndex) Retrieves the double value stored at the given value index.intgetFirstValueIndex(int position) Gets the index of the first value for the given position.floatgetFloat(int valueIndex) Retrieves the float value stored at the given value index.intgetInt(int valueIndex) Retrieves the int value stored at the given value index.longgetLong(int valueIndex) Retrieves the long value stored at the given value index.getMetricBlock(int index) intReturns The number of positions in this block..intReturns The total number of values in this block not counting nulls..intgetValueCount(int position) Gets the number of values for the given position, possibly 0.inthashCode()Returns the hash code of this block, as defined byBooleanBlock.hash(BooleanBlock).final booleanfinal voidincRef()booleanisNull(int position) final booleankeepMask(BooleanVector mask) org.elasticsearch.core.ReleasableIterator<ConstantNullBlock> 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.maxBlock()booleanCan this block have multivalued fields? Blocks that returnfalsewill never return more than one fromBlock.getValueCount(int).booleanminBlock()How are multivalued fields ordered?longsumBlock()toMask()Convert this to a"mask"that's appropriate for passing toBooleanBlock.keepMask(org.elasticsearch.compute.data.BooleanVector).toString()final booleanvoidwriteTo(StreamOutput out) Writes only the data of the block to a stream output.Methods 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.Block
insertNulls, isReleased, mvDeduplicated, mvSortedAscendingMethods inherited from interface org.elasticsearch.core.RefCounted
decRef, hasReferences, incRef, mustIncRef, tryIncRefMethods inherited from interface org.elasticsearch.core.Releasable
close
-
Method Details
-
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 interfaceBooleanBlock- Specified by:
asVectorin interfaceBytesRefBlock- Specified by:
asVectorin interfaceDoubleBlock- Specified by:
asVectorin interfaceFloatBlock- Specified by:
asVectorin interfaceIntBlock- Specified by:
asVectorin interfaceLongBlock- Returns:
- an efficient dense single-value view 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
-
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
-
isNull
public boolean isNull(int position) -
areAllValuesNull
public boolean areAllValuesNull()- Specified by:
areAllValuesNullin interfaceBlock- Returns:
- true if all values in this block are guaranteed to be null.
-
mayHaveNulls
public boolean mayHaveNulls()- Specified by:
mayHaveNullsin interfaceBlock- Returns:
- true if some values might be null. False, if all values are guaranteed to be not null.
-
mayHaveMultivaluedFields
public boolean mayHaveMultivaluedFields()Description copied from interface:BlockCan this block have multivalued fields? Blocks that returnfalsewill never return more than one fromBlock.getValueCount(int). This may returntruefor Blocks that do not have multivalued fields, but it will always answer quickly.- Specified by:
mayHaveMultivaluedFieldsin interfaceBlock
-
doesHaveMultivaluedFields
public boolean doesHaveMultivaluedFields()Description copied from interface:BlockDoes this block have multivalued fields? UnlikeBlock.mayHaveMultivaluedFields()this will never return a false positive. In other words, if this returnstruethen there are positions for whichBlock.getValueCount(int)will return more than 1. This will answer quickly if it can but may have to check all positions.- Specified by:
doesHaveMultivaluedFieldsin interfaceBlock
-
elementType
Description copied from interface:BlockReturns the element type of this block.- Specified by:
elementTypein interfaceBlock- Returns:
- the element type of this block
-
filter
Description copied from interface:BlockCreates a new block that only exposes the positions provided.- Specified by:
filterin interfaceAggregateMetricDoubleBlock- Specified by:
filterin interfaceBlock- Specified by:
filterin interfaceBooleanBlock- Specified by:
filterin interfaceBytesRefBlock- Specified by:
filterin interfaceDoubleBlock- Specified by:
filterin interfaceFloatBlock- Specified by:
filterin interfaceIntBlock- Specified by:
filterin interfaceLongBlock- Parameters:
positions- the positions to retain- Returns:
- a filtered block TODO: pass BlockFactory
-
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 interfaceAggregateMetricDoubleBlock- Specified by:
keepMaskin interfaceBlock- Specified by:
keepMaskin interfaceBooleanBlock- Specified by:
keepMaskin interfaceBytesRefBlock- Specified by:
keepMaskin interfaceDoubleBlock- Specified by:
keepMaskin interfaceFloatBlock- Specified by:
keepMaskin interfaceIntBlock- Specified by:
keepMaskin interfaceLongBlock
-
lookup
public org.elasticsearch.core.ReleasableIterator<ConstantNullBlock> 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 interfaceAggregateMetricDoubleBlock- Specified by:
lookupin interfaceBlock- Specified by:
lookupin interfaceBooleanBlock- Specified by:
lookupin interfaceBytesRefBlock- Specified by:
lookupin interfaceDoubleBlock- Specified by:
lookupin interfaceFloatBlock- Specified by:
lookupin interfaceIntBlock- Specified by:
lookupin interfaceLongBlock
-
writeTo
Description copied from interface:BlockWrites only the data of the block to a stream output. This method should be used when the type of the block is known during reading.- Specified by:
writeToin interfaceBlock- Specified by:
writeToin interfaceBooleanBlock- Specified by:
writeToin interfaceBytesRefBlock- Specified by:
writeToin interfaceDoubleBlock- Specified by:
writeToin interfaceFloatBlock- Specified by:
writeToin interfaceIntBlock- Specified by:
writeToin interfaceLongBlock- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
mvOrdering
Description copied from interface:BlockHow are multivalued fields ordered?- Specified by:
mvOrderingin interfaceBlock
-
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 interfaceAggregateMetricDoubleBlock- Specified by:
expandin interfaceBlock- Specified by:
expandin interfaceBooleanBlock- Specified by:
expandin interfaceBytesRefBlock- Specified by:
expandin interfaceDoubleBlock- Specified by:
expandin interfaceFloatBlock- Specified by:
expandin interfaceIntBlock- Specified by:
expandin interfaceLongBlock
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable
-
equals
Description copied from interface:BooleanBlockCompares the given object with this block for equality. Returnstrueif and only if the given object is a BooleanBlock, and both blocks areequal.- Specified by:
equalsin interfaceAggregateMetricDoubleBlock- Specified by:
equalsin interfaceBooleanBlock- Specified by:
equalsin interfaceBytesRefBlock- Specified by:
equalsin interfaceDoubleBlock- Specified by:
equalsin interfaceFloatBlock- Specified by:
equalsin interfaceIntBlock- Specified by:
equalsin interfaceLongBlock- Overrides:
equalsin classObject
-
hashCode
public int hashCode()Description copied from interface:BooleanBlockReturns the hash code of this block, as defined byBooleanBlock.hash(BooleanBlock).- Specified by:
hashCodein interfaceAggregateMetricDoubleBlock- Specified by:
hashCodein interfaceBooleanBlock- Specified by:
hashCodein interfaceBytesRefBlock- Specified by:
hashCodein interfaceDoubleBlock- Specified by:
hashCodein interfaceFloatBlock- Specified by:
hashCodein interfaceIntBlock- Specified by:
hashCodein interfaceLongBlock- Overrides:
hashCodein classObject
-
minBlock
- Specified by:
minBlockin interfaceAggregateMetricDoubleBlock
-
maxBlock
- Specified by:
maxBlockin interfaceAggregateMetricDoubleBlock
-
sumBlock
- Specified by:
sumBlockin interfaceAggregateMetricDoubleBlock
-
countBlock
- Specified by:
countBlockin interfaceAggregateMetricDoubleBlock
-
getMetricBlock
- Specified by:
getMetricBlockin interfaceAggregateMetricDoubleBlock
-
toString
-
closeInternal
public void closeInternal()This is called when the number of references reaches zero. This is where resources should be released (adjusting circuit breakers if needed). -
getBoolean
public boolean getBoolean(int valueIndex) Description copied from interface:BooleanBlockRetrieves the boolean 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:
getBooleanin interfaceBooleanBlock- Parameters:
valueIndex- the value index- Returns:
- the data value (as a boolean)
-
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)
-
getFloat
public float getFloat(int valueIndex) Description copied from interface:FloatBlockRetrieves the float 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:
getFloatin interfaceFloatBlock- Parameters:
valueIndex- the value index- Returns:
- the data value (as a float)
-
getDouble
public double getDouble(int valueIndex) Description copied from interface:DoubleBlockRetrieves the double 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:
getDoublein interfaceDoubleBlock- Parameters:
valueIndex- the value index- Returns:
- the data value (as a double)
-
getInt
public int getInt(int valueIndex) Description copied from interface:IntBlockRetrieves the int value stored at the given value index.Values for a given position are between getFirstValueIndex(position) (inclusive) and getFirstValueIndex(position) + getValueCount(position) (exclusive).
-
getLong
public long getLong(int valueIndex) Description copied from interface:LongBlockRetrieves the long value stored at the given value index.Values for a given position are between getFirstValueIndex(position) (inclusive) and getFirstValueIndex(position) + getValueCount(position) (exclusive).
-
getTotalValueCount
public int getTotalValueCount()Description copied from interface:BlockReturns The total number of values in this block not counting nulls..- Specified by:
getTotalValueCountin interfaceBlock- Returns:
- The total number of values in this block not counting nulls.
-
getPositionCount
public int getPositionCount()Description copied from interface:BlockReturns The number of positions in this block..- Specified by:
getPositionCountin interfaceBlock- Returns:
- The number of positions in this block.
-
getFirstValueIndex
public int getFirstValueIndex(int position) Description copied from interface:BlockGets the index of the first value for the given position.- Specified by:
getFirstValueIndexin interfaceBlock
-
getValueCount
public int getValueCount(int position) Description copied from interface:BlockGets the number of values for the given position, possibly 0.- Specified by:
getValueCountin interfaceBlock
-
blockFactory
Description copied from interface:BlockThe block factory associated with this block.- Specified by:
blockFactoryin interfaceBlock
-
allowPassingToDifferentDriver
public void allowPassingToDifferentDriver()Description copied from interface:BlockBefore passing a Block 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 Block, 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 interfaceBlock
-
incRef
public final void incRef()- Specified by:
incRefin interfaceorg.elasticsearch.core.RefCounted
-
tryIncRef
public final boolean tryIncRef()- Specified by:
tryIncRefin interfaceorg.elasticsearch.core.RefCounted
-
decRef
public final boolean decRef()- Specified by:
decRefin interfaceorg.elasticsearch.core.RefCounted
-
hasReferences
public final boolean hasReferences()- Specified by:
hasReferencesin interfaceorg.elasticsearch.core.RefCounted
-
close
public final void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceorg.elasticsearch.core.Releasable
-
isReleased
public final boolean isReleased()
-