// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. #include #include #include #include #include #include #include #include #ifndef _WINDOWS #include #include #include #include #endif #include "utils.h" #include "index.h" #include "memory_mapper.h" namespace po = boost::program_options; template void bfs_count(const std::string &index_path, uint32_t data_dims) { using TagT = uint32_t; using LabelT = uint32_t; diskann::Index index(diskann::Metric::L2, data_dims, 0, false, false); std::cout << "Index class instantiated" << std::endl; index.load(index_path.c_str(), 1, 100); std::cout << "Index loaded" << std::endl; index.count_nodes_at_bfs_levels(); } int main(int argc, char **argv) { std::string data_type, index_path_prefix; uint32_t data_dims; po::options_description desc{"Arguments"}; 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()("index_path_prefix", po::value(&index_path_prefix)->required(), "Path prefix to the index"); desc.add_options()("data_dims", po::value(&data_dims)->required(), "Dimensionality of the data"); po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); if (vm.count("help")) { std::cout << desc; return 0; } po::notify(vm); } catch (const std::exception &ex) { std::cerr << ex.what() << '\n'; return -1; } try { if (data_type == std::string("int8")) bfs_count(index_path_prefix, data_dims); else if (data_type == std::string("uint8")) bfs_count(index_path_prefix, data_dims); if (data_type == std::string("float")) bfs_count(index_path_prefix, data_dims); } catch (std::exception &e) { std::cout << std::string(e.what()) << std::endl; diskann::cerr << "Index BFS failed." << std::endl; return -1; } }