@@ -33,24 +33,23 @@ struct IndexConfig
3333 std::string tag_type;
3434 std::string data_type;
3535
36+ // Params for building index
3637 std::shared_ptr<IndexWriteParameters> index_write_params;
37-
38- uint32_t search_threads;
39- uint32_t initial_search_list_size;
38+ // Params for searching index
39+ std::shared_ptr<IndexSearchParams> index_search_params;
4040
4141 private:
4242 IndexConfig (DataStoreStrategy data_strategy, GraphStoreStrategy graph_strategy, Metric metric, size_t dimension,
4343 size_t max_points, size_t num_pq_chunks, size_t num_frozen_points, bool dynamic_index, bool enable_tags,
4444 bool pq_dist_build, bool concurrent_consolidate, bool use_opq, const std::string &data_type,
4545 const std::string &tag_type, const std::string &label_type,
46- std::shared_ptr<IndexWriteParameters> index_write_params, uint32_t search_threads,
47- uint32_t initial_search_list_size )
46+ std::shared_ptr<IndexWriteParameters> index_write_params,
47+ std::shared_ptr<IndexSearchParams> index_search_params )
4848 : data_strategy(data_strategy), graph_strategy(graph_strategy), metric(metric), dimension(dimension),
4949 max_points (max_points), dynamic_index(dynamic_index), enable_tags(enable_tags), pq_dist_build(pq_dist_build),
5050 concurrent_consolidate(concurrent_consolidate), use_opq(use_opq), num_pq_chunks(num_pq_chunks),
5151 num_frozen_pts(num_frozen_points), label_type(label_type), tag_type(tag_type), data_type(data_type),
52- index_write_params(index_write_params), search_threads(search_threads),
53- initial_search_list_size(initial_search_list_size)
52+ index_write_params(index_write_params), index_search_params(index_search_params)
5453 {
5554 }
5655
@@ -60,9 +59,7 @@ struct IndexConfig
6059class IndexConfigBuilder
6160{
6261 public:
63- IndexConfigBuilder ()
64- {
65- }
62+ IndexConfigBuilder () = default ;
6663
6764 IndexConfigBuilder &with_metric (Metric m)
6865 {
@@ -160,15 +157,31 @@ class IndexConfigBuilder
160157 return *this ;
161158 }
162159
163- IndexConfigBuilder &with_search_threads (uint32_t search_threads)
160+ IndexConfigBuilder &with_index_write_params (std::shared_ptr<IndexWriteParameters> index_write_params_ptr)
161+ {
162+ if (index_write_params_ptr == nullptr )
163+ {
164+ diskann::cout << " Passed, empty build_params while creating index config" << std::endl;
165+ return *this ;
166+ }
167+ this ->_index_write_params = index_write_params_ptr;
168+ return *this ;
169+ }
170+
171+ IndexConfigBuilder &with_index_search_params (IndexSearchParams &search_params)
164172 {
165- this ->_search_threads = search_threads ;
173+ this ->_index_search_params = std::make_shared<IndexSearchParams>(search_params) ;
166174 return *this ;
167175 }
168176
169- IndexConfigBuilder &with_initial_search_list_size ( uint32_t search_list_size )
177+ IndexConfigBuilder &with_index_search_params (std::shared_ptr<IndexSearchParams> search_params_ptr )
170178 {
171- this ->_initial_search_list_size = search_list_size;
179+ if (search_params_ptr == nullptr )
180+ {
181+ diskann::cout << " Passed, empty search_params while creating index config" << std::endl;
182+ return *this ;
183+ }
184+ this ->_index_search_params = search_params_ptr;
172185 return *this ;
173186 }
174187
@@ -177,19 +190,20 @@ class IndexConfigBuilder
177190 if (_data_type == " " || _data_type.empty ())
178191 throw ANNException (" Error: data_type can not be empty" , -1 );
179192
180- if (_dynamic_index && _index_write_params != nullptr )
193+ if (_dynamic_index && _num_frozen_pts == 0 )
181194 {
182- if (_search_threads == 0 )
183- throw ANNException ( " Error: please pass search_threads for building dynamic index. " , - 1 );
195+ _num_frozen_pts = 1 ;
196+ }
184197
185- if (_initial_search_list_size == 0 )
198+ if (_dynamic_index)
199+ {
200+ if (_index_search_params != nullptr && _index_search_params->initial_search_list_size == 0 )
186201 throw ANNException (" Error: please pass initial_search_list_size for building dynamic index." , -1 );
187202 }
188203
189204 return IndexConfig (_data_strategy, _graph_strategy, _metric, _dimension, _max_points, _num_pq_chunks,
190205 _num_frozen_pts, _dynamic_index, _enable_tags, _pq_dist_build, _concurrent_consolidate,
191- _use_opq, _data_type, _tag_type, _label_type, _index_write_params, _search_threads,
192- _initial_search_list_size);
206+ _use_opq, _data_type, _tag_type, _label_type, _index_write_params, _index_search_params);
193207 }
194208
195209 IndexConfigBuilder (const IndexConfigBuilder &) = delete ;
@@ -217,8 +231,6 @@ class IndexConfigBuilder
217231 std::string _data_type;
218232
219233 std::shared_ptr<IndexWriteParameters> _index_write_params;
220-
221- uint32_t _search_threads;
222- uint32_t _initial_search_list_size;
234+ std::shared_ptr<IndexSearchParams> _index_search_params;
223235};
224236} // namespace diskann
0 commit comments