@@ -27,12 +27,6 @@ std::string kIPIndexDir = kDir + "/ip_index";
2727std::string kL2IndexPrefix = kL2IndexDir + " /l2" ;
2828std::string kIPIndexPrefix = kIPIndexDir + " /ip" ;
2929
30- constexpr uint32_t kNumRows = 10000 ;
31- constexpr uint32_t kNumQueries = 100 ;
32- constexpr uint32_t kDim = 128 ;
33- constexpr uint32_t kK = 10 ;
34- constexpr float kL2KnnRecall = 0.8 ;
35-
3630void
3731WriteRawDataToDisk (const std::string data_path, const float * raw_data, const uint32_t num, const uint32_t dim) {
3832 std::ofstream writer (data_path.c_str (), std::ios::binary);
@@ -119,14 +113,17 @@ class Benchmark_float : public Benchmark_knowhere, public ::testing::Test {
119113 printf (" [%.3f s] Test '%s/%s' done\n\n " , get_time_diff (), ann_test_name_.c_str (), index_type_.c_str ());
120114 }
121115
116+ #ifdef KNOWHERE_WITH_DISKANN
122117 void
123118 test_diskann (const knowhere::Json& cfg) {
124119 auto conf = cfg;
125120 conf[" index_prefix" ] = (metric_type_ == knowhere::metric::L2 ? kL2IndexPrefix : kIPIndexPrefix );
126- conf[" num_threads" ] = 8 ;
127121 conf[" search_cache_budget_gb" ] = 0 ;
128122 conf[" beamwidth" ] = 8 ;
129123
124+ knowhere::BinarySet binset;
125+ index_.Deserialize (binset, conf);
126+
130127 printf (" \n [%0.3f s] %s | %s \n " , get_time_diff (), ann_test_name_.c_str (), index_type_.c_str ());
131128 printf (" ================================================================================\n " );
132129 for (auto nq : NQs_) {
@@ -144,6 +141,7 @@ class Benchmark_float : public Benchmark_knowhere, public ::testing::Test {
144141 printf (" ================================================================================\n " );
145142 printf (" [%.3f s] Test '%s/%s' done\n\n " , get_time_diff (), ann_test_name_.c_str (), index_type_.c_str ());
146143 }
144+ #endif
147145
148146 protected:
149147 void
@@ -255,6 +253,7 @@ TEST_F(Benchmark_float, TEST_HNSW) {
255253 }
256254}
257255
256+ #ifdef KNOWHERE_WITH_DISKANN
258257TEST_F (Benchmark_float, TEST_DISKANN) {
259258 index_type_ = knowhere::IndexEnum::INDEX_DISKANN;
260259
@@ -264,9 +263,8 @@ TEST_F(Benchmark_float, TEST_DISKANN) {
264263 conf[" data_path" ] = kRawDataPath ;
265264 conf[" max_degree" ] = 56 ;
266265 conf[" search_list_size" ] = 128 ;
267- conf[" pq_code_budget_gb" ] = sizeof (float ) * kDim * kNumRows * 0.125 / (1024 * 1024 * 1024 );
266+ conf[" pq_code_budget_gb" ] = sizeof (float ) * dim_ * nb_ * 0.125 / (1024 * 1024 * 1024 );
268267 conf[" build_dram_budget_gb" ] = 32.0 ;
269- conf[" num_threads" ] = 8 ;
270268
271269 fs::create_directory (kDir );
272270 fs::create_directory (kL2IndexDir );
@@ -283,3 +281,4 @@ TEST_F(Benchmark_float, TEST_DISKANN) {
283281 index_.Build (*ds_ptr, conf);
284282 test_diskann (conf);
285283}
284+ #endif
0 commit comments