Class TDigestArrayBlock

All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.lucene.util.Accountable, Writeable, Block, HistogramBlock, TDigestBlock, RefCounted, Releasable, BlockLoader.Block

public final class TDigestArrayBlock extends AbstractDelegatingCompoundBlock<TDigestBlock> implements TDigestBlock
  • Constructor Details

  • Method Details

    • assertInvariants

      protected boolean assertInvariants()
      Overrides:
      assertInvariants in class AbstractDelegatingCompoundBlock<TDigestBlock>
    • valueMaxByteSize

      public int valueMaxByteSize()
      Description copied from interface: Block
      Returns the maximum byte size of any single value in this block. For fixed-width types this is a constant. For BytesRef, this scans all values quickly.
      Specified by:
      valueMaxByteSize in interface Block
      Overrides:
      valueMaxByteSize in class AbstractDelegatingCompoundBlock<TDigestBlock>
      Returns:
      the maximum byte size of any single value in this block
    • getSubBlocks

      protected List<Block> getSubBlocks()
      Specified by:
      getSubBlocks in class AbstractDelegatingCompoundBlock<TDigestBlock>
      Returns:
      a list of the sub-blocks composing this compound block. The first block must be non-null for non-null composite values (used for null detection). The order should match the order expected by AbstractDelegatingCompoundBlock.buildFromSubBlocks(List, int, int[]).
    • buildFromSubBlocks

      protected TDigestArrayBlock buildFromSubBlocks(List<Block> subBlocks, int newPositionCount, @Nullable int[] newFirstValueIndexes)
      Description copied from class: AbstractDelegatingCompoundBlock
      Construct a new instance of the block, based on the given list of sub-blocks.
      Specified by:
      buildFromSubBlocks in class AbstractDelegatingCompoundBlock<TDigestBlock>
      Parameters:
      subBlocks - List of sub-blocks, in the same order as AbstractDelegatingCompoundBlock.getSubBlocks()
      newPositionCount - the number of positions in the new block
      newFirstValueIndexes - the firstValueIndexes array for the new block (may be null for single-valued)
      Returns:
      a new instance based on the given blocks.
    • asVector

      public Vector asVector()
      Description copied from interface: Block
      Returns 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:
      asVector in interface Block
      Returns:
      an efficient dense single-value view of this block
    • elementType

      public ElementType elementType()
      Description copied from interface: Block
      Returns the element type of this block.
      Specified by:
      elementType in interface Block
      Returns:
      the element type of this block
    • lookup

      public ReleasableIterator<? extends TDigestBlock> lookup(IntBlock positions, ByteSizeValue targetBlockSize)
      Description copied from interface: Block
      Builds an Iterator of new Blocks with the same Block.elementType() as this Block whose values are copied from positions in this Block. It has the same number of positions as the positions parameter.

      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 ReleasableIterator may retain a reference to the positions parameter. Close it to release those references.

      This block is built using the same BlockFactory as was used to build the positions parameter.

      Specified by:
      lookup in interface Block
    • expand

      public Block expand()
      Description copied from interface: Block
      Expand 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:
      expand in interface Block
    • buildHistogramComponentBlock

      public DoubleBlock buildHistogramComponentBlock(HistogramBlock.Component component)
      Description copied from interface: HistogramBlock
      Returns a block holding the specified component of the histogram at each position. The number of positions in the returned block will be exactly equal to the number of positions in this block. If a position is null in this block, it will also be null in the returned block.
      The caller is responsible for closing the returned block.
      Specified by:
      buildHistogramComponentBlock in interface HistogramBlock
      Parameters:
      component - the component to extract
      Returns:
      the block containing the specified component
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Block
      Writes 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:
      writeTo in interface Block
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • readFrom

      public static TDigestArrayBlock readFrom(BlockStreamInput input) throws IOException
      Throws:
      IOException
    • serializeTDigest

      public void serializeTDigest(int valueIndex, TDigestBlock.SerializedTDigestOutput out, org.apache.lucene.util.BytesRef scratch)
      Specified by:
      serializeTDigest in interface TDigestBlock
    • getTDigestHolder

      public TDigestHolder getTDigestHolder(int valueIndex, TDigestHolder scratch)
      Specified by:
      getTDigestHolder in interface TDigestBlock
    • createConstant

      public static TDigestBlock createConstant(TDigestHolder histogram, int positionCount, BlockFactory blockFactory)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object