@@ -375,8 +375,6 @@ ExecutionEngineImpl::Serialize() {
375375
376376Status
377377ExecutionEngineImpl::Load (bool to_cache) {
378- // TODO(zhiru): refactor
379-
380378 index_ = std::static_pointer_cast<knowhere::VecIndex>(cache::CpuCacheMgr::GetInstance ()->GetIndex (location_));
381379 bool already_in_cache = (index_ != nullptr );
382380 if (!already_in_cache) {
@@ -411,21 +409,19 @@ ExecutionEngineImpl::Load(bool to_cache) {
411409 auto & vectors = segment_ptr->vectors_ptr_ ;
412410 auto & deleted_docs = segment_ptr->deleted_docs_ptr_ ->GetDeletedDocs ();
413411
414- auto vectors_uids = vectors->GetUids ();
412+ auto & vectors_uids = vectors->GetMutableUids ();
413+ auto count = vectors_uids.size ();
415414 index_->SetUids (vectors_uids);
416415 ENGINE_LOG_DEBUG << " set uids " << index_->GetUids ().size () << " for index " << location_;
417416
418- auto vectors_data = vectors->GetData ();
417+ auto & vectors_data = vectors->GetData ();
419418
420- faiss::ConcurrentBitsetPtr concurrent_bitset_ptr =
421- std::make_shared<faiss::ConcurrentBitset>(vectors->GetCount ());
419+ faiss::ConcurrentBitsetPtr concurrent_bitset_ptr = std::make_shared<faiss::ConcurrentBitset>(count);
422420 for (auto & offset : deleted_docs) {
423- if (!concurrent_bitset_ptr->test (offset)) {
424- concurrent_bitset_ptr->set (offset);
425- }
421+ concurrent_bitset_ptr->set (offset);
426422 }
427423
428- auto dataset = knowhere::GenDataset (vectors-> GetCount () , this ->dim_ , vectors_data.data ());
424+ auto dataset = knowhere::GenDataset (count , this ->dim_ , vectors_data.data ());
429425 if (index_type_ == EngineType::FAISS_IDMAP) {
430426 auto bf_index = std::static_pointer_cast<knowhere::IDMAP>(index_);
431427 bf_index->Train (knowhere::DatasetPtr (), conf);
0 commit comments