Skip to content

Commit

Permalink
Fixed the order of how vectors are transferred to JNI layer
Browse files Browse the repository at this point in the history
Signed-off-by: Navneet Verma <navneev@amazon.com>
  • Loading branch information
navneet1v committed Mar 1, 2024
1 parent d2e07c6 commit b87ed7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions jni/src/nmslib_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ void knn_jni::nmslib_wrapper::CreateIndex_With_Memory_Address(knn_jni::JNIUtilIn
topLevelPointer++;
}

// for(int j = 0; j < dim ; j++) {
// std::cout<<floatArrayCpp[j]<<" ";
// }
// std::cout<<std::endl;

memcpy(ptr, &floatArrayCpp, vectorSizeInBytes);
//jniUtil->ReleaseFloatArrayElements(env, floatArrayJ, floatArrayCpp, JNI_ABORT);
ptr += vectorSizeInBytes;
Expand Down
2 changes: 1 addition & 1 deletion jni/src/org_opensearch_knn_jni_FaissService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ JNIEXPORT jlong JNICALL Java_org_opensearch_knn_jni_FaissService_transferVectors

int dim = jniUtil.GetInnerDimensionOf2dJavaFloatArray(env, vectorsJ);
auto dataset = jniUtil.Convert2dJavaObjectArrayToCppFloatVector(env, vectorsJ, dim);
vect->insert(vect->begin(), dataset.begin(), dataset.end());
vect->insert(vect->end(), dataset.begin(), dataset.end());

return (jlong) vect;
}
Expand Down

0 comments on commit b87ed7f

Please sign in to comment.