Skip to content

Commit 6d8168b

Browse files
cwlacewemichaelbeale-ILifadamssys-vdmsrv355
authored
V2.10 hnswfix (#235)
* 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>
1 parent ad8076b commit 6d8168b

File tree

4 files changed

+68
-1
lines changed

4 files changed

+68
-1
lines changed

tests/unit_tests/client_descriptors.cc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,34 @@ TEST(CLIENT_CPP, add_flinng_descriptor) {
5656

5757
EXPECT_EQ(status1, 0);
5858
}
59+
TEST(CLIENT_CPP, add_hnsw_descriptor) {
60+
std::vector<float> fv_values;
61+
srand((unsigned)time(NULL));
62+
for (int i = 0; i < 100; i++)
63+
fv_values.push_back((float)rand() / RAND_MAX);
64+
65+
std::vector<std::string *> blobs;
66+
std::string *bytes_str = new std::string();
67+
bytes_str->resize(fv_values.size() * sizeof(float));
68+
std::memcpy((void *)bytes_str->data(), fv_values.data(),
69+
fv_values.size() * sizeof(float));
70+
blobs.push_back(bytes_str);
71+
72+
Meta_Data *meta_obj = new Meta_Data();
73+
meta_obj->_aclient.reset(
74+
new VDMS::VDMSClient(meta_obj->get_server(), meta_obj->get_port()));
75+
Json::Value tuple;
76+
tuple = meta_obj->construct_hnsw_descriptor();
77+
78+
VDMS::Response response =
79+
meta_obj->_aclient->query(meta_obj->_fastwriter.write(tuple), blobs);
80+
Json::Value result;
81+
meta_obj->_reader.parse(response.json.c_str(), result);
82+
83+
int status1 = result[0]["AddDescriptor"]["status"].asInt();
84+
85+
EXPECT_EQ(status1, 0);
86+
}
5987

6088
TEST(CLIENT_CPP, find_descriptor) {
6189

tests/unit_tests/meta_data.cc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,43 @@ Json::Value Meta_Data::construct_flinng_descriptor() {
4545
return tuple;
4646
}
4747

48+
Json::Value Meta_Data::construct_hnsw_Set(std::string &name, int &dim) {
49+
50+
Json::Value descriptor_set;
51+
Json::Value set_query;
52+
Json::Value tuple;
53+
descriptor_set["name"] = name;
54+
descriptor_set["dimensions"] = dim;
55+
descriptor_set["metric"] = "L2";
56+
descriptor_set["engine"] = "FaissHNSWFlat";
57+
set_query["AddDescriptorSet"] = descriptor_set;
58+
59+
return set_query;
60+
}
61+
62+
Json::Value Meta_Data::construct_hnsw_descriptor() {
63+
Json::Value tuple;
64+
std::shared_ptr<VDMS::VDMSClient> test_aclient;
65+
std::string name = "hnsw_test_2060";
66+
int dim = 100;
67+
tuple.append(construct_hnsw_Set(name, dim));
68+
test_aclient.reset(new VDMS::VDMSClient(get_server(), get_port()));
69+
VDMS::Response response = test_aclient->query(_fastwriter.write(tuple));
70+
Json::Value result;
71+
_reader.parse(response.json.c_str(), result);
72+
Json::Value AddDesc;
73+
Json::Value Desc;
74+
75+
Desc["set"] = "hnsw_test_2060";
76+
Desc["label"] = "Person";
77+
Desc["_ref"] = 1;
78+
Desc["properties"]["id"] = 123;
79+
Desc["properties"]["name"] = "Jane Doe";
80+
AddDesc["AddDescriptor"] = Desc;
81+
tuple.append(AddDesc);
82+
return tuple;
83+
}
84+
4885
Json::Value Meta_Data::construct_descriptor() {
4986
Json::Value descriptor_set;
5087
Json::Value set_query;

tests/unit_tests/meta_data_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class Meta_Data {
5555
Json::Value construct_flinng_descriptor();
5656
Json::Value construct_find_flinng_descriptor();
5757
Json::Value construct_Flinng_Set(std::string &, int &);
58+
Json::Value construct_hnsw_descriptor();
59+
Json::Value construct_hnsw_Set(std::string &, int &);
5860
std::string get_server() { return _server_name; }
5961
int get_port() { return _port; }
6062
};

utils/src/api_schema/api_schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130

131131
"engineFormatString": {
132132
"type": "string",
133-
"enum": ["FaissFlat", "FaissIVFFlat", "TileDBDense", "TileDBSparse", "Flinng"]
133+
"enum": ["FaissFlat", "FaissHNSWFlat", "FaissIVFFlat", "TileDBDense", "TileDBSparse", "Flinng"]
134134
},
135135

136136
"vidCodecString": {

0 commit comments

Comments
 (0)