@@ -121,7 +121,8 @@ TEST_F(VectorIndexBinaryIvfFlatTest, Create) {
121
121
pb::common::VectorIndexParameter index_parameter;
122
122
index_parameter.set_vector_index_type (::dingodb::pb::common::VectorIndexType::VECTOR_INDEX_TYPE_BINARY_IVF_FLAT);
123
123
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);
125
126
vector_index_binary_ivf_flat =
126
127
VectorIndexFactory::NewBinaryIVFFlat (id, index_parameter, k_epoch, kRange , vector_index_thread_pool);
127
128
EXPECT_EQ (vector_index_binary_ivf_flat.get (), nullptr );
@@ -148,7 +149,7 @@ TEST_F(VectorIndexBinaryIvfFlatTest, Create) {
148
149
index_parameter.mutable_binary_ivf_flat_parameter ()->set_dimension (dimension);
149
150
index_parameter.mutable_binary_ivf_flat_parameter ()->set_metric_type (
150
151
::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 );
152
153
vector_index_binary_ivf_flat =
153
154
VectorIndexFactory::NewBinaryIVFFlat (id, index_parameter, k_epoch, kRange , vector_index_thread_pool);
154
155
EXPECT_NE (vector_index_binary_ivf_flat.get (), nullptr );
@@ -226,18 +227,6 @@ TEST_F(VectorIndexBinaryIvfFlatTest, SearchNotTrain) {
226
227
for (int j = 0 ; j < dim; j++) data_base[dim * i + j] = distrib (rng);
227
228
data_base[dim * i] += i / 255 ;
228
229
}
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
- }
241
230
}
242
231
243
232
// ok
@@ -275,18 +264,6 @@ TEST_F(VectorIndexBinaryIvfFlatTest, RangeSearchNotTrain) {
275
264
for (int j = 0 ; j < dim; j++) data_base[dim * i + j] = distrib (rng);
276
265
data_base[dim * i] += i / 255 ;
277
266
}
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
- }
290
267
}
291
268
292
269
// ok
@@ -324,6 +301,8 @@ TEST_F(VectorIndexBinaryIvfFlatTest, AddNotTrain) {
324
301
std::string byte_data (1 , static_cast <char >(data_base[i]));
325
302
vector_with_id.mutable_vector ()->add_binary_values (byte_data);
326
303
}
304
+ vector_with_id.mutable_vector ()->set_dimension (dimension);
305
+ vector_with_id.mutable_vector ()->set_value_type (::dingodb::pb::common::ValueType::UINT8);
327
306
328
307
vector_with_ids.push_back (vector_with_id);
329
308
@@ -362,18 +341,6 @@ TEST_F(VectorIndexBinaryIvfFlatTest, TrainVectorWithId) {
362
341
for (int j = 0 ; j < dim; j++) data_base[dim * i + j] = distrib (rng);
363
342
data_base[dim * i] += i / 255 ;
364
343
}
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
- }
377
344
}
378
345
379
346
// invalid. no data
@@ -398,9 +365,9 @@ TEST_F(VectorIndexBinaryIvfFlatTest, TrainVectorWithId) {
398
365
vector_with_ids.push_back (vector_with_id);
399
366
}
400
367
401
- // not align
368
+ // not align
402
369
pb::common::VectorWithId vector_with_id;
403
- for (int j = 0 ; j < dim- 1 ; j++) {
370
+ for (int j = 0 ; j < dim - 1 ; j++) {
404
371
std::string byte_data (1 , static_cast <char >(data_base_not_align[(data_base_size - 1 ) * dim + j]));
405
372
vector_with_id.mutable_vector ()->add_binary_values (byte_data);
406
373
}
@@ -470,18 +437,6 @@ TEST_F(VectorIndexBinaryIvfFlatTest, Train) {
470
437
for (int j = 0 ; j < dim; j++) data_base[dim * i + j] = distrib (rng);
471
438
data_base[dim * i] += i / 255 ;
472
439
}
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
- }
485
440
}
486
441
487
442
// invalid. no data
@@ -567,6 +522,8 @@ TEST_F(VectorIndexBinaryIvfFlatTest, Add) {
567
522
std::string byte_data (1 , static_cast <char >(data_base[i]));
568
523
vector_with_id.mutable_vector ()->add_binary_values (byte_data);
569
524
}
525
+ vector_with_id.mutable_vector ()->set_dimension (dimension);
526
+ vector_with_id.mutable_vector ()->set_value_type (::dingodb::pb::common::ValueType::UINT8);
570
527
571
528
vector_with_ids.push_back (vector_with_id);
572
529
@@ -586,6 +543,8 @@ TEST_F(VectorIndexBinaryIvfFlatTest, Add) {
586
543
std::string byte_data (1 , static_cast <char >(data_base[id * dim + i]));
587
544
vector_with_id.mutable_vector ()->add_binary_values (byte_data);
588
545
}
546
+ vector_with_id.mutable_vector ()->set_dimension (dimension);
547
+ vector_with_id.mutable_vector ()->set_value_type (::dingodb::pb::common::ValueType::UINT8);
589
548
590
549
vector_with_ids.push_back (vector_with_id);
591
550
}
@@ -648,6 +607,8 @@ TEST_F(VectorIndexBinaryIvfFlatTest, Upsert) {
648
607
std::string byte_data (1 , static_cast <char >(data_base[id * dim + i]));
649
608
vector_with_id.mutable_vector ()->add_binary_values (byte_data);
650
609
}
610
+ vector_with_id.mutable_vector ()->set_dimension (dimension);
611
+ vector_with_id.mutable_vector ()->set_value_type (::dingodb::pb::common::ValueType::UINT8);
651
612
652
613
vector_with_ids.push_back (vector_with_id);
653
614
}
@@ -675,6 +636,8 @@ TEST_F(VectorIndexBinaryIvfFlatTest, Upsert) {
675
636
std::string byte_data (1 , static_cast <char >(data_base[id * dim + i]));
676
637
vector_with_id.mutable_vector ()->add_binary_values (byte_data);
677
638
}
639
+ vector_with_id.mutable_vector ()->set_dimension (dimension);
640
+ vector_with_id.mutable_vector ()->set_value_type (::dingodb::pb::common::ValueType::UINT8);
678
641
679
642
vector_with_ids.push_back (vector_with_id);
680
643
}
@@ -1008,12 +971,10 @@ TEST_F(VectorIndexBinaryIvfFlatTest, SearchAfterLoad) {
1008
971
ok = vector_index_binary_ivf_flat->Search (vector_with_ids, topk, {}, false , {}, results);
1009
972
EXPECT_EQ (ok.error_code (), pb::error::Errno::OK);
1010
973
1011
-
1012
974
for (const auto & result : results) {
1013
975
DINGO_LOG (INFO) << " results:" << result.DebugString ();
1014
976
DINGO_LOG (INFO) << " " ;
1015
977
}
1016
-
1017
978
}
1018
979
1019
980
// ok with param
@@ -1070,7 +1031,6 @@ TEST_F(VectorIndexBinaryIvfFlatTest, SearchAfterLoad) {
1070
1031
if (is_all_in_vector) {
1071
1032
DINGO_LOG (INFO) << " All Id in vectors " ;
1072
1033
}
1073
-
1074
1034
}
1075
1035
}
1076
1036
@@ -1086,7 +1046,6 @@ TEST_F(VectorIndexBinaryIvfFlatTest, RangeSearchAfterLoad) {
1086
1046
std::vector<pb::index ::VectorWithDistanceResult> results;
1087
1047
ok = vector_index_binary_ivf_flat->RangeSearch (vector_with_ids, radius, {}, false , {}, results);
1088
1048
EXPECT_EQ (ok.error_code (), pb::error::Errno::EVECTOR_INVALID);
1089
-
1090
1049
}
1091
1050
1092
1051
// invalid param failed, topk == 0, return OK
@@ -1106,7 +1065,6 @@ TEST_F(VectorIndexBinaryIvfFlatTest, RangeSearchAfterLoad) {
1106
1065
1107
1066
ok = vector_index_binary_ivf_flat->RangeSearch (vector_with_ids, radius, {}, false , {}, results);
1108
1067
EXPECT_EQ (ok.error_code (), pb::error::Errno::OK);
1109
-
1110
1068
}
1111
1069
1112
1070
// ok
@@ -1127,12 +1085,10 @@ TEST_F(VectorIndexBinaryIvfFlatTest, RangeSearchAfterLoad) {
1127
1085
ok = vector_index_binary_ivf_flat->RangeSearch (vector_with_ids, radius, {}, false , {}, results);
1128
1086
EXPECT_EQ (ok.error_code (), pb::error::Errno::OK);
1129
1087
1130
-
1131
1088
for (const auto & result : results) {
1132
1089
DINGO_LOG (INFO) << " results:" << result.DebugString ();
1133
1090
DINGO_LOG (INFO) << " " ;
1134
1091
}
1135
-
1136
1092
}
1137
1093
1138
1094
// ok with param
0 commit comments