Skip to content

Commit

Permalink
V2.10 hnswfix (#235)
Browse files Browse the repository at this point in the history
* Add HNSW to DescriptorSet Engine enum (#233)

* Update enum in api_schema.json and add client test using hnsw

* remove artifact

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Michael Beale <[email protected]>
Co-authored-by: Ian Adams <[email protected]>
Co-authored-by: sys_vdms <[email protected]>
Co-authored-by: Rohit Verma <[email protected]>
Co-authored-by: Sameh Gobriel <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
7 people authored Oct 14, 2024
1 parent ad8076b commit 6d8168b
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
28 changes: 28 additions & 0 deletions tests/unit_tests/client_descriptors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,34 @@ TEST(CLIENT_CPP, add_flinng_descriptor) {

EXPECT_EQ(status1, 0);
}
TEST(CLIENT_CPP, add_hnsw_descriptor) {
std::vector<float> fv_values;
srand((unsigned)time(NULL));
for (int i = 0; i < 100; i++)
fv_values.push_back((float)rand() / RAND_MAX);

std::vector<std::string *> blobs;
std::string *bytes_str = new std::string();
bytes_str->resize(fv_values.size() * sizeof(float));
std::memcpy((void *)bytes_str->data(), fv_values.data(),
fv_values.size() * sizeof(float));
blobs.push_back(bytes_str);

Meta_Data *meta_obj = new Meta_Data();
meta_obj->_aclient.reset(
new VDMS::VDMSClient(meta_obj->get_server(), meta_obj->get_port()));
Json::Value tuple;
tuple = meta_obj->construct_hnsw_descriptor();

VDMS::Response response =
meta_obj->_aclient->query(meta_obj->_fastwriter.write(tuple), blobs);
Json::Value result;
meta_obj->_reader.parse(response.json.c_str(), result);

int status1 = result[0]["AddDescriptor"]["status"].asInt();

EXPECT_EQ(status1, 0);
}

TEST(CLIENT_CPP, find_descriptor) {

Expand Down
37 changes: 37 additions & 0 deletions tests/unit_tests/meta_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,43 @@ Json::Value Meta_Data::construct_flinng_descriptor() {
return tuple;
}

Json::Value Meta_Data::construct_hnsw_Set(std::string &name, int &dim) {

Json::Value descriptor_set;
Json::Value set_query;
Json::Value tuple;
descriptor_set["name"] = name;
descriptor_set["dimensions"] = dim;
descriptor_set["metric"] = "L2";
descriptor_set["engine"] = "FaissHNSWFlat";
set_query["AddDescriptorSet"] = descriptor_set;

return set_query;
}

Json::Value Meta_Data::construct_hnsw_descriptor() {
Json::Value tuple;
std::shared_ptr<VDMS::VDMSClient> test_aclient;
std::string name = "hnsw_test_2060";
int dim = 100;
tuple.append(construct_hnsw_Set(name, dim));
test_aclient.reset(new VDMS::VDMSClient(get_server(), get_port()));
VDMS::Response response = test_aclient->query(_fastwriter.write(tuple));
Json::Value result;
_reader.parse(response.json.c_str(), result);
Json::Value AddDesc;
Json::Value Desc;

Desc["set"] = "hnsw_test_2060";
Desc["label"] = "Person";
Desc["_ref"] = 1;
Desc["properties"]["id"] = 123;
Desc["properties"]["name"] = "Jane Doe";
AddDesc["AddDescriptor"] = Desc;
tuple.append(AddDesc);
return tuple;
}

Json::Value Meta_Data::construct_descriptor() {
Json::Value descriptor_set;
Json::Value set_query;
Expand Down
2 changes: 2 additions & 0 deletions tests/unit_tests/meta_data_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class Meta_Data {
Json::Value construct_flinng_descriptor();
Json::Value construct_find_flinng_descriptor();
Json::Value construct_Flinng_Set(std::string &, int &);
Json::Value construct_hnsw_descriptor();
Json::Value construct_hnsw_Set(std::string &, int &);
std::string get_server() { return _server_name; }
int get_port() { return _port; }
};
2 changes: 1 addition & 1 deletion utils/src/api_schema/api_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@

"engineFormatString": {
"type": "string",
"enum": ["FaissFlat", "FaissIVFFlat", "TileDBDense", "TileDBSparse", "Flinng"]
"enum": ["FaissFlat", "FaissHNSWFlat", "FaissIVFFlat", "TileDBDense", "TileDBSparse", "Flinng"]
},

"vidCodecString": {
Expand Down

0 comments on commit 6d8168b

Please sign in to comment.