Interface Vector

All Superinterfaces:
org.apache.lucene.util.Accountable, AutoCloseable, Closeable, org.elasticsearch.core.RefCounted, org.elasticsearch.core.Releasable
All Known Subinterfaces:
BooleanVector, BytesRefVector, DoubleVector, FloatVector, IntVector, LongVector
All Known Implementing Classes:
AbstractArrowBufVector, BooleanArrowBufVector, BooleanBigArrayVector, BytesRefArrowBufVector, ConstantNullVector, DocVector, DoubleArrowBufVector, DoubleBigArrayVector, Float16ArrowBufVector, FloatArrowBufVector, FloatBigArrayVector, Int16ArrowBufVector, Int8ArrowBufVector, IntArrowBufVector, IntBigArrayVector, LongArrowBufVector, LongBigArrayVector, LongMul1kArrowBufVector, OrdinalBytesRefVector, UInt16ArrowBufVector, UInt32ArrowBufVector, UInt8ArrowBufVector

public interface Vector extends org.apache.lucene.util.Accountable, org.elasticsearch.core.RefCounted, org.elasticsearch.core.Releasable
A dense Vector of single values. This is effectively a kind of Block so it is reference counted in the same way.

The usual way to read a block looks like:


 for (int p = 0; p < block.getPositionCount(); p++) {
     // Do stuff with single valued data
     int v = block.getInt(p);
 }
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Builds Vectors.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final byte
     
    static final byte
     
    static final byte
     
    static final byte
     
    static final byte
    The serialization type of vectors: 0 and 1 replaces the boolean false/true in pre-8.14.

    Fields inherited from interface org.apache.lucene.util.Accountable

    NULL_ACCOUNTABLE

    Fields inherited from interface org.elasticsearch.core.RefCounted

    ALWAYS_REFERENCED
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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.
    Returns a new Block containing this vector.
    The block factory associated with this vector.
    deepCopy(BlockFactory blockFactory)
    Make a deep copy of this Block using the provided BlockFactory, likely copying all data.
    Returns the element type of this vector.
    filter(boolean mayContainDuplicates, int... positions)
    Creates a new vector that only exposes the positions provided.
    int
    Returns the number of positions (rows) in this vector.
    boolean
    Returns true iff this vector is a constant vector - returns the same constant value for every position.
    boolean
    Whether this vector was released
    Build a Block the same values as this Vector, but replacing all values for which mask.getBooleanValue(position) returns false with null.
    org.elasticsearch.core.ReleasableIterator<? extends Block>
    lookup(IntBlock positions, ByteSizeValue targetBlockSize)
    Builds an Iterator of new Blocks with the same elementType() as this Vector whose values are copied from positions in this Vector.
    slice(int beginInclusive, int endExclusive)
    Return a subset of this Vector from position beginInclusive to position endExclusive.

    Methods inherited from interface org.apache.lucene.util.Accountable

    getChildResources, ramBytesUsed

    Methods inherited from interface org.elasticsearch.core.RefCounted

    decRef, hasReferences, incRef, mustIncRef, tryIncRef

    Methods inherited from interface org.elasticsearch.core.Releasable

    close
  • Field Details

    • SERIALIZE_VECTOR_VALUES

      static final byte SERIALIZE_VECTOR_VALUES
      The serialization type of vectors: 0 and 1 replaces the boolean false/true in pre-8.14.
      See Also:
    • SERIALIZE_VECTOR_CONSTANT

      static final byte SERIALIZE_VECTOR_CONSTANT
      See Also:
    • SERIALIZE_VECTOR_ARRAY

      static final byte SERIALIZE_VECTOR_ARRAY
      See Also:
    • SERIALIZE_VECTOR_BIG_ARRAY

      static final byte SERIALIZE_VECTOR_BIG_ARRAY
      See Also:
    • SERIALIZE_VECTOR_ORDINAL

      static final byte SERIALIZE_VECTOR_ORDINAL
      See Also:
  • Method Details

    • asBlock

      Block asBlock()
      Returns a new Block containing this vector.
      Returns:
      a new Block containing this vector
    • getPositionCount

      int getPositionCount()
      Returns the number of positions (rows) in this vector. See class javadoc for the usual way to iterate these positions.
      Returns:
      the number of positions (rows) in this vector
    • filter

      Vector filter(boolean mayContainDuplicates, int... positions)
      Creates a new vector that only exposes the positions provided. Materialization of the selected positions is avoided.
      Parameters:
      mayContainDuplicates - may the positions array contain duplicate positions?
      positions - the positions to retain
      Returns:
      a filtered vector
    • keepMask

      Block keepMask(BooleanVector mask)
      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.
    • lookup

      org.elasticsearch.core.ReleasableIterator<? extends Block> lookup(IntBlock positions, ByteSizeValue targetBlockSize)
      Builds an Iterator of new Blocks with the same 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.

    • elementType

      ElementType elementType()
      Returns the element type of this vector.
      Returns:
      the element type of this vector
    • isConstant

      boolean isConstant()
      Returns true iff this vector is a constant vector - returns the same constant value for every position.
      Returns:
      true iff this vector is a constant vector - returns the same constant value for every position
    • blockFactory

      BlockFactory blockFactory()
      The block factory associated with this vector.
    • allowPassingToDifferentDriver

      void allowPassingToDifferentDriver()
      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.
    • slice

      Vector slice(int beginInclusive, int endExclusive)
      Return a subset of this Vector from position beginInclusive to position endExclusive. This may return the same instance if the range covers all positions, but if it does it will RefCounted.incRef() it.

      NOTE: Implementations will not try to optimize zero length slices as we expect them to be rare.

    • deepCopy

      Vector deepCopy(BlockFactory blockFactory)
      Make a deep copy of this Block using the provided BlockFactory, likely copying all data.
    • isReleased

      boolean isReleased()
      Whether this vector was released