Class ConstantNullBlock

java.lang.Object
org.elasticsearch.compute.data.ConstantNullBlock
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

public final class ConstantNullBlock extends Object implements BooleanBlock, IntBlock, LongBlock, FloatBlock, DoubleBlock, BytesRefBlock, AggregateMetricDoubleBlock
Block implementation representing a constant null value.
  • Method Details

    • asVector

      public ConstantNullVector 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
      Specified by:
      asVector in interface BooleanBlock
      Specified by:
      asVector in interface BytesRefBlock
      Specified by:
      asVector in interface DoubleBlock
      Specified by:
      asVector in interface FloatBlock
      Specified by:
      asVector in interface IntBlock
      Specified by:
      asVector in interface LongBlock
      Returns:
      an efficient dense single-value view of this block
    • asOrdinals

      public OrdinalBytesRefBlock asOrdinals()
      Description copied from interface: BytesRefBlock
      Returns 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:
      asOrdinals in interface BytesRefBlock
    • toMask

      public ToMask toMask()
      Description copied from interface: BooleanBlock
      Convert this to a "mask" that's appropriate for passing to BooleanBlock.keepMask(org.elasticsearch.compute.data.BooleanVector). Null and multivalued positions will be converted to false.
      Specified by:
      toMask in interface BooleanBlock
    • 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
    • areAllValuesNull

      public boolean areAllValuesNull()
      Specified by:
      areAllValuesNull in interface Block
      Returns:
      true if all values in this block are guaranteed to be null.
    • 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.
    • 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
    • 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
    • filter

      public ConstantNullBlock filter(int... positions)
      Description copied from interface: Block
      Creates a new block that only exposes the positions provided.
      Specified by:
      filter in interface AggregateMetricDoubleBlock
      Specified by:
      filter in interface Block
      Specified by:
      filter in interface BooleanBlock
      Specified by:
      filter in interface BytesRefBlock
      Specified by:
      filter in interface DoubleBlock
      Specified by:
      filter in interface FloatBlock
      Specified by:
      filter in interface IntBlock
      Specified by:
      filter in interface LongBlock
      Parameters:
      positions - the positions to retain
      Returns:
      a filtered block TODO: pass BlockFactory
    • keepMask

      public ConstantNullBlock 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 AggregateMetricDoubleBlock
      Specified by:
      keepMask in interface Block
      Specified by:
      keepMask in interface BooleanBlock
      Specified by:
      keepMask in interface BytesRefBlock
      Specified by:
      keepMask in interface DoubleBlock
      Specified by:
      keepMask in interface FloatBlock
      Specified by:
      keepMask in interface IntBlock
      Specified by:
      keepMask in interface LongBlock
    • lookup

      public org.elasticsearch.core.ReleasableIterator<ConstantNullBlock> 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
      Specified by:
      lookup in interface BooleanBlock
      Specified by:
      lookup in interface BytesRefBlock
      Specified by:
      lookup in interface DoubleBlock
      Specified by:
      lookup in interface FloatBlock
      Specified by:
      lookup in interface IntBlock
      Specified by:
      lookup in interface LongBlock
    • 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 BooleanBlock
      Specified by:
      writeTo in interface BytesRefBlock
      Specified by:
      writeTo in interface DoubleBlock
      Specified by:
      writeTo in interface FloatBlock
      Specified by:
      writeTo in interface IntBlock
      Specified by:
      writeTo in interface LongBlock
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • mvOrdering

      public Block.MvOrdering mvOrdering()
      Description copied from interface: Block
      How are multivalued fields ordered?
      Specified by:
      mvOrdering in interface Block
    • expand

      public ConstantNullBlock 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
      Specified by:
      expand in interface BooleanBlock
      Specified by:
      expand in interface BytesRefBlock
      Specified by:
      expand in interface DoubleBlock
      Specified by:
      expand in interface FloatBlock
      Specified by:
      expand in interface IntBlock
      Specified by:
      expand in interface LongBlock
    • ramBytesUsed

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

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

      public int hashCode()
      Description copied from interface: BooleanBlock
      Returns the hash code of this block, as defined by BooleanBlock.hash(BooleanBlock).
      Specified by:
      hashCode in interface AggregateMetricDoubleBlock
      Specified by:
      hashCode in interface BooleanBlock
      Specified by:
      hashCode in interface BytesRefBlock
      Specified by:
      hashCode in interface DoubleBlock
      Specified by:
      hashCode in interface FloatBlock
      Specified by:
      hashCode in interface IntBlock
      Specified by:
      hashCode in interface LongBlock
      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
    • 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: BooleanBlock
      Retrieves 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:
      getBoolean in interface BooleanBlock
      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: BytesRefBlock
      Retrieves 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:
      getBytesRef in interface BytesRefBlock
      Parameters:
      valueIndex - the value index
      dest - the destination
      Returns:
      the data value (as a BytesRef)
    • getFloat

      public float getFloat(int valueIndex)
      Description copied from interface: FloatBlock
      Retrieves 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:
      getFloat in interface FloatBlock
      Parameters:
      valueIndex - the value index
      Returns:
      the data value (as a float)
    • getDouble

      public double getDouble(int valueIndex)
      Description copied from interface: DoubleBlock
      Retrieves 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:
      getDouble in interface DoubleBlock
      Parameters:
      valueIndex - the value index
      Returns:
      the data value (as a double)
    • getInt

      public int getInt(int valueIndex)
      Description copied from interface: IntBlock
      Retrieves 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).

      Specified by:
      getInt in interface IntBlock
      Parameters:
      valueIndex - the value index
      Returns:
      the data value (as a int)
    • getLong

      public long getLong(int valueIndex)
      Description copied from interface: LongBlock
      Retrieves 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).

      Specified by:
      getLong in interface LongBlock
      Parameters:
      valueIndex - the value index
      Returns:
      the data value (as a long)
    • getTotalValueCount

      public int getTotalValueCount()
      Description copied from interface: Block
      Returns The total number of values in this block not counting nulls..
      Specified by:
      getTotalValueCount in interface Block
      Returns:
      The total number of values in this block not counting nulls.
    • getPositionCount

      public int getPositionCount()
      Description copied from interface: Block
      Returns The number of positions in this block..
      Specified by:
      getPositionCount in interface Block
      Returns:
      The number of positions in this block.
    • getFirstValueIndex

      public int getFirstValueIndex(int position)
      Description copied from interface: Block
      Gets the index of the first value for the given position.
      Specified by:
      getFirstValueIndex in interface Block
    • getValueCount

      public int getValueCount(int position)
      Description copied from interface: Block
      Gets the number of values for the given position, possibly 0.
      Specified by:
      getValueCount 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
    • 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
    • incRef

      public final void incRef()
      Specified by:
      incRef in interface org.elasticsearch.core.RefCounted
    • tryIncRef

      public final boolean tryIncRef()
      Specified by:
      tryIncRef in interface org.elasticsearch.core.RefCounted
    • decRef

      public final boolean decRef()
      Specified by:
      decRef in interface org.elasticsearch.core.RefCounted
    • hasReferences

      public final boolean hasReferences()
      Specified by:
      hasReferences in interface org.elasticsearch.core.RefCounted
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.elasticsearch.core.Releasable
    • isReleased

      public final boolean isReleased()