mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
Fix typo and time record
Former-commit-id: bd76bb403d0869125d48ecaf4a853c206e82106c
This commit is contained in:
parent
ae352dfa23
commit
521227bfdb
@ -103,6 +103,8 @@ XSearchTask::Load(LoadType type, uint8_t device_id) {
|
||||
index_engine_->CopyToCpu();
|
||||
} else {
|
||||
// TODO: exception
|
||||
std::string msg = "Wrong load type";
|
||||
ENGINE_LOG_ERROR << msg;
|
||||
}
|
||||
} catch (std::exception &ex) {
|
||||
//typical error: out of disk space or permition denied
|
||||
@ -147,17 +149,17 @@ XSearchTask::Execute() {
|
||||
server::CollectDurationMetrics metrics(index_type_);
|
||||
|
||||
std::vector<long> output_ids;
|
||||
std::vector<float> output_distence;
|
||||
std::vector<float> output_distance;
|
||||
for (auto &context : search_contexts_) {
|
||||
//step 1: allocate memory
|
||||
auto inner_k = context->topk();
|
||||
auto nprobe = context->nprobe();
|
||||
output_ids.resize(inner_k * context->nq());
|
||||
output_distence.resize(inner_k * context->nq());
|
||||
output_distance.resize(inner_k * context->nq());
|
||||
|
||||
try {
|
||||
//step 2: search
|
||||
index_engine_->Search(context->nq(), context->vectors(), inner_k, nprobe, output_distence.data(),
|
||||
index_engine_->Search(context->nq(), context->vectors(), inner_k, nprobe, output_distance.data(),
|
||||
output_ids.data());
|
||||
|
||||
double span = rc.RecordSection("do search for context:" + context->Identity());
|
||||
@ -167,12 +169,12 @@ XSearchTask::Execute() {
|
||||
//step 3: cluster result
|
||||
SearchContext::ResultSet result_set;
|
||||
auto spec_k = index_engine_->Count() < context->topk() ? index_engine_->Count() : context->topk();
|
||||
XSearchTask::ClusterResult(output_ids, output_distence, context->nq(), spec_k, result_set);
|
||||
XSearchTask::ClusterResult(output_ids, output_distance, context->nq(), spec_k, result_set);
|
||||
|
||||
span = rc.RecordSection("cluster result for context:" + context->Identity());
|
||||
context->AccumReduceCost(span);
|
||||
|
||||
//step 4: pick up topk result
|
||||
// step 4: pick up topk result
|
||||
XSearchTask::TopkResult(result_set, inner_k, metric_l2, context->GetResult());
|
||||
|
||||
span = rc.RecordSection("reduce topk for context:" + context->Identity());
|
||||
@ -194,13 +196,13 @@ XSearchTask::Execute() {
|
||||
}
|
||||
|
||||
Status XSearchTask::ClusterResult(const std::vector<long> &output_ids,
|
||||
const std::vector<float> &output_distence,
|
||||
const std::vector<float> &output_distance,
|
||||
uint64_t nq,
|
||||
uint64_t topk,
|
||||
SearchContext::ResultSet &result_set) {
|
||||
if (output_ids.size() < nq * topk || output_distence.size() < nq * topk) {
|
||||
if (output_ids.size() < nq * topk || output_distance.size() < nq * topk) {
|
||||
std::string msg = "Invalid id array size: " + std::to_string(output_ids.size()) +
|
||||
" distance array size: " + std::to_string(output_distence.size());
|
||||
" distance array size: " + std::to_string(output_distance.size());
|
||||
ENGINE_LOG_ERROR << msg;
|
||||
return Status(DB_ERROR, msg);
|
||||
}
|
||||
@ -217,7 +219,7 @@ Status XSearchTask::ClusterResult(const std::vector<long> &output_ids,
|
||||
if (output_ids[index] < 0) {
|
||||
continue;
|
||||
}
|
||||
id_distance.push_back(std::make_pair(output_ids[index], output_distence[index]));
|
||||
id_distance.push_back(std::make_pair(output_ids[index], output_distance[index]));
|
||||
}
|
||||
result_set[i] = id_distance;
|
||||
}
|
||||
|
||||
@ -652,7 +652,7 @@ SearchTask::OnExecute() {
|
||||
search_param_->query_record_array(i).vector_data().data(),
|
||||
table_info.dimension_ * sizeof(float));
|
||||
}
|
||||
rc.ElapseFromBegin("prepare vector data");
|
||||
rc.RecordSection("prepare vector data");
|
||||
|
||||
//step 6: search vectors
|
||||
engine::QueryResults results;
|
||||
@ -666,7 +666,7 @@ SearchTask::OnExecute() {
|
||||
record_count, nprobe, vec_f.data(), dates, results);
|
||||
}
|
||||
|
||||
rc.ElapseFromBegin("search vectors from engine");
|
||||
rc.RecordSection("search vectors from engine");
|
||||
if (!stat.ok()) {
|
||||
return SetError(DB_META_TRANSACTION_FAILED, stat.ToString());
|
||||
}
|
||||
@ -681,8 +681,6 @@ SearchTask::OnExecute() {
|
||||
return SetError(SERVER_ILLEGAL_SEARCH_RESULT, msg);
|
||||
}
|
||||
|
||||
rc.ElapseFromBegin("do search");
|
||||
|
||||
//step 7: construct result array
|
||||
for (auto &result : results) {
|
||||
::milvus::grpc::TopKQueryResult *topk_query_result = topk_result_list->add_topk_query_result();
|
||||
@ -698,7 +696,7 @@ SearchTask::OnExecute() {
|
||||
#endif
|
||||
|
||||
//step 8: print time cost percent
|
||||
double span_result = rc.RecordSection("construct result");
|
||||
rc.RecordSection("construct result and send");
|
||||
rc.ElapseFromBegin("totally cost");
|
||||
|
||||
|
||||
@ -972,4 +970,4 @@ DropIndexTask::OnExecute() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,6 +103,7 @@ ErrorCode VecIndexImpl::Search(const long &nq, const float *xq, float *dist, lon
|
||||
// TODO(linxj): avoid copy here.
|
||||
memcpy(ids, p_ids, sizeof(int64_t) * nq * k);
|
||||
memcpy(dist, p_dist, sizeof(float) * nq * k);
|
||||
|
||||
} catch (KnowhereException &e) {
|
||||
WRAPPER_LOG_ERROR << e.what();
|
||||
return KNOWHERE_UNEXPECTED_ERROR;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user