Class AggregateMetricDoubleArrayBlock

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

public final class AggregateMetricDoubleArrayBlock extends AbstractDelegatingCompoundBlock<AggregateMetricDoubleBlock> implements AggregateMetricDoubleBlock
  • Field Details

  • Constructor Details

  • Method Details

    • fromCompositeBlock

      public static AggregateMetricDoubleArrayBlock fromCompositeBlock(CompositeBlock block)
    • asCompositeBlock

      public CompositeBlock asCompositeBlock()
    • 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
    • getSubBlocks

      protected List<Block> getSubBlocks()
      Specified by:
      getSubBlocks in class AbstractDelegatingCompoundBlock<AggregateMetricDoubleBlock>
      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 AggregateMetricDoubleArrayBlock 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<AggregateMetricDoubleBlock>
      Parameters:
      subBlocks - List of sub-blocks, in the same order as AbstractDelegatingCompoundBlock.getSubBlocks()
      Returns:
      a new instance based on the given blocks.
    • 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 AggregateMetricDoubleBlock> 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 AggregateMetricDoubleBlock
      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 AggregateMetricDoubleBlock 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 AggregateMetricDoubleBlock
      Specified by:
      expand in interface Block
    • 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 Block readFrom(StreamInput in) throws IOException
      Throws:
      IOException
    • equals

      public boolean equals(Object obj)
      Description copied from interface: AggregateMetricDoubleBlock
      Compares the given object with this block for equality. Returns true if and only if the given object is a AggregateMetricDoubleBlock, and both blocks are equal.
      Specified by:
      equals in interface AggregateMetricDoubleBlock
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Description copied from interface: AggregateMetricDoubleBlock
      Returns the hash code of this block, as defined by AggregateMetricDoubleBlock.hash(AggregateMetricDoubleBlock).
      Specified by:
      hashCode in interface AggregateMetricDoubleBlock
      Overrides:
      hashCode in class Object
    • minBlock

      public DoubleBlock minBlock()
      Specified by:
      minBlock in interface AggregateMetricDoubleBlock
    • maxBlock

      public DoubleBlock maxBlock()
      Specified by:
      maxBlock in interface AggregateMetricDoubleBlock
    • sumBlock

      public DoubleBlock sumBlock()
      Specified by:
      sumBlock in interface AggregateMetricDoubleBlock
    • countBlock

      public IntBlock countBlock()
      Specified by:
      countBlock in interface AggregateMetricDoubleBlock
    • getMetricBlock

      public Block getMetricBlock(int index)
      Specified by:
      getMetricBlock in interface AggregateMetricDoubleBlock
    • toString

      public String toString()
      Overrides:
      toString in class Object