From ed8ce3e719d8873812b82f0567ecf5681bbd3858 Mon Sep 17 00:00:00 2001 From: Jon McLean Date: Mon, 10 Jul 2023 16:04:16 -0700 Subject: [PATCH] Updated usage statement for search_disk_app #370 --- apps/search_disk_index.cpp | 88 ++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 37 deletions(-) diff --git a/apps/search_disk_index.cpp b/apps/search_disk_index.cpp index 1108da97e..33e831159 100644 --- a/apps/search_disk_index.cpp +++ b/apps/search_disk_index.cpp @@ -12,6 +12,7 @@ #include "pq_flash_index.h" #include "timer.h" #include "percentile_stats.h" +#include "../src/program_options_utils.hpp" #ifndef _WINDOWS #include @@ -318,48 +319,61 @@ int main(int argc, char **argv) bool use_reorder_data = false; float fail_if_recall_below = 0.0f; - po::options_description desc{"Arguments"}; + po::options_description desc{ + program_options_utils::make_program_description("search_disk_index", "Searches on-disk DiskANN indexes")}; try { desc.add_options()("help,h", "Print information on arguments"); - desc.add_options()("data_type", po::value(&data_type)->required(), "data type "); - desc.add_options()("dist_fn", po::value(&dist_fn)->required(), - "distance function "); - desc.add_options()("index_path_prefix", po::value(&index_path_prefix)->required(), - "Path prefix to the index"); - desc.add_options()("result_path", po::value(&result_path_prefix)->required(), - "Path prefix for saving results of the queries"); - desc.add_options()("query_file", po::value(&query_file)->required(), - "Query file in binary format"); - desc.add_options()("gt_file", po::value(>_file)->default_value(std::string("null")), - "ground truth file for the queryset"); - desc.add_options()("recall_at,K", po::value(&K)->required(), "Number of neighbors to be returned"); - desc.add_options()("search_list,L", po::value>(&Lvec)->multitoken(), - "List of L values of search"); - desc.add_options()("beamwidth,W", po::value(&W)->default_value(2), - "Beamwidth for search. Set 0 to optimize internally."); - desc.add_options()("num_nodes_to_cache", po::value(&num_nodes_to_cache)->default_value(0), - "Beamwidth for search"); - desc.add_options()("search_io_limit", + + // Required parameters + po::options_description required_configs("Required"); + required_configs.add_options()("data_type", po::value(&data_type)->required(), + program_options_utils::DATA_TYPE_DESCRIPTION); + required_configs.add_options()("dist_fn", po::value(&dist_fn)->required(), + 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_prefix)->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(), + program_options_utils::NUMBER_OF_RESULTS_DESCRIPTION); + required_configs.add_options()("search_list,L", + po::value>(&Lvec)->multitoken()->required(), + program_options_utils::SEARCH_LIST_DESCRIPTION); + + // Optional parameters + po::options_description optional_configs("Optional"); + optional_configs.add_options()("gt_file", po::value(>_file)->default_value(std::string("null")), + program_options_utils::GROUND_TRUTH_FILE_DESCRIPTION); + optional_configs.add_options()("beamwidth,W", po::value(&W)->default_value(2), + "Beamwidth for search. Set 0 to optimize internally. Default value: 2"); + optional_configs.add_options()("num_nodes_to_cache", po::value(&num_nodes_to_cache)->default_value(0), + "Number of BFS nodes around medoid(s) to cache. Default value: 0"); + optional_configs.add_options()("search_io_limit", po::value(&search_io_limit)->default_value(std::numeric_limits::max()), - "Max #IOs for search"); - desc.add_options()("num_threads,T", po::value(&num_threads)->default_value(omp_get_num_procs()), - "Number of threads used for building index (defaults to " - "omp_get_num_procs())"); - desc.add_options()("use_reorder_data", po::bool_switch()->default_value(false), + "Max #IOs for search. Default value: uint32::max()"); + optional_configs.add_options()("num_threads,T", + po::value(&num_threads)->default_value(omp_get_num_procs()), + program_options_utils::NUMBER_THREADS_DESCRIPTION); + optional_configs.add_options()("use_reorder_data", po::bool_switch()->default_value(false), "Include full precision data in the index. Use only in " - "conjuction with compressed data on SSD."); - desc.add_options()("filter_label", po::value(&filter_label)->default_value(std::string("")), - "Filter Label for Filtered Search"); - desc.add_options()("query_filters_file", - po::value(&query_filters_file)->default_value(std::string("")), - "Filter file for Queries for Filtered Search "); - desc.add_options()("label_type", po::value(&label_type)->default_value("uint"), - "Storage type of Labels , default value is uint which " - "will consume memory 4 bytes per filter"); - desc.add_options()("fail_if_recall_below", po::value(&fail_if_recall_below)->default_value(0.0f), - "If set to a value >0 and <100%, program returns -1 if best recall " - "found is below this threshold. "); + "conjuction with compressed data on SSD. Default value: false"); + optional_configs.add_options()("filter_label", + po::value(&filter_label)->default_value(std::string("")), + program_options_utils::FILTER_LABEL_DESCRIPTION); + optional_configs.add_options()("query_filters_file", + po::value(&query_filters_file)->default_value(std::string("")), + program_options_utils::FILTERS_FILE_DESCRIPTION); + optional_configs.add_options()("label_type", po::value(&label_type)->default_value("uint"), + program_options_utils::LABEL_TYPE_DESCRIPTION); + optional_configs.add_options()("fail_if_recall_below", + po::value(&fail_if_recall_below)->default_value(0.0f), + program_options_utils::FAIl_IF_RECALL_BELOW); + + // Merge required and optional parameters + desc.add(required_configs).add(optional_configs); po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm);