From 01f61341f36ec5e1daa5dd8bb09da68845f80073 Mon Sep 17 00:00:00 2001 From: harsha vardhan simhadri Date: Mon, 21 Aug 2023 10:30:15 -0700 Subject: [PATCH] address changes requested --- apps/search_disk_index.cpp | 24 ++++++++++++++--------- apps/search_memory_index.cpp | 37 +++++++++++++++++++++--------------- src/pq_flash_index.cpp | 4 ++-- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/apps/search_disk_index.cpp b/apps/search_disk_index.cpp index 7e2a7ac6d..aef98c959 100644 --- a/apps/search_disk_index.cpp +++ b/apps/search_disk_index.cpp @@ -290,18 +290,24 @@ int search_disk_index(diskann::Metric &metric, const std::string &index_path_pre delete[] stats; } - diskann::cout << "Done searching. Now saving results " << std::endl; - uint64_t test_id = 0; - for (auto L : Lvec) + diskann::cout << "Done searching." << std::endl; + + if (result_path_prefix != std::string("")) { - if (L < recall_at) - continue; + std::cout << "Saving results." << std::endl; - std::string cur_result_path = result_output_prefix + "_" + std::to_string(L) + "_idx_uint32.bin"; - diskann::save_bin(cur_result_path, query_result_ids[test_id].data(), query_num, recall_at); + uint64_t test_id = 0; + for (auto L : Lvec) + { + if (L < recall_at) + continue; - cur_result_path = result_output_prefix + "_" + std::to_string(L) + "_dists_float.bin"; - diskann::save_bin(cur_result_path, query_result_dists[test_id++].data(), query_num, recall_at); + std::string cur_result_path = result_output_prefix + "_" + std::to_string(L) + "_idx_uint32.bin"; + diskann::save_bin(cur_result_path, query_result_ids[test_id].data(), query_num, recall_at); + + cur_result_path = result_output_prefix + "_" + std::to_string(L) + "_dists_float.bin"; + diskann::save_bin(cur_result_path, query_result_dists[test_id++].data(), query_num, recall_at); + } } diskann::aligned_free(query); diff --git a/apps/search_memory_index.cpp b/apps/search_memory_index.cpp index d309fa804..efc6af9c5 100644 --- a/apps/search_memory_index.cpp +++ b/apps/search_memory_index.cpp @@ -240,24 +240,31 @@ int search_memory_index(diskann::Metric &metric, const std::string &index_path, std::cout << std::endl; } - std::cout << "Done searching. Now saving results " << std::endl; - uint64_t test_id = 0; - for (auto L : Lvec) + std::cout << "Done searching." << std::endl; + + if (result_path_prefix != std::string("")) { - if (L < recall_at) + std::cout << "Saving results." << std::endl; + + uint64_t test_id = 0; + for (auto L : Lvec) { - diskann::cout << "Ignoring search with L:" << L << " since it's smaller than K:" << recall_at << std::endl; - continue; - } - std::string cur_result_path_prefix = result_path_prefix + "_" + std::to_string(L); + if (L < recall_at) + { + diskann::cout << "Ignoring search with L:" << L << " since it's smaller than K:" << recall_at + << std::endl; + continue; + } + std::string cur_result_path_prefix = result_path_prefix + "_" + std::to_string(L); - std::string cur_result_path = cur_result_path_prefix + "_idx_uint32.bin"; - diskann::save_bin(cur_result_path, query_result_ids[test_id].data(), query_num, recall_at); + std::string cur_result_path = cur_result_path_prefix + "_idx_uint32.bin"; + diskann::save_bin(cur_result_path, query_result_ids[test_id].data(), query_num, recall_at); - cur_result_path = cur_result_path_prefix + "_dists_float.bin"; - diskann::save_bin(cur_result_path, query_result_dists[test_id].data(), query_num, recall_at); + cur_result_path = cur_result_path_prefix + "_dists_float.bin"; + diskann::save_bin(cur_result_path, query_result_dists[test_id].data(), query_num, recall_at); - test_id++; + test_id++; + } } diskann::aligned_free(query); @@ -287,8 +294,6 @@ int main(int argc, char **argv) program_options_utils::DISTANCE_FUNCTION_DESCRIPTION); required_configs.add_options()("index_path_prefix", po::value(&index_path_prefix)->required(), program_options_utils::INDEX_PATH_PREFIX_DESCRIPTION); - required_configs.add_options()("result_path", po::value(&result_path)->required(), - program_options_utils::RESULT_PATH_DESCRIPTION); required_configs.add_options()("query_file", po::value(&query_file)->required(), program_options_utils::QUERY_FILE_DESCRIPTION); required_configs.add_options()("recall_at,K", po::value(&K)->required(), @@ -299,6 +304,8 @@ int main(int argc, char **argv) // Optional parameters po::options_description optional_configs("Optional"); + optional_configs.add_options()("result_path", po::value(&result_path)->default_value(""), + program_options_utils::RESULT_PATH_DESCRIPTION); optional_configs.add_options()("filter_label", po::value(&filter_label)->default_value(std::string("")), program_options_utils::FILTER_LABEL_DESCRIPTION); diff --git a/src/pq_flash_index.cpp b/src/pq_flash_index.cpp index cd0e87c33..e76debcdf 100644 --- a/src/pq_flash_index.cpp +++ b/src/pq_flash_index.cpp @@ -1392,7 +1392,7 @@ void PQFlashIndex::cached_beam_search(const T *query1, const uint64_t io_timer.reset(); #ifdef USE_BING_INFRA reader->read(frontier_read_reqs, ctx, - true); // synhronous reader for Bing. + true); // asynhronous reader for Bing. #else reader->read(frontier_read_reqs, ctx); // synchronous IO linux #endif @@ -1561,7 +1561,7 @@ void PQFlashIndex::cached_beam_search(const T *query1, const uint64_t io_timer.reset(); #ifdef USE_BING_INFRA - reader->read(vec_read_reqs, ctx, false); // sync reader windows. + reader->read(vec_read_reqs, ctx, true); // async reader windows. #else reader->read(vec_read_reqs, ctx); // synchronous IO linux #endif