- java.lang.Object
-
- org.apache.lucene.codecs.KnnVectorsFormat
-
- All Implemented Interfaces:
NamedSPILoader.NamedSPI
- Direct Known Subclasses:
HnswBitVectorsFormat
,Lucene90HnswVectorsFormat
,Lucene91HnswVectorsFormat
,Lucene92HnswVectorsFormat
,Lucene94HnswVectorsFormat
,Lucene95HnswVectorsFormat
,Lucene99HnswScalarQuantizedVectorsFormat
,Lucene99HnswVectorsFormat
,PerFieldKnnVectorsFormat
,SimpleTextKnnVectorsFormat
public abstract class KnnVectorsFormat extends java.lang.Object implements NamedSPILoader.NamedSPI
Encodes/decodes per-document vector and any associated indexing structures required to support nearest-neighbor search
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
KnnVectorsFormat.Holder
This static holder class prevents classloading deadlock by delaying init of doc values formats until needed.
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_DIMENSIONS
The maximum number of vector dimensionsstatic KnnVectorsFormat
EMPTY
EMPTY throws an exception when written.private java.lang.String
name
-
Constructor Summary
Constructors Modifier Constructor Description protected
KnnVectorsFormat(java.lang.String name)
Sole constructor
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static java.util.Set<java.lang.String>
availableKnnVectorsFormats()
returns a list of all available format namesabstract KnnVectorsReader
fieldsReader(SegmentReadState state)
Returns aKnnVectorsReader
to read the vectors from the index.abstract KnnVectorsWriter
fieldsWriter(SegmentWriteState state)
Returns aKnnVectorsWriter
to write the vectors to the index.static KnnVectorsFormat
forName(java.lang.String name)
looks up a format by nameint
getMaxDimensions(java.lang.String fieldName)
Returns the maximum number of vector dimensions supported by this codec for the given field namejava.lang.String
getName()
static void
reloadKnnVectorsFormat(java.lang.ClassLoader classloader)
Reloads the KnnVectorsFormat list from the givenClassLoader
.
-
-
-
Field Detail
-
DEFAULT_MAX_DIMENSIONS
public static final int DEFAULT_MAX_DIMENSIONS
The maximum number of vector dimensions- See Also:
- Constant Field Values
-
name
private final java.lang.String name
-
EMPTY
public static final KnnVectorsFormat EMPTY
EMPTY throws an exception when written. It acts as a sentinel indicating a Codec that does not support vectors.
-
-
Method Detail
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceNamedSPILoader.NamedSPI
-
reloadKnnVectorsFormat
public static void reloadKnnVectorsFormat(java.lang.ClassLoader classloader)
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
public static KnnVectorsFormat forName(java.lang.String name)
looks up a format by name
-
availableKnnVectorsFormats
public static java.util.Set<java.lang.String> availableKnnVectorsFormats()
returns a list of all available format names
-
fieldsWriter
public abstract KnnVectorsWriter fieldsWriter(SegmentWriteState state) throws java.io.IOException
Returns aKnnVectorsWriter
to write the vectors to the index.- Throws:
java.io.IOException
-
fieldsReader
public abstract KnnVectorsReader fieldsReader(SegmentReadState state) throws java.io.IOException
Returns aKnnVectorsReader
to read the vectors from the index.- Throws:
java.io.IOException
-
getMaxDimensions
public int getMaxDimensions(java.lang.String fieldName)
Returns the maximum number of vector dimensions supported by this codec for the given field nameCodecs should override this method to specify the maximum number of dimensions they support.
- Parameters:
fieldName
- the field name- Returns:
- the maximum number of vector dimensions.
-
-