forked from opensearch-project/k-NN
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit for enabling the float vector values for vector search.
Things not working: 1. Filter query not working 2. Training index creation not tested.
- Loading branch information
Showing
16 changed files
with
693 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...main/java/org/opensearch/knn/index/codec/KNN990Codec/NativeEngines99KnnVectorsFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
package org.opensearch.knn.index.codec.KNN990Codec; | ||
|
||
import org.apache.lucene.codecs.hnsw.DefaultFlatVectorScorer; | ||
import org.apache.lucene.codecs.hnsw.FlatVectorsFormat; | ||
import org.apache.lucene.codecs.KnnVectorsFormat; | ||
import org.apache.lucene.codecs.KnnVectorsReader; | ||
import org.apache.lucene.codecs.KnnVectorsWriter; | ||
import org.apache.lucene.codecs.lucene99.Lucene99FlatVectorsFormat; | ||
import org.apache.lucene.index.SegmentReadState; | ||
import org.apache.lucene.index.SegmentWriteState; | ||
|
||
import java.io.IOException; | ||
|
||
public class NativeEngines99KnnVectorsFormat extends KnnVectorsFormat { | ||
|
||
/** The format for storing, reading, merging vectors on disk */ | ||
private static final FlatVectorsFormat flatVectorsFormat = new Lucene99FlatVectorsFormat(new DefaultFlatVectorScorer()); | ||
|
||
/** | ||
* Sole constructor | ||
* | ||
*/ | ||
public NativeEngines99KnnVectorsFormat() { | ||
super("NativeEngines99KnnVectorsFormat"); | ||
} | ||
|
||
/** | ||
* Returns a {@link KnnVectorsWriter} to write the vectors to the index. | ||
* | ||
* @param state | ||
*/ | ||
@Override | ||
public KnnVectorsWriter fieldsWriter(SegmentWriteState state) throws IOException { | ||
return new NativeEnginesKNNVectorsWriter(state, flatVectorsFormat.fieldsWriter(state)); | ||
} | ||
|
||
/** | ||
* Returns a {@link KnnVectorsReader} to read the vectors from the index. | ||
* | ||
* @param state | ||
*/ | ||
@Override | ||
public KnnVectorsReader fieldsReader(SegmentReadState state) throws IOException { | ||
return new NativeEnginesKNNVectorsReader(state, flatVectorsFormat.fieldsReader(state)); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "NativeEngines99KnnVectorsFormat(name=NativeEngines99KnnVectorsFormat, flatVectorsFormat=" + flatVectorsFormat + ")"; | ||
} | ||
|
||
} |
Oops, something went wrong.