Package org.apache.lucene.index

## Class VectorValues

- java.lang.Object
- - org.apache.lucene.search.DocIdSetIterator
  - - org.apache.lucene.index.VectorValues

- Direct Known Subclasses:
    `FilterVectorValues`

      public abstract class VectorValues
      extends DocIdSetIterator

  This class provides access to per-document floating point vector values indexed as `KnnVectorField`.
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static VectorValues` | `EMPTY` | Represents the lack of vector values.
    `static int` | `MAX_DIMENSIONS` | The maximum length of a vector

    - ### Fields inherited from class org.apache.lucene.search.DocIdSetIterator

      `NO_MORE_DOCS`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `VectorValues()` | Sole constructor

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `BytesRef` | `binaryValue()` | Return the binary encoded vector value for the current document ID.
    `abstract int` | `dimension()` | Return the dimension of the vectors
    `abstract int` | `size()` | TODO: should we use cost() for this? We rely on its always being exactly the number of documents having a value for this field, which is not guaranteed by the cost() contract, but in all the implementations so far they are the same.
    `abstract float[]` | `vectorValue()` | Return the vector value for the current document ID.

    - ### Methods inherited from class org.apache.lucene.search.DocIdSetIterator

      `advance, all, cost, docID, empty, nextDoc, range, slowAdvance`

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

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

- - ### Field Detail

    - #### MAX_DIMENSIONS

          public static final int MAX_DIMENSIONS

      The maximum length of a vector
      See Also:
        Constant Field Values

    - #### EMPTY

          public static final VectorValues EMPTY

      Represents the lack of vector values. It is returned by providers that do not support VectorValues.

  - ### Constructor Detail

    - #### VectorValues

          protected VectorValues()

      Sole constructor

  - ### Method Detail

    - #### dimension

          public abstract int dimension()

      Return the dimension of the vectors

    - #### size

          public abstract int size()

      TODO: should we use cost() for this? We rely on its always being exactly the number of documents having a value for this field, which is not guaranteed by the cost() contract, but in all the implementations so far they are the same.
      Returns:
        the number of vectors returned by this iterator

    - #### vectorValue

          public abstract float[] vectorValue()
                                       throws IOException

      Return the vector value for the current document ID. It is illegal to call this method when the iterator is not positioned: before advancing, or after failing to advance. The returned array may be shared across calls, re-used, and modified as the iterator advances.
      Returns:
        the vector value
      Throws:
        `IOException`

    - #### binaryValue

          public BytesRef binaryValue()
                               throws IOException

      Return the binary encoded vector value for the current document ID. These are the bytes corresponding to the float array return by `vectorValue()`. It is illegal to call this method when the iterator is not positioned: before advancing, or after failing to advance. The returned storage may be shared across calls, re-used and modified as the iterator advances.
      Returns:
        the binary value
      Throws:
        `IOException`