Skip to content

Commit

Permalink
Fixed faiss tests to work with writeIndex
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Klepchick <[email protected]>
  • Loading branch information
MrFlap committed Aug 2, 2024
1 parent 7894e40 commit 4121df7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions jni/tests/faiss_index_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ TEST(CreateIndexTest, BasicAssertions) {
knn_jni::faiss_wrapper::IndexService indexService(std::move(mockFaissMethods));
long indexAddress = indexService.initIndex(&mockJNIUtil, jniEnv, metricType, indexDescription, dim, numIds, threadCount, parametersMap);
indexService.insertToIndex(dim, numIds, threadCount, (int64_t) &vectors, ids, indexAddress);
indexService.writeIndex(threadCount, indexPath, indexAddress);
indexService.writeIndex(indexPath, indexAddress);
}

TEST(CreateBinaryIndexTest, BasicAssertions) {
Expand Down Expand Up @@ -112,5 +112,5 @@ TEST(CreateBinaryIndexTest, BasicAssertions) {
knn_jni::faiss_wrapper::BinaryIndexService indexService(std::move(mockFaissMethods));
long indexAddress = indexService.initIndex(&mockJNIUtil, jniEnv, metricType, indexDescription, dim, numIds, threadCount, parametersMap);
indexService.insertToIndex(dim, numIds, threadCount, (int64_t) &vectors, ids, indexAddress);
indexService.writeIndex(threadCount, indexPath, indexAddress);
indexService.writeIndex(indexPath, indexAddress);
}
8 changes: 4 additions & 4 deletions jni/tests/faiss_wrapper_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void createIndexIteratively(
}
knn_jni::faiss_wrapper::InsertToIndex(JNIUtil, jniEnv, reinterpret_cast<jintArray>(&insertIds), (jlong)&insertVecs, dim, index_ptr, 0, indexService);
}
knn_jni::faiss_wrapper::WriteIndex(JNIUtil, jniEnv, (jstring)&indexPath, index_ptr, 0, indexService);
knn_jni::faiss_wrapper::WriteIndex(JNIUtil, jniEnv, (jstring)&indexPath, index_ptr, indexService);
}

void createBinaryIndexIteratively(
Expand Down Expand Up @@ -93,7 +93,7 @@ void createBinaryIndexIteratively(
}
knn_jni::faiss_wrapper::InsertToIndex(JNIUtil, jniEnv, reinterpret_cast<jintArray>(&insertIds), (jlong)&insertVecs, dim, index_ptr, 0, indexService);
}
knn_jni::faiss_wrapper::WriteIndex(JNIUtil, jniEnv, (jstring)&indexPath, index_ptr, 0, indexService);
knn_jni::faiss_wrapper::WriteIndex(JNIUtil, jniEnv, (jstring)&indexPath, index_ptr, indexService);
}

TEST(FaissCreateIndexTest, BasicAssertions) {
Expand Down Expand Up @@ -132,7 +132,7 @@ TEST(FaissCreateIndexTest, BasicAssertions) {
.Times(1);
EXPECT_CALL(mockIndexService, insertToIndex(dim, numIds / insertions, 0, _, _, _))
.Times(insertions);
EXPECT_CALL(mockIndexService, writeIndex(0, indexPath, _))
EXPECT_CALL(mockIndexService, writeIndex(indexPath, _))
.Times(1);

createIndexIteratively(&mockJNIUtil, jniEnv, ids, vectors, dim, indexPath, parametersMap, &mockIndexService, insertions);
Expand Down Expand Up @@ -174,7 +174,7 @@ TEST(FaissCreateBinaryIndexTest, BasicAssertions) {
.Times(1);
EXPECT_CALL(mockIndexService, insertToIndex(dim, numIds / insertions, 0, _, _, _))
.Times(insertions);
EXPECT_CALL(mockIndexService, writeIndex(0, indexPath, _))
EXPECT_CALL(mockIndexService, writeIndex(indexPath, _))
.Times(1);

// This method calls delete vectors at the end
Expand Down
1 change: 0 additions & 1 deletion jni/tests/mocks/faiss_index_service_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class MockIndexService : public IndexService {
void,
writeIndex,
(
int threadCount,
std::string indexPath,
long indexPtr
),
Expand Down

0 comments on commit 4121df7

Please sign in to comment.