Skip to content
Snippets Groups Projects
Commit 5b2e85bb authored by Weiqi's avatar Weiqi
Browse files

Done with the hnsw

parent 7e6fcb84
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,35 @@ int test_insert() {
return 1;
}
int test_search() {
// Set dimensions holders and get the data.
size_t d, n;
float *xd = fvecs_read("sift_query.fvecs", &d, &n);
// Conversion.
int *data = float_to_int(xd, d * n);
// Cast d to integer.
int d_int = static_cast<int>(d);
// Encrypt the first three vectors.
Key key = setup(d_int);
Item *encrypted_data = encrypt_data(data, key, d, 6);
// Get the HNSW object.
HNSWGraph index(10, 30, 10, 40, 4, key, 10, 100);
// Do the insert.
for (int i = 0; i < 5; i++) index.insert(encrypted_data[i]);
// Check for whether the data is correct.
vector<int> result = index.search(encrypted_data[5], 3);
if (result.size() != 3) return 0;
return 1;
}
int main() {
// Init core and setup.
......@@ -52,6 +81,7 @@ int main() {
// Perform tests.
if (test_constructor() != 1) return 1;
if (test_insert() != 1) return 1;
if (test_search() != 1) return 1;
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment