From 5262adbb8f71a58b10668020beeb35c3e5a45ff1 Mon Sep 17 00:00:00 2001 From: Dax Pryce Date: Fri, 3 Nov 2023 15:42:06 -0700 Subject: [PATCH] Ran automatic formatting --- python/src/builder.cpp | 64 +++++++++++++++--------------- python/src/module.cpp | 4 +- python/src/static_memory_index.cpp | 5 +-- 3 files changed, 35 insertions(+), 38 deletions(-) diff --git a/python/src/builder.cpp b/python/src/builder.cpp index 3e06608a3..e02a86d6c 100644 --- a/python/src/builder.cpp +++ b/python/src/builder.cpp @@ -32,16 +32,12 @@ template void build_disk_index(diskann::Metric, const std::string &, con double, double, uint32_t, uint32_t); template -std::string prepare_filtered_label_map( - diskann::Index& index, - const std::string& index_output_path, - const std::string& filter_labels_file, - const std::string& universal_label -) { +std::string prepare_filtered_label_map(diskann::Index &index, const std::string &index_output_path, + const std::string &filter_labels_file, const std::string &universal_label) +{ std::string labels_file_to_use = index_output_path + "_label_formatted.txt"; std::string mem_labels_int_map_file = index_output_path + "_labels_map.txt"; - convert_labels_string_to_int(filter_labels_file, labels_file_to_use, - mem_labels_int_map_file, universal_label); + convert_labels_string_to_int(filter_labels_file, labels_file_to_use, mem_labels_int_map_file, universal_label); if (!universal_label.empty()) { uint32_t unv_label_as_num = 0; @@ -50,27 +46,21 @@ std::string prepare_filtered_label_map( return labels_file_to_use; } -template std::string prepare_filtered_label_map(diskann::Index&, - const std::string&, - const std::string&, - const std::string&); +template std::string prepare_filtered_label_map(diskann::Index &, const std::string &, + const std::string &, const std::string &); -template std::string prepare_filtered_label_map(diskann::Index&, - const std::string&, - const std::string&, - const std::string&); +template std::string prepare_filtered_label_map(diskann::Index &, + const std::string &, const std::string &, const std::string &); -template std::string prepare_filtered_label_map(diskann::Index&, - const std::string&, - const std::string&, - const std::string&); +template std::string prepare_filtered_label_map(diskann::Index &, + const std::string &, const std::string &, const std::string &); template void build_memory_index(const diskann::Metric metric, const std::string &vector_bin_path, const std::string &index_output_path, const uint32_t graph_degree, const uint32_t complexity, const float alpha, const uint32_t num_threads, const bool use_pq_build, const size_t num_pq_bytes, const bool use_opq, const bool use_tags, - const std::string& filter_labels_file, const std::string& universal_label, + const std::string &filter_labels_file, const std::string &universal_label, const uint32_t filter_complexity) { diskann::IndexWriteParameters index_build_params = diskann::IndexWriteParametersBuilder(complexity, graph_degree) @@ -100,19 +90,27 @@ void build_memory_index(const diskann::Metric metric, const std::string &vector_ size_t tag_dims = 1; diskann::load_bin(tags_file, tags_data, data_num, tag_dims); std::vector tags(tags_data, tags_data + data_num); - if (filter_labels_file.empty()) { + if (filter_labels_file.empty()) + { index.build(vector_bin_path.c_str(), data_num, tags); - } else { - auto labels_file = prepare_filtered_label_map(index, index_output_path, filter_labels_file, universal_label); + } + else + { + auto labels_file = prepare_filtered_label_map(index, index_output_path, filter_labels_file, + universal_label); index.build_filtered_index(vector_bin_path.c_str(), labels_file, data_num, tags); } } else { - if (filter_labels_file.empty()) { + if (filter_labels_file.empty()) + { index.build(vector_bin_path.c_str(), data_num); - } else { - auto labels_file = prepare_filtered_label_map(index, index_output_path, filter_labels_file, universal_label); + } + else + { + auto labels_file = prepare_filtered_label_map(index, index_output_path, filter_labels_file, + universal_label); index.build_filtered_index(vector_bin_path.c_str(), labels_file, data_num); } } @@ -121,15 +119,15 @@ void build_memory_index(const diskann::Metric metric, const std::string &vector_ } template void build_memory_index(diskann::Metric, const std::string &, const std::string &, uint32_t, uint32_t, - float, uint32_t, bool, size_t, bool,bool, const std::string&, - const std::string&, uint32_t); + float, uint32_t, bool, size_t, bool, bool, const std::string &, + const std::string &, uint32_t); template void build_memory_index(diskann::Metric, const std::string &, const std::string &, uint32_t, uint32_t, - float, uint32_t, bool, size_t, bool, bool, const std::string&, - const std::string&, uint32_t); + float, uint32_t, bool, size_t, bool, bool, const std::string &, + const std::string &, uint32_t); template void build_memory_index(diskann::Metric, const std::string &, const std::string &, uint32_t, uint32_t, - float, uint32_t, bool, size_t, bool, bool, const std::string&, - const std::string&, uint32_t); + float, uint32_t, bool, size_t, bool, bool, const std::string &, + const std::string &, uint32_t); } // namespace diskannpy diff --git a/python/src/module.cpp b/python/src/module.cpp index ecdeae4d0..376515661 100644 --- a/python/src/module.cpp +++ b/python/src/module.cpp @@ -48,8 +48,8 @@ template inline void add_variant(py::module_ &m, const Variant &var m.def(variant.memory_builder_name.c_str(), &diskannpy::build_memory_index, "distance_metric"_a, "data_file_path"_a, "index_output_path"_a, "graph_degree"_a, "complexity"_a, "alpha"_a, "num_threads"_a, - "use_pq_build"_a, "num_pq_bytes"_a, "use_opq"_a, "use_tags"_a = false, - "filter_labels_file"_a = "", "universal_label"_a = "", "filter_complexity"_a = 0); + "use_pq_build"_a, "num_pq_bytes"_a, "use_opq"_a, "use_tags"_a = false, "filter_labels_file"_a = "", + "universal_label"_a = "", "filter_complexity"_a = 0); py::class_>(m, variant.static_memory_index_name.c_str()) .def(py::init StaticMemoryIndex
::search( template NeighborsAndDistances StaticMemoryIndex
::search_with_filter( - py::array_t &query, - const uint64_t knn, const uint64_t complexity, const filterT filter -) + py::array_t &query, const uint64_t knn, const uint64_t complexity, + const filterT filter) { py::array_t ids(knn); py::array_t dists(knn);