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

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