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

public final class DocVector extends Object implements Vector
Vector where each entry references a lucene document.
  • Field Details

    • SHARD_SEGMENT_DOC_MAP_PER_ROW_OVERHEAD

      public static final int SHARD_SEGMENT_DOC_MAP_PER_ROW_OVERHEAD
      Per position memory cost to build the shard segment doc map required to load fields out of order.
      See Also:
  • Constructor Details

  • Method Details

    • shards

      public IntVector shards()
    • segments

      public IntVector segments()
    • docs

      public IntVector docs()
    • singleSegmentNonDecreasing

      public boolean singleSegmentNonDecreasing()
    • singleSegment

      public boolean singleSegment()
    • shardSegmentDocMapForwards

      public int[] shardSegmentDocMapForwards()
      Map from the positions in this page to the positions in lucene's native order for loading doc values.
    • shardSegmentDocMapBackwards

      public int[] shardSegmentDocMapBackwards()
      Reverse of shardSegmentDocMapForwards. If you load doc values in the "forward" order then you can call Block.filter(int...) on the loaded values with this array to put them in the same order as this Page.
    • asBlock

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

      public DocVector filter(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 Vector
      Parameters:
      positions - the positions to retain
      Returns:
      a filtered vector
    • keepMask

      public DocBlock 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 Vector
    • lookup

      public org.elasticsearch.core.ReleasableIterator<? extends Block> 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 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
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • ramBytesEstimated

      public static long ramBytesEstimated(IntVector shards, IntVector segments, IntVector docs, int[] shardSegmentDocMapForwards, int[] shardSegmentDocMapBackwards)
    • ramBytesUsed

      public long ramBytesUsed()
      Specified by:
      ramBytesUsed in interface org.apache.lucene.util.Accountable
    • 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

      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).
    • getPositionCount

      public final int getPositionCount()
      Description copied from interface: Vector
      The number of positions in this vector.
      Specified by:
      getPositionCount in interface Vector
      Returns:
      the number of positions
    • blockFactory

      public BlockFactory blockFactory()
      Description copied from interface: Vector
      The block factory associated with this vector.
      Specified by:
      blockFactory in interface Vector
    • 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()