From 61846c08c28204430fb40d00e132476ad7d6c133 Mon Sep 17 00:00:00 2001 From: litan1 <106347144+ltan1ms@users.noreply.github.com> Date: Tue, 5 Mar 2024 10:47:19 -0800 Subject: [PATCH] Create in memory data store/graph store with at least max_points as 1 (#523) * create in memory data store/graph store with at least max_points as 1 * fix code formatting --- src/index.cpp | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/index.cpp b/src/index.cpp index 486d41e76..bf93344fa 100644 --- a/src/index.cpp +++ b/src/index.cpp @@ -118,30 +118,32 @@ Index::Index(Metric m, const size_t dim, const size_t max_point const bool dynamic_index, const bool enable_tags, const bool concurrent_consolidate, const bool pq_dist_build, const size_t num_pq_chunks, const bool use_opq, const bool filtered_index) - : Index(IndexConfigBuilder() - .with_metric(m) - .with_dimension(dim) - .with_max_points(max_points) - .with_index_write_params(index_parameters) - .with_index_search_params(index_search_params) - .with_num_frozen_pts(num_frozen_pts) - .is_dynamic_index(dynamic_index) - .is_enable_tags(enable_tags) - .is_concurrent_consolidate(concurrent_consolidate) - .is_pq_dist_build(pq_dist_build) - .with_num_pq_chunks(num_pq_chunks) - .is_use_opq(use_opq) - .is_filtered(filtered_index) - .with_data_type(diskann_type_to_name()) - .build(), - IndexFactory::construct_datastore( - DataStoreStrategy::MEMORY, - max_points + (dynamic_index && num_frozen_pts == 0 ? (size_t)1 : num_frozen_pts), dim, m), - IndexFactory::construct_graphstore( - GraphStoreStrategy::MEMORY, - max_points + (dynamic_index && num_frozen_pts == 0 ? (size_t)1 : num_frozen_pts), - (size_t)((index_parameters == nullptr ? 0 : index_parameters->max_degree) * - defaults::GRAPH_SLACK_FACTOR * 1.05))) + : Index( + IndexConfigBuilder() + .with_metric(m) + .with_dimension(dim) + .with_max_points(max_points) + .with_index_write_params(index_parameters) + .with_index_search_params(index_search_params) + .with_num_frozen_pts(num_frozen_pts) + .is_dynamic_index(dynamic_index) + .is_enable_tags(enable_tags) + .is_concurrent_consolidate(concurrent_consolidate) + .is_pq_dist_build(pq_dist_build) + .with_num_pq_chunks(num_pq_chunks) + .is_use_opq(use_opq) + .is_filtered(filtered_index) + .with_data_type(diskann_type_to_name()) + .build(), + IndexFactory::construct_datastore(DataStoreStrategy::MEMORY, + (max_points == 0 ? (size_t)1 : max_points) + + (dynamic_index && num_frozen_pts == 0 ? (size_t)1 : num_frozen_pts), + dim, m), + IndexFactory::construct_graphstore(GraphStoreStrategy::MEMORY, + (max_points == 0 ? (size_t)1 : max_points) + + (dynamic_index && num_frozen_pts == 0 ? (size_t)1 : num_frozen_pts), + (size_t)((index_parameters == nullptr ? 0 : index_parameters->max_degree) * + defaults::GRAPH_SLACK_FACTOR * 1.05))) { if (_pq_dist) {