Remove duplicated vector storage and rely on inline vectors for RAVV#145
Remove duplicated vector storage and rely on inline vectors for RAVV#145tjake wants to merge 11 commits into
Conversation
Signed-off-by: Jake Luciani <jake@datastax.com>
Signed-off-by: Jake Luciani <jake@datastax.com>
|
Before PR: After First Commit: After Second Commit: |
Signed-off-by: Jake Luciani <jake@datastax.com>
3147fd7 to
61bf31a
Compare
Signed-off-by: Jake Luciani <jake@datastax.com>
Signed-off-by: Jake Luciani <jake@datastax.com>
Signed-off-by: Jake Luciani <jake@datastax.com>
| @Override | ||
| public void addBinaryField(FieldInfo field, DocValuesProducer valuesProducer) throws IOException { | ||
| delegatee.addBinaryField(field, valuesProducer); | ||
| if (!(field.hasVectorValues() && extractKNNEngine(field) == KNNEngine.JVECTOR)) delegatee.addBinaryField(field, valuesProducer); |
There was a problem hiding this comment.
should we just change the conditions for isKNNBinaryFieldRequired() method?
We can place the condition exception for jVector engine there, and also avoid binary field creation altogether for FP vectors.
| assert mergeState != null; | ||
| assert mergeState.mergeFieldInfos != null; | ||
|
|
||
| for (DocValuesProducer docValuesProducer : mergeState.docValuesProducers) { |
There was a problem hiding this comment.
Should we just remove doc values all together for KNN fields?
There was a problem hiding this comment.
I think perhaps what we can do is actually to leverage the "DerivedSourceFormat", glancing at the plugin it seems like it's already there.
https://github.com/opensearch-project/opensearch-jvector/blob/main/src/main/java/org/opensearch/knn/index/codec/KNN9120Codec/DerivedSourceStoredFieldsFormat.java
Do you want to try and test with the derived source for the index and see if it achieves the same result?
|
Hi @tjake I think in order to remove the doc values we will need to introduce |
|
Changes from this PR were augmented to #167 and merged |
This pull request refactors the JVector codec implementation to remove dependencies on Lucene's flat vector format and related classes, streamlining the codebase and improving performance and memory management. The changes replace the use of
FlatVectorsWriterandFlatVectorsReaderwith internal data structures for handling float vectors, and update reader and writer logic accordingly.Most importantly this removes the second copy of vectors which was causing a doubling of disk usage per index.
Removal of Lucene Flat Vectors Dependencies
FlatVectorsWriter,FlatVectorsReader, and related classes fromJVectorWriter,JVectorReader, and supporting classes, replacing them with direct management of float vectors using internal lists and utility methods. [1] [2] [3] [4] [5]Refactoring Writer Logic
FieldWriterclass to store vectors in aList<VectorFloat<?>>instead of delegating toFlatFieldVectorsWriter, and adjusted vector addition and memory usage calculations to use the new structure. [1] [2] [3]Refactoring Reader Logic
JVectorReaderto remove references to flat vector reading and merging logic, simplifying float vector retrieval and integrity checks. [1] [2] [3] [4]Improvements to Vector Access and Memory Management
JVectorFloatVectorValuesto reuse a single vector object, reducing allocations. [1] [2]Miscellaneous Updates
@Overrideannotation forreadLong()inJVectorRandomAccessReaderto match the updated jVector version.### Description[Describe what this change achieves]
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.