Interface Vector

All Superinterfaces:
org.apache.lucene.util.Accountable, AutoCloseable, Closeable, RefCounted, Releasable
All Known Subinterfaces:
BooleanVector, BytesRefVector, DoubleVector, FloatVector, IntVector, LongVector
All Known Implementing Classes:
AbstractArrowBufVector, BooleanArrayVector, BooleanArrowBufVector, BooleanBigArrayVector, BytesRefArrayVector, BytesRefArrowBufVector, ConstantBooleanVector, ConstantBytesRefVector, ConstantDoubleVector, ConstantFloatVector, ConstantIntVector, ConstantLongVector, ConstantNullVector, DirectBytesRefVector, DocVector, DoubleArrayVector, DoubleArrowBufVector, DoubleBigArrayVector, Float16ArrowBufVector, FloatArrayVector, FloatArrowBufVector, FloatBigArrayVector, Int16ArrowBufVector, Int8ArrowBufVector, IntArrayVector, IntArrowBufVector, IntBigArrayVector, LongArrayVector, LongArrowBufVector, LongBigArrayVector, LongMul1kArrowBufVector, OrdinalBytesRefVector, UInt16ArrowBufVector, UInt32ArrowBufVector, UInt8ArrowBufVector

public interface Vector extends org.apache.lucene.util.Accountable, RefCounted, 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);
 }
 
  • 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, int offset, int length)
      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 array
      offset - the start index in the positions array
      length - the number of positions to use from the array
      Returns:
      a filtered vector
    • filter

      default 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

      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
    • valueMaxByteSize

      int valueMaxByteSize()
      Returns the maximum byte size of any single value in this vector. For fixed-width types this is a constant. For BytesRef, this scans all values quickly.
      Returns:
      the maximum byte size of any single value in 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
    • attachReleasable

      void attachReleasable(Releasable releasable)
      Attaches a Releasable that is invoked exactly once when this vector's reference count reaches zero, immediately after its resources are released. May be called at most once; throws IllegalStateException if called after release or a second time.