Class ConstantFloatVector

java.lang.Object
org.elasticsearch.compute.data.AbstractNonThreadSafeRefCounted
org.elasticsearch.compute.data.ConstantFloatVector
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.lucene.util.Accountable, FloatVector, Vector, RefCounted, Releasable

public final class ConstantFloatVector extends AbstractNonThreadSafeRefCounted implements FloatVector
Vector implementation that stores a constant float value. This class is generated. Edit X-ConstantVector.java.st instead.
  • Method Details

    • getFloat

      public float getFloat(int position)
      Specified by:
      getFloat in interface FloatVector
    • 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
    • asBlock

      public FloatBlock asBlock()
      Description copied from interface: Vector
      Returns a new Block containing this vector.
      Specified by:
      asBlock in interface FloatVector
      Specified by:
      asBlock in interface Vector
      Returns:
      a new Block containing this vector
    • valueMaxByteSize

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

      public FloatVector 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 FloatVector
      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
    • keepMask

      public FloatBlock 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 FloatVector
      Specified by:
      keepMask in interface Vector
    • lookup

      public ReleasableIterator<FloatBlock> 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 FloatVector
      Specified by:
      lookup in interface Vector
    • slice

      public FloatVector slice(int beginInclusive, int endExclusive)
      Description copied from interface: FloatVector
      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 FloatVector
      Specified by:
      slice in interface Vector
    • 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
    • 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
    • deepCopy

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

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

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

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

      public String toString()
      Overrides:
      toString in class Object
    • 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