Package org.apache.lucene.index

# Class KnnVectorValues

java.lang.Object
org.apache.lucene.index.KnnVectorValues

Direct Known Subclasses:
  `ByteVectorValues`, `FloatVectorValues`

public abstract class KnnVectorValues extends Object
This class abstracts addressing of document vector values indexed as `KnnFloatVectorField` or `KnnByteVectorField`.

WARNING: This API is experimental and might change in incompatible ways in the next release.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `KnnVectorValues.DocIndexIterator`
  A DocIdSetIterator that also provides an index() method tracking a distinct ordinal for a vector associated with each doc.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `KnnVectorValues()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract KnnVectorValues`
  `copy()`
  Creates a new copy of this `KnnVectorValues`.
  `protected KnnVectorValues.DocIndexIterator`
  `createDenseIterator()`
  Creates an iterator for instances where every doc has a value, and the value ordinals are equal to the docids.
  `protected KnnVectorValues.DocIndexIterator`
  `createSparseIterator()`
  Creates an iterator from this instance's ordinal-to-docid mapping which must be monotonic (docid increases when ordinal does).
  `abstract int`
  `dimension()`
  Return the dimension of the vectors
  `protected static KnnVectorValues.DocIndexIterator`
  `fromDISI(DocIdSetIterator docsWithField)`
  Creates an iterator from a DocIdSetIterator indicating which docs have values, and for which ordinals increase monotonically with docid.
  `Bits`
  `getAcceptOrds(Bits acceptDocs)`
  Returns a Bits accepting docs accepted by the argument and having a vector value
  `abstract VectorEncoding`
  `getEncoding()`
  The vector encoding of these values.
  `int`
  `getVectorByteLength()`
  Returns the vector byte length, defaults to dimension multiplied by float byte size
  `KnnVectorValues.DocIndexIterator`
  `iterator()`
  Create an iterator for this instance.
  `int`
  `ordToDoc(int ord)`
  Return the docid of the document indexed with the given vector ordinal.
  `abstract int`
  `size()`
  Return the number of vectors for this field.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### KnnVectorValues

    public KnnVectorValues()

- ## Method Details

  - ### dimension

    public abstract int dimension()
    Return the dimension of the vectors

  - ### size

    public abstract int size()
    Return the number of vectors for this field.
    Returns:
      the number of vectors returned by this iterator

  - ### ordToDoc

    public int ordToDoc(int ord)
    Return the docid of the document indexed with the given vector ordinal. This default implementation returns the argument and is appropriate for dense values implementations where every doc has a single value.

  - ### copy

    public abstract KnnVectorValues copy() throws IOException
    Creates a new copy of this `KnnVectorValues`. This is helpful when you need to access different values at once, to avoid overwriting the underlying vector returned.
    Throws:
      `IOException`

  - ### getVectorByteLength

    public int getVectorByteLength()
    Returns the vector byte length, defaults to dimension multiplied by float byte size

  - ### getEncoding

    public abstract VectorEncoding getEncoding()
    The vector encoding of these values.

  - ### getAcceptOrds

    public Bits getAcceptOrds(Bits acceptDocs)
    Returns a Bits accepting docs accepted by the argument and having a vector value

  - ### iterator

    public KnnVectorValues.DocIndexIterator iterator()
    Create an iterator for this instance.

  - ### createDenseIterator

    protected KnnVectorValues.DocIndexIterator createDenseIterator()
    Creates an iterator for instances where every doc has a value, and the value ordinals are equal to the docids.

  - ### fromDISI

    protected static KnnVectorValues.DocIndexIterator fromDISI(DocIdSetIterator docsWithField)
    Creates an iterator from a DocIdSetIterator indicating which docs have values, and for which ordinals increase monotonically with docid.

  - ### createSparseIterator

    protected KnnVectorValues.DocIndexIterator createSparseIterator()
    Creates an iterator from this instance's ordinal-to-docid mapping which must be monotonic (docid increases when ordinal does).