@@ -43,10 +43,10 @@ class IndexNodeWithDataViewRefiner : public IndexNode {
4343 }
4444
4545 Status
46- Train (const DataSetPtr dataset, std::shared_ptr<Config> cfg) override ;
46+ Train (const DataSetPtr dataset, std::shared_ptr<Config> cfg, bool use_knowhere_build_pool ) override ;
4747
4848 Status
49- Add (const DataSetPtr dataset, std::shared_ptr<Config> cfg) override ;
49+ Add (const DataSetPtr dataset, std::shared_ptr<Config> cfg, bool use_knowhere_build_pool ) override ;
5050
5151 expected<DataSetPtr>
5252 Search (const DataSetPtr dataset, std::unique_ptr<Config> cfg, const BitsetView& bitset) const override ;
@@ -306,7 +306,8 @@ ConvertToBaseIndexFp32DataSet(const DataSetPtr& src, bool is_cosine = false,
306306
307307template <typename DataType, typename BaseIndexNode>
308308Status
309- IndexNodeWithDataViewRefiner<DataType, BaseIndexNode>::Train(const DataSetPtr dataset, std::shared_ptr<Config> cfg) {
309+ IndexNodeWithDataViewRefiner<DataType, BaseIndexNode>::Train(const DataSetPtr dataset, std::shared_ptr<Config> cfg,
310+ bool use_knowhere_build_pool) {
310311 BaseConfig& base_cfg = static_cast <BaseConfig&>(*cfg);
311312 this ->is_cosine_ = IsMetricType (base_cfg.metric_type .value (), knowhere::metric::COSINE);
312313 auto dim = dataset->GetDim ();
@@ -326,19 +327,20 @@ IndexNodeWithDataViewRefiner<DataType, BaseIndexNode>::Train(const DataSetPtr da
326327 refine_offset_index_ = std::make_unique<DataViewIndexFlat>(
327328 dim, datatype_v<DataType>, refine_metric, this ->view_data_op_ , is_cosine_, refine_type, build_thread_num);
328329 try {
329- refine_offset_index_->Train (train_rows, data);
330+ refine_offset_index_->Train (train_rows, data, use_knowhere_build_pool );
330331 } catch (const std::exception& e) {
331332 LOG_KNOWHERE_WARNING_ << " data view index inner error: " << e.what ();
332333 return Status::internal_error;
333334 }
334- return base_index_->Train (
335- fp32_train_ds,
336- cfg); // train not need base_index_lock_, all add and search will fail if train not called before
335+ return base_index_->Train (fp32_train_ds, cfg,
336+ use_knowhere_build_pool); // train not need base_index_lock_, all add and search will
337+ // fail if train not called before
337338}
338339
339340template <typename DataType, typename BaseIndexNode>
340341Status
341- IndexNodeWithDataViewRefiner<DataType, BaseIndexNode>::Add(const DataSetPtr dataset, std::shared_ptr<Config> cfg) {
342+ IndexNodeWithDataViewRefiner<DataType, BaseIndexNode>::Add(const DataSetPtr dataset, std::shared_ptr<Config> cfg,
343+ bool use_knowhere_build_pool) {
342344 auto rows = dataset->GetRows ();
343345 auto dim = dataset->GetDim ();
344346 auto data = (const DataType*)dataset->GetTensor ();
@@ -349,14 +351,14 @@ IndexNodeWithDataViewRefiner<DataType, BaseIndexNode>::Add(const DataSetPtr data
349351 auto [fp32_base_ds, norms] =
350352 ConvertToBaseIndexFp32DataSet<DataType>(dataset, is_cosine_, blk_i, blk_size, base_index_->Dim ());
351353 try {
352- refine_offset_index_->Add (blk_size, data + blk_i * dim, norms.data ());
354+ refine_offset_index_->Add (blk_size, data + blk_i * dim, norms.data (), use_knowhere_build_pool );
353355 } catch (const std::exception& e) {
354356 LOG_KNOWHERE_WARNING_ << " data view index inner error: " << e.what ();
355357 return Status::internal_error;
356358 }
357359 {
358360 FairWriteLockGuard guard (*this ->base_index_lock_ );
359- add_stat = base_index_->Add (fp32_base_ds, cfg);
361+ add_stat = base_index_->Add (fp32_base_ds, cfg, use_knowhere_build_pool );
360362 }
361363
362364 if (add_stat != Status::success) {
0 commit comments