mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-03 17:31:58 +08:00
MS-151 Fix topk problem
Former-commit-id: eeac049095172303c32f4f26ee13b9c8724870b0
This commit is contained in:
parent
55afa772d3
commit
45c172543f
@ -138,7 +138,6 @@ Status FaissExecutionEngine::Search(long n,
|
||||
auto start_time = METRICS_NOW_TIME;
|
||||
|
||||
std::shared_ptr<faiss::IndexIVF> ivf_index = std::dynamic_pointer_cast<faiss::IndexIVF>(pIndex_);
|
||||
//ENGINE_LOG_DEBUG << "Index nlist: " << ivf_index->nlist << ", ntotal: "<< ivf_index->ntotal;
|
||||
if(ivf_index) {
|
||||
ENGINE_LOG_DEBUG << "Index type: IVFFLAT nProbe: " << nprobe_;
|
||||
ivf_index->nprobe = nprobe_;
|
||||
|
||||
@ -151,7 +151,7 @@ std::shared_ptr<IScheduleTask> SearchTask::Execute() {
|
||||
std::vector<float> output_distence;
|
||||
for(auto& context : search_contexts_) {
|
||||
//step 1: allocate memory
|
||||
auto inner_k = index_engine_->Count() < context->topk() ? index_engine_->Count() : context->topk();
|
||||
auto inner_k = context->topk();
|
||||
output_ids.resize(inner_k*context->nq());
|
||||
output_distence.resize(inner_k*context->nq());
|
||||
|
||||
@ -164,17 +164,10 @@ std::shared_ptr<IScheduleTask> SearchTask::Execute() {
|
||||
|
||||
//step 3: cluster result
|
||||
SearchContext::ResultSet result_set;
|
||||
ClusterResult(output_ids, output_distence, context->nq(), inner_k, result_set);
|
||||
auto spec_k = index_engine_->Count() < context->topk() ? index_engine_->Count() : context->topk();
|
||||
ClusterResult(output_ids, output_distence, context->nq(), spec_k, result_set);
|
||||
rc.Record("cluster result");
|
||||
|
||||
|
||||
SERVER_LOG_DEBUG << "Query Result: ";
|
||||
for(auto& id2score_vector: result_set) {
|
||||
for(auto& pair: id2score_vector) {
|
||||
SERVER_LOG_DEBUG << "id: " << pair.first << ", distance: " << pair.second;
|
||||
}
|
||||
}
|
||||
|
||||
//step 4: pick up topk result
|
||||
TopkResult(result_set, inner_k, context->GetResult());
|
||||
rc.Record("reduce topk");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user