Skip to content

Commit

Permalink
address changes requested
Browse files Browse the repository at this point in the history
  • Loading branch information
harsha-simhadri committed Aug 21, 2023
1 parent 3290d12 commit 01f6134
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 26 deletions.
24 changes: 15 additions & 9 deletions apps/search_disk_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>(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<float>(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<uint32_t>(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<float>(cur_result_path, query_result_dists[test_id++].data(), query_num, recall_at);
}
}

diskann::aligned_free(query);
Expand Down
37 changes: 22 additions & 15 deletions apps/search_memory_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>(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<uint32_t>(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<float>(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<float>(cur_result_path, query_result_dists[test_id].data(), query_num, recall_at);

test_id++;
test_id++;
}
}

diskann::aligned_free(query);
Expand Down Expand Up @@ -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<std::string>(&index_path_prefix)->required(),
program_options_utils::INDEX_PATH_PREFIX_DESCRIPTION);
required_configs.add_options()("result_path", po::value<std::string>(&result_path)->required(),
program_options_utils::RESULT_PATH_DESCRIPTION);
required_configs.add_options()("query_file", po::value<std::string>(&query_file)->required(),
program_options_utils::QUERY_FILE_DESCRIPTION);
required_configs.add_options()("recall_at,K", po::value<uint32_t>(&K)->required(),
Expand All @@ -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<std::string>(&result_path)->default_value(""),
program_options_utils::RESULT_PATH_DESCRIPTION);
optional_configs.add_options()("filter_label",
po::value<std::string>(&filter_label)->default_value(std::string("")),
program_options_utils::FILTER_LABEL_DESCRIPTION);
Expand Down
4 changes: 2 additions & 2 deletions src/pq_flash_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ void PQFlashIndex<T, LabelT>::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
Expand Down Expand Up @@ -1561,7 +1561,7 @@ void PQFlashIndex<T, LabelT>::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
Expand Down

0 comments on commit 01f6134

Please sign in to comment.