Skip to content

Commit

Permalink
Fixing the issue with Faiss engine for vector streaming from java to …
Browse files Browse the repository at this point in the history
…jni layer

Signed-off-by: Navneet Verma <[email protected]>
  • Loading branch information
navneet1v committed Mar 2, 2024
1 parent aa6c170 commit 4be6171
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions jni/src/faiss_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,12 @@ void knn_jni::faiss_wrapper::CreateIndex_With_Memory_Address(knn_jni::JNIUtilInt
//auto dataset = jniUtil->Convert2dJavaObjectArrayToCppFloatVector(env, vectorsJ, dim);
//auto dataset = jniUtil->GetFloatArrayElements(env, )
std::vector<float> dataset;
long long topLevelPointer = 0;
for (int i = 0; i < numVectors; i++) {
dataset.push_back(inputVectors->at(i));
for(int j = 0 ; j < dim; j++) {
dataset.push_back(inputVectors->at(topLevelPointer));
topLevelPointer++;
}
}


Expand Down Expand Up @@ -309,8 +313,12 @@ void knn_jni::faiss_wrapper::CreateIndexFromTemplate_With_Memory_Address(knn_jni
//int dim = jniUtil->GetInnerDimensionOf2dJavaFloatArray(env, vectorsJ);
//auto dataset = jniUtil->Convert2dJavaObjectArrayToCppFloatVector(env, vectorsJ, dim);
std::vector<float> dataset;
long long topLevelPointer = 0;
for (int i = 0; i < numVectors; i++) {
dataset.push_back(inputVectors->at(i));
for(int j = 0 ; j < dim; j++) {
dataset.push_back(inputVectors->at(topLevelPointer));
topLevelPointer++;
}
}

// Get vector of bytes from jbytearray
Expand Down

0 comments on commit 4be6171

Please sign in to comment.