Optimize segcore API GetResultData (#10548)

Signed-off-by: yudong.cai <yudong.cai@zilliz.com>
pull/10578/head
Cai Yudong 2021-10-25 17:53:20 +08:00 committed by GitHub
parent 880e375b00
commit e4909c1c0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -94,7 +94,7 @@ GetResultData(std::vector<std::vector<int64_t>>& search_records,
// remove duplicates
if (curr_pk == -1 || std::abs(curr_dis - prev_dis) > 0.00001) {
result_pair.search_result_->result_offsets_.push_back(loc_offset++);
search_records[index].push_back(result_pair.offset_++);
search_records[index].push_back(result_pair.offset_);
prev_dis = curr_dis;
prev_pk_set.clear();
prev_pk_set.insert(curr_pk);
@ -105,15 +105,15 @@ GetResultData(std::vector<std::vector<int64_t>>& search_records,
// e3: [100, 0.99] ==> duplicated, should remove
if (prev_pk_set.count(curr_pk) == 0) {
result_pair.search_result_->result_offsets_.push_back(loc_offset++);
search_records[index].push_back(result_pair.offset_++);
search_records[index].push_back(result_pair.offset_);
// prev_pk_set keeps all primary keys with same distance
prev_pk_set.insert(curr_pk);
} else {
// the entity with same distance and same primary key must be duplicated
result_pair.offset_++;
LOG_SEGCORE_DEBUG_ << "skip duplicated search result, primary key " << curr_pk;
}
}
result_pair.offset_++;
}
#endif
}