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.
Integrates FAISS iterative builds with NativeEngines990KnnVectorsFormat
Changes include reusing the same vector buffer in the JNI layer Signed-off-by: Tejas Shah <[email protected]>
- Loading branch information
Showing
42 changed files
with
1,355 additions
and
1,040 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
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
40 changes: 40 additions & 0 deletions
40
src/main/java/org/opensearch/knn/common/FieldInfoExtractor.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,40 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.knn.common; | ||
|
||
import lombok.experimental.UtilityClass; | ||
import org.apache.lucene.index.FieldInfo; | ||
import org.opensearch.knn.index.VectorDataType; | ||
import org.opensearch.knn.index.engine.KNNEngine; | ||
import org.opensearch.knn.indices.ModelMetadata; | ||
|
||
import static org.opensearch.knn.common.KNNConstants.MODEL_ID; | ||
import static org.opensearch.knn.indices.ModelUtil.getModelMetadata; | ||
|
||
@UtilityClass | ||
public class FieldInfoExtractor { | ||
|
||
public static KNNEngine extractKNNEngine(final FieldInfo field) { | ||
final ModelMetadata modelMetadata = getModelMetadata(field.attributes().get(MODEL_ID)); | ||
if (modelMetadata != null) { | ||
return modelMetadata.getKnnEngine(); | ||
} | ||
final String engineName = field.attributes().getOrDefault(KNNConstants.KNN_ENGINE, KNNEngine.DEFAULT.getName()); | ||
return KNNEngine.getEngine(engineName); | ||
} | ||
|
||
public static VectorDataType extractVectorDataType(final FieldInfo field) { | ||
String vectorDataTypeString = field.getAttribute(KNNConstants.VECTOR_DATA_TYPE_FIELD); | ||
if (vectorDataTypeString == null) { | ||
final ModelMetadata modelMetadata = getModelMetadata(field.attributes().get(MODEL_ID)); | ||
if (modelMetadata != null) { | ||
VectorDataType vectorDataType = modelMetadata.getVectorDataType(); | ||
vectorDataTypeString = vectorDataType == null ? null : vectorDataType.getValue(); | ||
} | ||
} | ||
return vectorDataTypeString != null ? VectorDataType.get(vectorDataTypeString) : VectorDataType.DEFAULT; | ||
} | ||
} |
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
Oops, something went wrong.