Class ConstantNullVector

java.lang.Object
org.elasticsearch.compute.data.AbstractNonThreadSafeRefCounted
org.elasticsearch.compute.data.ConstantNullVector
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.lucene.util.Accountable, BooleanVector, BytesRefVector, DoubleVector, FloatVector, IntVector, LongVector, Vector, RefCounted, Releasable

public final class ConstantNullVector extends AbstractNonThreadSafeRefCounted implements BooleanVector, BytesRefVector, DoubleVector, FloatVector, IntVector, LongVector
This vector is never instantiated. This class serves as a type holder for ConstantNullBlock.asVector().
  • Method Details

    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: BooleanVector
      Serializes this Vector to the given stream output.
      Specified by:
      writeTo in interface BooleanVector
      Specified by:
      writeTo in interface BytesRefVector
      Specified by:
      writeTo in interface DoubleVector
      Specified by:
      writeTo in interface FloatVector
      Specified by:
      writeTo in interface IntVector
      Specified by:
      writeTo in interface LongVector
      Throws:
      IOException
    • asBlock

      public ConstantNullBlock asBlock()
      Description copied from interface: Vector
      Returns a new Block containing this vector.
      Specified by:
      asBlock in interface BooleanVector
      Specified by:
      asBlock in interface BytesRefVector
      Specified by:
      asBlock in interface DoubleVector
      Specified by:
      asBlock in interface FloatVector
      Specified by:
      asBlock in interface IntVector
      Specified by:
      asBlock in interface LongVector
      Specified by:
      asBlock in interface Vector
      Returns:
      a new Block containing this vector
    • asOrdinals

      public OrdinalBytesRefVector asOrdinals()
      Description copied from interface: BytesRefVector
      Returns an ordinal BytesRef vector if this vector is backed by a dictionary and ordinals; otherwise, returns null. Callers must not release the returned vector as no extra reference is retained by this method.
      Specified by:
      asOrdinals in interface BytesRefVector
    • filter

      public ConstantNullVector filter(boolean mayContainDuplicates, int[] positions, int offset, int length)
      Description copied from interface: Vector
      Creates a new vector that only exposes the positions provided. Materialization of the selected positions is avoided.
      Specified by:
      filter in interface BooleanVector
      Specified by:
      filter in interface BytesRefVector
      Specified by:
      filter in interface DoubleVector
      Specified by:
      filter in interface FloatVector
      Specified by:
      filter in interface IntVector
      Specified by:
      filter in interface LongVector
      Specified by:
      filter in interface Vector
      Parameters:
      mayContainDuplicates - may the positions array contain duplicate positions?
      positions - the positions array
      offset - the start index in the positions array
      length - the number of positions to use from the array
      Returns:
      a filtered vector
    • filter

      public ConstantNullVector filter(boolean mayContainDuplicates, int... positions)
      Description copied from interface: Vector
      Creates a new vector that only exposes the positions provided. Materialization of the selected positions is avoided.
      Specified by:
      filter in interface BooleanVector
      Specified by:
      filter in interface BytesRefVector
      Specified by:
      filter in interface DoubleVector
      Specified by:
      filter in interface FloatVector
      Specified by:
      filter in interface IntVector
      Specified by:
      filter in interface LongVector
      Specified by:
      filter in interface Vector
      Parameters:
      mayContainDuplicates - may the positions array contain duplicate positions?
      positions - the positions to retain
      Returns:
      a filtered vector
    • deepCopy

      public ConstantNullVector deepCopy(BlockFactory blockFactory)
      Description copied from interface: BooleanVector
      Make a deep copy of this Vector using the provided BlockFactory, likely copying all data.
      Specified by:
      deepCopy in interface BooleanVector
      Specified by:
      deepCopy in interface BytesRefVector
      Specified by:
      deepCopy in interface DoubleVector
      Specified by:
      deepCopy in interface FloatVector
      Specified by:
      deepCopy in interface IntVector
      Specified by:
      deepCopy in interface LongVector
      Specified by:
      deepCopy in interface Vector
    • keepMask

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

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

      For example, if this vector contained [a, b, c] and were called with the block [0, 1, 1, [1, 2]] then the result would be [a, b, b, [b, c]].

      This process produces 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 BooleanVector
      Specified by:
      lookup in interface BytesRefVector
      Specified by:
      lookup in interface DoubleVector
      Specified by:
      lookup in interface FloatVector
      Specified by:
      lookup in interface IntVector
      Specified by:
      lookup in interface LongVector
      Specified by:
      lookup in interface Vector
    • getBoolean

      public boolean getBoolean(int position)
      Specified by:
      getBoolean in interface BooleanVector
    • getBytesRef

      public org.apache.lucene.util.BytesRef getBytesRef(int position, org.apache.lucene.util.BytesRef dest)
      Description copied from interface: BytesRefVector
      Build a contiguous array of bytes for the value stored at the given position. The underlying data is generally stored in pages that look like byte[][] with some data spanning more than one of the inner byte[] arrays. In that case, this builds a byte[] in the BytesRef, copies the bytes, and returns it. Otherwise, this returns a zero-copy snapshot of the underlying data. Except arrow. Arrow always copies.

      If possible, use BytesRefVector.get(int, org.elasticsearch.common.bytes.PagedBytesCursor) because it only needs to copy in the arrow implementation.

      Specified by:
      getBytesRef in interface BytesRefVector
      Parameters:
      position - the position index
      dest - the destination
      Returns:
      the data value (as a BytesRef)
    • get

      public PagedBytesCursor get(int position, PagedBytesCursor scratch)
      Description copied from interface: BytesRefVector
      Retrieves the bytes value stored at the given value index using a PagedBytesCursor for zero-copy access to the underlying paged byte storage. Except arrow. Arrow always copies.
      Specified by:
      get in interface BytesRefVector
      Parameters:
      position - the position index
      scratch - the cursor to initialize and return
      Returns:
      the initialized cursor pointing to the value's bytes
    • getFloat

      public float getFloat(int position)
      Specified by:
      getFloat in interface FloatVector
    • getDouble

      public double getDouble(int position)
      Specified by:
      getDouble in interface DoubleVector
    • getInt

      public int getInt(int position)
      Specified by:
      getInt in interface IntVector
    • getLong

      public long getLong(int position)
      Specified by:
      getLong in interface LongVector
    • copyTo

      public void copyTo(int srcPosition, long[] dst, int dstPosition, int length)
      Description copied from interface: LongVector
      Copies values from this vector into the destination array.
      Specified by:
      copyTo in interface LongVector
    • copyTo

      public void copyTo(int srcPosition, int[] dst, int dstPosition, int length)
      Description copied from interface: IntVector
      Copies values from this vector into the destination array.
      Specified by:
      copyTo in interface IntVector
    • copyTo

      public void copyTo(int srcPosition, double[] dst, int dstPosition, int length)
      Description copied from interface: DoubleVector
      Copies values from this vector into the destination array.
      Specified by:
      copyTo in interface DoubleVector
    • copyTo

      public void copyTo(int srcPosition, float[] dst, int dstPosition, int length)
      Description copied from interface: FloatVector
      Copies values from this vector into the destination array.
      Specified by:
      copyTo in interface FloatVector
    • copyTo

      public void copyTo(int srcPosition, boolean[] dst, int dstPosition, int length)
      Description copied from interface: BooleanVector
      Copies values from this vector into the destination array.
      Specified by:
      copyTo in interface BooleanVector
    • min

      public int min()
      Description copied from interface: IntVector
      The minimum value in the Vector. An empty Vector will return Integer.MAX_VALUE.
      Specified by:
      min in interface IntVector
    • max

      public int max()
      Description copied from interface: IntVector
      The maximum value in the Vector. An empty Vector will return Integer.MIN_VALUE.
      Specified by:
      max in interface IntVector
    • slice

      public ConstantNullVector slice(int beginInclusive, int endExclusive)
      Description copied from interface: BooleanVector
      Return a subset of this vector from beginInclusive to endExclusive. This may return the same instance if the range covers all positions, but if it does it will RefCounted.incRef() it.
      Specified by:
      slice in interface BooleanVector
      Specified by:
      slice in interface BytesRefVector
      Specified by:
      slice in interface DoubleVector
      Specified by:
      slice in interface FloatVector
      Specified by:
      slice in interface IntVector
      Specified by:
      slice in interface LongVector
      Specified by:
      slice in interface Vector
    • allTrue

      public boolean allTrue()
      Description copied from interface: BooleanVector
      Are all values true? This will scan all values to check and always answer accurately.
      Specified by:
      allTrue in interface BooleanVector
    • allFalse

      public boolean allFalse()
      Description copied from interface: BooleanVector
      Are all values false? This will scan all values to check and always answer accurately.
      Specified by:
      allFalse in interface BooleanVector
    • elementType

      public ElementType elementType()
      Description copied from interface: Vector
      Returns the element type of this vector.
      Specified by:
      elementType in interface Vector
      Returns:
      the element type of this vector
    • valueMaxByteSize

      public int valueMaxByteSize()
      Description copied from interface: BooleanVector
      The maximum size in bytes of any single value stored in this vector, or 0 if there are no values. Always Byte.BYTES since all boolean values encode to the same number of bytes.
      Specified by:
      valueMaxByteSize in interface BooleanVector
      Specified by:
      valueMaxByteSize in interface BytesRefVector
      Specified by:
      valueMaxByteSize in interface DoubleVector
      Specified by:
      valueMaxByteSize in interface FloatVector
      Specified by:
      valueMaxByteSize in interface IntVector
      Specified by:
      valueMaxByteSize in interface LongVector
      Specified by:
      valueMaxByteSize in interface Vector
      Returns:
      the maximum byte size of any single value in this vector
    • isConstant

      public boolean isConstant()
      Description copied from interface: Vector
      Returns true iff this vector is a constant vector - returns the same constant value for every position.
      Specified by:
      isConstant in interface Vector
      Returns:
      true iff this vector is a constant vector - returns the same constant value for every position
    • ramBytesUsed

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

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

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

      public void allowPassingToDifferentDriver()
      Description copied from interface: Vector
      Before passing a Vector 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 Vector, 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 Vector
    • 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