Class AbstractDelegatingCompoundBlock<T extends Block>

java.lang.Object
org.elasticsearch.compute.data.AbstractNonThreadSafeRefCounted
org.elasticsearch.compute.data.AbstractDelegatingCompoundBlock<T>
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.lucene.util.Accountable, Writeable, Block, org.elasticsearch.core.RefCounted, org.elasticsearch.core.Releasable, BlockLoader.Block
Direct Known Subclasses:
AggregateMetricDoubleArrayBlock, TDigestArrayBlock

public abstract class AbstractDelegatingCompoundBlock<T extends Block> extends AbstractNonThreadSafeRefCounted implements Block
Abstract base class for block types that are implemented by delegating to several concrete sub blocks.
  • Constructor Details

    • AbstractDelegatingCompoundBlock

      public AbstractDelegatingCompoundBlock()
  • Method Details

    • getSubBlocks

      protected abstract List<Block> getSubBlocks()
      Returns:
      a list of the sub-blocks composing this compound block. The order of the list should match the order expected by buildFromSubBlocks(List)
    • buildFromSubBlocks

      protected abstract T buildFromSubBlocks(List<Block> subBlocks)
      Construct a new instance of the block, based on the given list of sub-blocks.
      Parameters:
      subBlocks - List of sub-blocks, in the same order as getSubBlocks()
      Returns:
      a new instance based on the given blocks.
    • allowPassingToDifferentDriver

      public void allowPassingToDifferentDriver()
      Description copied from interface: Block
      Before 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:
      allowPassingToDifferentDriver in interface Block
    • blockFactory

      public BlockFactory blockFactory()
      Description copied from interface: Block
      The block factory associated with this block.
      Specified by:
      blockFactory in interface Block
    • closeInternal

      protected void closeInternal()
      Description copied from class: AbstractNonThreadSafeRefCounted
      This is called when the number of references reaches zero. This is where resources should be released (adjusting circuit breakers if needed).
      Specified by:
      closeInternal in class AbstractNonThreadSafeRefCounted
    • deepCopy

      public T deepCopy(BlockFactory blockFactory)
      Description copied from interface: Block
      Make a deep copy of this Block using the provided BlockFactory, likely copying all data.
      Specified by:
      deepCopy in interface Block
    • filter

      public T filter(boolean mayContainDuplicates, int... positions)
      Description copied from interface: Block
      Creates a new block that only exposes the positions provided.
      Specified by:
      filter in interface Block
      Parameters:
      mayContainDuplicates - may the positions array contain duplicate positions?
      positions - the positions to retain
      Returns:
      a filtered block
    • slice

      public T slice(int beginInclusive, int endExclusive)
      Description copied from interface: Block
      Return a subset of this Block from position beginInclusive to position endExclusive. This may return the same instance if the range covers all positions, but if it does it will RefCounted.incRef() it.

      NOTE: Implementations will not try to optimize zero length slices as we expect them to be rare.

      Specified by:
      slice in interface Block
    • getPositionCount

      public int getPositionCount()
      Description copied from interface: Block
      Returns the number of positions (rows) in this block. See class javadoc for the usual way to iterate these positions.
      Specified by:
      getPositionCount in interface Block
      Returns:
      the number of positions (rows) in this block
    • keepMask

      public T keepMask(BooleanVector mask)
      Description copied from interface: Block
      Build a Block with the same values as this Block, but replacing all values for which mask.getBooleanValue(position) returns false with null. The mask vector must be at least as long as this Block.
      Specified by:
      keepMask in interface Block
    • ramBytesUsed

      public long ramBytesUsed()
      Specified by:
      ramBytesUsed in interface org.apache.lucene.util.Accountable