Package org.apache.lucene.codecs
Class KnnVectorsWriter
java.lang.Object
org.apache.lucene.codecs.KnnVectorsWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Accountable
- Direct Known Subclasses:
BufferingKnnVectorsWriter
,FlatVectorsWriter
,Lucene99HnswVectorsWriter
Writes vectors to an index.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
View over multiple vector values supporting iterator-style access via DocIdMerger. -
Field Summary
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract KnnFieldVectorsWriter
<?> Add new field for indexingabstract void
finish()
Called once at the end before closeabstract void
flush
(int maxDoc, Sorter.DocMap sortMap) Flush all buffered data on disk *static void
mapOldOrdToNewOrd
(DocsWithFieldSet oldDocIds, Sorter.DocMap sortMap, int[] old2NewOrd, int[] new2OldOrd, DocsWithFieldSet newDocsWithField) Given old doc ids and an id mapping, maps old ordinal to new ordinal.final void
merge
(MergeState mergeState) Merges the segment vectors for all fields.void
mergeOneField
(FieldInfo fieldInfo, MergeState mergeState) Write field for mergingMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.lucene.util.Accountable
getChildResources, ramBytesUsed
-
Constructor Details
-
KnnVectorsWriter
protected KnnVectorsWriter()Sole constructor
-
-
Method Details
-
addField
Add new field for indexing- Throws:
IOException
-
flush
Flush all buffered data on disk *- Throws:
IOException
-
mergeOneField
Write field for merging- Throws:
IOException
-
finish
Called once at the end before close- Throws:
IOException
-
merge
Merges the segment vectors for all fields. This default implementation delegates tomergeOneField(org.apache.lucene.index.FieldInfo, org.apache.lucene.index.MergeState)
, passing aKnnVectorsReader
that combines the vector values and ignores deleted documents.- Throws:
IOException
-
mapOldOrdToNewOrd
public static void mapOldOrdToNewOrd(DocsWithFieldSet oldDocIds, Sorter.DocMap sortMap, int[] old2NewOrd, int[] new2OldOrd, DocsWithFieldSet newDocsWithField) throws IOException Given old doc ids and an id mapping, maps old ordinal to new ordinal. Note: this method return nothing and output are written to parameters- Parameters:
oldDocIds
- the old or current document ordinals. Must not be null.sortMap
- the document sorting map for how to make the new ordinals. Must not be null.old2NewOrd
- int[] maps from old ord to new ordnew2OldOrd
- int[] maps from new ord to old ordnewDocsWithField
- set of new doc ids which has the value- Throws:
IOException
-