Class TDigestArrayBlock

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

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

  • Method Details

    • getSubBlocks

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

      protected TDigestArrayBlock buildFromSubBlocks(List<Block> subBlocks)
      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()
      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
    • getFirstValueIndex

      public int getFirstValueIndex(int position)
      Description copied from interface: Block
      Returns the index of the first value for the given position. See class javadoc for the usual way to iterate these positions.

      For densely packed data this will return its parameter unchanged. For fields with null values or multivalued fields, this will shift. Here's an example:

      
           0   <---+
           1       | Values at first position
           2       |
           3   <---+
           5   <---- Value at second position
           6   <---+ Values at third position
           7   <---+
       

      This represents three rows. The first has the value [0, 1, 2, 3]. The second has the value 5. The third has the value [6, 7]. This method will return 0 for the first position, 4 for the second, and 5 for the third.

      Specified by:
      getFirstValueIndex in interface Block
      Returns:
      the index of the first value for the given position
    • getTotalValueCount

      public int getTotalValueCount()
      Description copied from interface: Block
      Returns the total number of values in this block not counting nulls. This powers the COUNT aggregation and is used to report the number of fields loaded by ESQL.
      Specified by:
      getTotalValueCount in interface Block
      Returns:
      the total number of values in this block not counting nulls
    • getValueCount

      public int getValueCount(int position)
      Description copied from interface: Block
      Returns the number of values for the given position. See class javadoc for the usual way to iterate these positions.

      For densely packed data this will return 1. For nulls this will return 0. For multivalued fields, this will return the number of values. Here's an example:

      
           0   <---+
           1       | Values at first position
           2       |
           3   <---+
           5   <---- Value at second position
           6   <---+ Values at third position
           7   <---+
       

      This represents three rows. The first has the value [0, 1, 2, 3]. The second has the value 5. The third has the value [6, 7]. This method will return 4 for the first position, 1 for the second, and 2 for the third.

      Specified by:
      getValueCount in interface Block
      Returns:
      the number of values for the given position
    • 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
    • isNull

      public boolean isNull(int position)
      Specified by:
      isNull in interface Block
      Parameters:
      position - the position
      Returns:
      true if the value stored at the given position is null, false otherwise
    • mayHaveNulls

      public boolean mayHaveNulls()
      Specified by:
      mayHaveNulls in interface Block
      Returns:
      true if some values might be null. False, if all values are guaranteed to be not null.
    • areAllValuesNull

      public boolean areAllValuesNull()
      Specified by:
      areAllValuesNull in interface Block
      Returns:
      true if all values in this block are guaranteed to be null.
    • mayHaveMultivaluedFields

      public boolean mayHaveMultivaluedFields()
      Description copied from interface: Block
      Can this block have multivalued fields? Blocks that return false will never return more than one from Block.getValueCount(int). This may return true for Blocks that do not have multivalued fields, but it will always answer quickly.
      Specified by:
      mayHaveMultivaluedFields in interface Block
    • doesHaveMultivaluedFields

      public boolean doesHaveMultivaluedFields()
      Description copied from interface: Block
      Does this block have multivalued fields? Unlike Block.mayHaveMultivaluedFields() this will never return a false positive. In other words, if this returns true then there are positions for which Block.getValueCount(int) will return more than 1. This will answer quickly if it can but may have to check all positions.
      Specified by:
      doesHaveMultivaluedFields in interface Block
    • lookup

      public org.elasticsearch.core.ReleasableIterator<? extends Block> 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
    • mvOrdering

      public Block.MvOrdering mvOrdering()
      Description copied from interface: Block
      How are multivalued fields ordered?
      Specified by:
      mvOrdering 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 in) 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 offset, 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