@@ -46,6 +46,7 @@ TEST_CASE("init constructor", "[api_ivf_pq_index]") {
4646 a.partitioning_index_type_string () ==
4747 datatype_to_string (TILEDB_UINT32));
4848 CHECK (dimensions (a) == 0 );
49+ CHECK (a.distance_metric () == DistanceMetric::SUM_OF_SQUARES);
4950 }
5051
5152 SECTION (" float uint32 uint32" ) {
@@ -202,6 +203,7 @@ TEST_CASE("create empty index and then train and query", "[api_ivf_pq_index]") {
202203 CHECK (index.feature_type_string () == feature_type);
203204 CHECK (index.id_type_string () == id_type);
204205 CHECK (index.partitioning_index_type_string () == partitioning_index_type);
206+ CHECK (index.distance_metric () == DistanceMetric::SUM_OF_SQUARES);
205207 }
206208
207209 {
@@ -242,6 +244,7 @@ TEST_CASE(
242244 auto partitioning_index_type = " uint32" ;
243245 uint64_t dimensions = 3 ;
244246 uint32_t num_subspaces = 1 ;
247+ auto distance_metric = DistanceMetric::L2;
245248
246249 std::string index_uri =
247250 (std::filesystem::temp_directory_path () / " api_ivf_pq_index" ).string ();
@@ -251,13 +254,14 @@ TEST_CASE(
251254 }
252255
253256 {
254- auto index = IndexIVFPQ (std::make_optional<IndexOptions>({
255- {" feature_type" , feature_type},
256- {" id_type" , id_type},
257- {" partitioning_index_type" , partitioning_index_type},
258- {" dimensions" , std::to_string (dimensions)},
259- {" num_subspaces" , std::to_string (num_subspaces)},
260- }));
257+ auto index = IndexIVFPQ (std::make_optional<IndexOptions>(
258+ {{" feature_type" , feature_type},
259+ {" id_type" , id_type},
260+ {" partitioning_index_type" , partitioning_index_type},
261+ {" dimensions" , std::to_string (dimensions)},
262+ {" num_subspaces" , std::to_string (num_subspaces)},
263+ {" distance_metric" ,
264+ std::to_string (static_cast <size_t >(distance_metric))}}));
261265
262266 size_t num_vectors = 0 ;
263267 auto empty_training_vector_array =
@@ -271,6 +275,7 @@ TEST_CASE(
271275 CHECK (index.partitioning_index_type_string () == partitioning_index_type);
272276 CHECK (index.dimensions () == dimensions);
273277 CHECK (index.num_subspaces () == num_subspaces);
278+ CHECK (index.distance_metric () == distance_metric);
274279 }
275280
276281 {
@@ -281,6 +286,7 @@ TEST_CASE(
281286 CHECK (index.partitioning_index_type_string () == partitioning_index_type);
282287 CHECK (index.dimensions () == dimensions);
283288 CHECK (index.num_subspaces () == num_subspaces);
289+ CHECK (index.distance_metric () == distance_metric);
284290 auto training = ColMajorMatrixWithIds<feature_type_type, id_type_type>{
285291 {{8 , 6 , 7 }, {5 , 3 , 0 }, {9 , 5 , 0 }, {2 , 7 , 3 }}, {10 , 11 , 12 , 13 }};
286292
@@ -292,6 +298,9 @@ TEST_CASE(
292298 CHECK (index.feature_type_string () == feature_type);
293299 CHECK (index.id_type_string () == id_type);
294300 CHECK (index.partitioning_index_type_string () == partitioning_index_type);
301+ CHECK (index.dimensions () == dimensions);
302+ CHECK (index.num_subspaces () == num_subspaces);
303+ CHECK (index.distance_metric () == distance_metric);
295304
296305 auto queries = ColMajorMatrix<feature_type_type>{
297306 {{8 , 6 , 7 }, {5 , 3 , 0 }, {9 , 5 , 0 }, {2 , 7 , 3 }}};
@@ -370,6 +379,7 @@ TEST_CASE(
370379 CHECK (index.feature_type_string () == feature_type);
371380 CHECK (index.id_type_string () == id_type);
372381 CHECK (index.partitioning_index_type_string () == partitioning_index_type);
382+ CHECK (index.distance_metric () == DistanceMetric::SUM_OF_SQUARES);
373383 }
374384
375385 {
0 commit comments