Fix parallel merge issue

Former-commit-id: 7eae24c65e50c6c0abc423b841c14bf16a8c0a1d
This commit is contained in:
jinhai 2019-10-31 11:03:22 +00:00
parent e316271a0d
commit 71fa8bdd05
2 changed files with 8 additions and 1 deletions

View File

@ -90,6 +90,10 @@ class SearchJob : public Job {
return index_files_;
}
std::mutex& mutex() {
return mutex_;
}
private:
uint64_t topk_ = 0;
uint64_t nq_ = 0;

View File

@ -219,8 +219,11 @@ XSearchTask::Execute() {
// step 3: pick up topk result
auto spec_k = index_engine_->Count() < topk ? index_engine_->Count() : topk;
XSearchTask::MergeTopkToResultSet(output_ids, output_distance, spec_k, nq, topk, metric_l2,
{
std::unique_lock<std::mutex> lock(search_job->mutex());
XSearchTask::MergeTopkToResultSet(output_ids, output_distance, spec_k, nq, topk, metric_l2,
search_job->GetResult());
}
span = rc.RecordSection(hdr + ", reduce topk");
// search_job->AccumReduceCost(span);