Package org.apache.lucene.codecs
Class KnnVectorsFormat
java.lang.Object
org.apache.lucene.codecs.KnnVectorsFormat
- All Implemented Interfaces:
NamedSPILoader.NamedSPI
- Direct Known Subclasses:
FlatVectorsFormat,Lucene102HnswBinaryQuantizedVectorsFormat,Lucene99HnswScalarQuantizedVectorsFormat,Lucene99HnswVectorsFormat,PerFieldKnnVectorsFormat
Encodes/decodes per-document vector and any associated indexing structures required to support
nearest-neighbor search
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe maximum number of vector dimensionsstatic final KnnVectorsFormatEMPTY throws an exception when written. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreturns a list of all available format namesabstract KnnVectorsReaderfieldsReader(SegmentReadState state) Returns aKnnVectorsReaderto read the vectors from the index.abstract KnnVectorsWriterfieldsWriter(SegmentWriteState state) Returns aKnnVectorsWriterto write the vectors to the index.static KnnVectorsFormatlooks up a format by nameabstract intgetMaxDimensions(String fieldName) Returns the maximum number of vector dimensions supported by this codec for the given field namegetName()static voidreloadKnnVectorsFormat(ClassLoader classloader) Reloads the KnnVectorsFormat list from the givenClassLoader.
-
Field Details
-
DEFAULT_MAX_DIMENSIONS
public static final int DEFAULT_MAX_DIMENSIONSThe maximum number of vector dimensions- See Also:
-
EMPTY
EMPTY throws an exception when written. It acts as a sentinel indicating a Codec that does not support vectors.
-
-
Constructor Details
-
KnnVectorsFormat
Sole constructor
-
-
Method Details
-
getName
- Specified by:
getNamein interfaceNamedSPILoader.NamedSPI
-
reloadKnnVectorsFormat
Reloads the KnnVectorsFormat list from the givenClassLoader.NOTE: Only new KnnVectorsFormat are added, existing ones are never removed or replaced.
This method is expensive and should only be called for discovery of new KnnVectorsFormat on the given classpath/classloader!
-
forName
looks up a format by name -
availableKnnVectorsFormats
returns a list of all available format names -
fieldsWriter
Returns aKnnVectorsWriterto write the vectors to the index.- Throws:
IOException
-
fieldsReader
Returns aKnnVectorsReaderto read the vectors from the index.- Throws:
IOException
-
getMaxDimensions
Returns the maximum number of vector dimensions supported by this codec for the given field nameCodecs implement this method to specify the maximum number of dimensions they support.
- Parameters:
fieldName- the field name- Returns:
- the maximum number of vector dimensions.
-