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.
Add faiss support in jni (opensearch-project#28)
Signed-off-by: Jack Mazanec <jmazane1@nd.edu>
- Loading branch information
1 parent
d7c55e9
commit 104a6ac
Showing
32 changed files
with
3,969 additions
and
1,091 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "jni/external/nmslib"] | ||
path = jni/external/nmslib | ||
url = https://github.com/nmslib/nmslib.git | ||
[submodule "jni/external/faiss"] | ||
path = jni/external/faiss | ||
url = https://github.com/facebookresearch/faiss.git |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#ifndef OPENSEARCH_KNN_FAISS_WRAPPER_H | ||
#define OPENSEARCH_KNN_FAISS_WRAPPER_H | ||
|
||
#include <jni.h> | ||
|
||
namespace knn_jni { | ||
namespace faiss_wrapper { | ||
// Create an index with ids and vectors. The configuration is defined by values in the Java map, parametersJ. | ||
// The index is serialized to indexPathJ. | ||
void CreateIndex(knn_jni::JNIUtilInterface * jniUtil, JNIEnv * env, jintArray idsJ, jobjectArray vectorsJ, | ||
jstring indexPathJ, jobject parametersJ); | ||
|
||
// Create an index with ids and vectors. Instead of creating a new index, this function creates the index | ||
// based off of the template index passed in. The index is serialized to indexPathJ. | ||
void CreateIndexFromTemplate(knn_jni::JNIUtilInterface * jniUtil, JNIEnv * env, jintArray idsJ, | ||
jobjectArray vectorsJ, jstring indexPathJ, jbyteArray templateIndexJ); | ||
|
||
// Load an index from indexPathJ into memory. | ||
// | ||
// Return a pointer to the loaded index | ||
jlong LoadIndex(knn_jni::JNIUtilInterface * jniUtil, JNIEnv * env, jstring indexPathJ); | ||
|
||
// Execute a query against the index located in memory at indexPointerJ. | ||
// | ||
// Return an array of KNNQueryResults | ||
jobjectArray QueryIndex(knn_jni::JNIUtilInterface * jniUtil, JNIEnv * env, jlong indexPointerJ, | ||
jfloatArray queryVectorJ, jint kJ); | ||
|
||
// Free the index located in memory at indexPointerJ | ||
void Free(jlong indexPointer); | ||
|
||
// Perform initilization operations for the library | ||
void InitLibrary(); | ||
|
||
// Create an empty index defined by the values in the Java map, parametersJ. Train the index with | ||
// the vector of floats located at trainVectorsPointerJ. | ||
// | ||
// Return the serialized representation | ||
jbyteArray TrainIndex(knn_jni::JNIUtilInterface * jniUtil, JNIEnv * env, jobject parametersJ, jint dimension, | ||
jlong trainVectorsPointerJ); | ||
} | ||
} | ||
|
||
#endif //OPENSEARCH_KNN_FAISS_WRAPPER_H |
Oops, something went wrong.