@@ -121,7 +121,8 @@ TEST_F(VectorIndexBinaryIvfFlatTest, Create) {
121121 pb::common::VectorIndexParameter index_parameter;
122122 index_parameter.set_vector_index_type (::dingodb::pb::common::VectorIndexType::VECTOR_INDEX_TYPE_BINARY_IVF_FLAT);
123123 index_parameter.mutable_binary_ivf_flat_parameter ()->set_dimension (64 );
124- index_parameter.mutable_binary_ivf_flat_parameter ()->set_metric_type (::dingodb::pb::common::MetricType::METRIC_TYPE_NONE);
124+ index_parameter.mutable_binary_ivf_flat_parameter ()->set_metric_type (
125+ ::dingodb::pb::common::MetricType::METRIC_TYPE_NONE);
125126 vector_index_binary_ivf_flat =
126127 VectorIndexFactory::NewBinaryIVFFlat (id, index_parameter, k_epoch, kRange , vector_index_thread_pool);
127128 EXPECT_EQ (vector_index_binary_ivf_flat.get (), nullptr );
@@ -148,7 +149,7 @@ TEST_F(VectorIndexBinaryIvfFlatTest, Create) {
148149 index_parameter.mutable_binary_ivf_flat_parameter ()->set_dimension (dimension);
149150 index_parameter.mutable_binary_ivf_flat_parameter ()->set_metric_type (
150151 ::dingodb::pb::common::MetricType::METRIC_TYPE_HAMMING);
151- index_parameter.mutable_binary_ivf_flat_parameter ()->set_ncentroids (0 );
152+ index_parameter.mutable_binary_ivf_flat_parameter ()->set_ncentroids (0 );
152153 vector_index_binary_ivf_flat =
153154 VectorIndexFactory::NewBinaryIVFFlat (id, index_parameter, k_epoch, kRange , vector_index_thread_pool);
154155 EXPECT_NE (vector_index_binary_ivf_flat.get (), nullptr );
@@ -226,18 +227,6 @@ TEST_F(VectorIndexBinaryIvfFlatTest, SearchNotTrain) {
226227 for (int j = 0 ; j < dim; j++) data_base[dim * i + j] = distrib (rng);
227228 data_base[dim * i] += i / 255 ;
228229 }
229-
230- for (size_t i = 0 ; i < data_base_size; i++) {
231- LOG (INFO) << " [" << i << " ]" << " [" ;
232- for (faiss::idx_t j = 0 ; j < dim; j++) {
233- if (0 != j) {
234- LOG (INFO) << " ," ;
235- }
236- LOG (INFO) << std::setw (10 ) << data_base[i * dim + j];
237- }
238-
239- LOG (INFO) << " ]" ;
240- }
241230 }
242231
243232 // ok
@@ -275,18 +264,6 @@ TEST_F(VectorIndexBinaryIvfFlatTest, RangeSearchNotTrain) {
275264 for (int j = 0 ; j < dim; j++) data_base[dim * i + j] = distrib (rng);
276265 data_base[dim * i] += i / 255 ;
277266 }
278-
279- for (size_t i = 0 ; i < data_base_size; i++) {
280- LOG (INFO) << " [" << i << " ]" << " [" ;
281- for (faiss::idx_t j = 0 ; j < dim; j++) {
282- if (0 != j) {
283- LOG (INFO) << " ," ;
284- }
285- LOG (INFO) << std::setw (10 ) << data_base[i * dim + j];
286- }
287-
288- LOG (INFO) << " ]" ;
289- }
290267 }
291268
292269 // ok
@@ -324,6 +301,8 @@ TEST_F(VectorIndexBinaryIvfFlatTest, AddNotTrain) {
324301 std::string byte_data (1 , static_cast <char >(data_base[i]));
325302 vector_with_id.mutable_vector ()->add_binary_values (byte_data);
326303 }
304+ vector_with_id.mutable_vector ()->set_dimension (dimension);
305+ vector_with_id.mutable_vector ()->set_value_type (::dingodb::pb::common::ValueType::UINT8);
327306
328307 vector_with_ids.push_back (vector_with_id);
329308
@@ -362,18 +341,6 @@ TEST_F(VectorIndexBinaryIvfFlatTest, TrainVectorWithId) {
362341 for (int j = 0 ; j < dim; j++) data_base[dim * i + j] = distrib (rng);
363342 data_base[dim * i] += i / 255 ;
364343 }
365-
366- for (size_t i = 0 ; i < data_base_size; i++) {
367- LOG (INFO) << " [" << i << " ]" << " [" ;
368- for (faiss::idx_t j = 0 ; j < dim; j++) {
369- if (0 != j) {
370- LOG (INFO) << " ," ;
371- }
372- LOG (INFO) << std::setw (10 ) << data_base[i * dim + j];
373- }
374-
375- LOG (INFO) << " ]" ;
376- }
377344 }
378345
379346 // invalid. no data
@@ -398,9 +365,9 @@ TEST_F(VectorIndexBinaryIvfFlatTest, TrainVectorWithId) {
398365 vector_with_ids.push_back (vector_with_id);
399366 }
400367
401- // not align
368+ // not align
402369 pb::common::VectorWithId vector_with_id;
403- for (int j = 0 ; j < dim- 1 ; j++) {
370+ for (int j = 0 ; j < dim - 1 ; j++) {
404371 std::string byte_data (1 , static_cast <char >(data_base_not_align[(data_base_size - 1 ) * dim + j]));
405372 vector_with_id.mutable_vector ()->add_binary_values (byte_data);
406373 }
@@ -470,18 +437,6 @@ TEST_F(VectorIndexBinaryIvfFlatTest, Train) {
470437 for (int j = 0 ; j < dim; j++) data_base[dim * i + j] = distrib (rng);
471438 data_base[dim * i] += i / 255 ;
472439 }
473-
474- for (size_t i = 0 ; i < data_base_size; i++) {
475- LOG (INFO) << " [" << i << " ]" << " [" ;
476- for (faiss::idx_t j = 0 ; j < dim; j++) {
477- if (0 != j) {
478- LOG (INFO) << " ," ;
479- }
480- LOG (INFO) << std::setw (10 ) << data_base[i * dim + j];
481- }
482-
483- LOG (INFO) << " ]" ;
484- }
485440 }
486441
487442 // invalid. no data
@@ -567,6 +522,8 @@ TEST_F(VectorIndexBinaryIvfFlatTest, Add) {
567522 std::string byte_data (1 , static_cast <char >(data_base[i]));
568523 vector_with_id.mutable_vector ()->add_binary_values (byte_data);
569524 }
525+ vector_with_id.mutable_vector ()->set_dimension (dimension);
526+ vector_with_id.mutable_vector ()->set_value_type (::dingodb::pb::common::ValueType::UINT8);
570527
571528 vector_with_ids.push_back (vector_with_id);
572529
@@ -586,6 +543,8 @@ TEST_F(VectorIndexBinaryIvfFlatTest, Add) {
586543 std::string byte_data (1 , static_cast <char >(data_base[id * dim + i]));
587544 vector_with_id.mutable_vector ()->add_binary_values (byte_data);
588545 }
546+ vector_with_id.mutable_vector ()->set_dimension (dimension);
547+ vector_with_id.mutable_vector ()->set_value_type (::dingodb::pb::common::ValueType::UINT8);
589548
590549 vector_with_ids.push_back (vector_with_id);
591550 }
@@ -648,6 +607,8 @@ TEST_F(VectorIndexBinaryIvfFlatTest, Upsert) {
648607 std::string byte_data (1 , static_cast <char >(data_base[id * dim + i]));
649608 vector_with_id.mutable_vector ()->add_binary_values (byte_data);
650609 }
610+ vector_with_id.mutable_vector ()->set_dimension (dimension);
611+ vector_with_id.mutable_vector ()->set_value_type (::dingodb::pb::common::ValueType::UINT8);
651612
652613 vector_with_ids.push_back (vector_with_id);
653614 }
@@ -675,6 +636,8 @@ TEST_F(VectorIndexBinaryIvfFlatTest, Upsert) {
675636 std::string byte_data (1 , static_cast <char >(data_base[id * dim + i]));
676637 vector_with_id.mutable_vector ()->add_binary_values (byte_data);
677638 }
639+ vector_with_id.mutable_vector ()->set_dimension (dimension);
640+ vector_with_id.mutable_vector ()->set_value_type (::dingodb::pb::common::ValueType::UINT8);
678641
679642 vector_with_ids.push_back (vector_with_id);
680643 }
@@ -1008,12 +971,10 @@ TEST_F(VectorIndexBinaryIvfFlatTest, SearchAfterLoad) {
1008971 ok = vector_index_binary_ivf_flat->Search (vector_with_ids, topk, {}, false , {}, results);
1009972 EXPECT_EQ (ok.error_code (), pb::error::Errno::OK);
1010973
1011-
1012974 for (const auto & result : results) {
1013975 DINGO_LOG (INFO) << " results:" << result.DebugString ();
1014976 DINGO_LOG (INFO) << " " ;
1015977 }
1016-
1017978 }
1018979
1019980 // ok with param
@@ -1070,7 +1031,6 @@ TEST_F(VectorIndexBinaryIvfFlatTest, SearchAfterLoad) {
10701031 if (is_all_in_vector) {
10711032 DINGO_LOG (INFO) << " All Id in vectors " ;
10721033 }
1073-
10741034 }
10751035}
10761036
@@ -1086,7 +1046,6 @@ TEST_F(VectorIndexBinaryIvfFlatTest, RangeSearchAfterLoad) {
10861046 std::vector<pb::index::VectorWithDistanceResult> results;
10871047 ok = vector_index_binary_ivf_flat->RangeSearch (vector_with_ids, radius, {}, false , {}, results);
10881048 EXPECT_EQ (ok.error_code (), pb::error::Errno::EVECTOR_INVALID);
1089-
10901049 }
10911050
10921051 // invalid param failed, topk == 0, return OK
@@ -1106,7 +1065,6 @@ TEST_F(VectorIndexBinaryIvfFlatTest, RangeSearchAfterLoad) {
11061065
11071066 ok = vector_index_binary_ivf_flat->RangeSearch (vector_with_ids, radius, {}, false , {}, results);
11081067 EXPECT_EQ (ok.error_code (), pb::error::Errno::OK);
1109-
11101068 }
11111069
11121070 // ok
@@ -1127,12 +1085,10 @@ TEST_F(VectorIndexBinaryIvfFlatTest, RangeSearchAfterLoad) {
11271085 ok = vector_index_binary_ivf_flat->RangeSearch (vector_with_ids, radius, {}, false , {}, results);
11281086 EXPECT_EQ (ok.error_code (), pb::error::Errno::OK);
11291087
1130-
11311088 for (const auto & result : results) {
11321089 DINGO_LOG (INFO) << " results:" << result.DebugString ();
11331090 DINGO_LOG (INFO) << " " ;
11341091 }
1135-
11361092 }
11371093
11381094 // ok with param
0 commit comments