Deprecate num_groups to simplify search API (#6230)

Signed-off-by: fluorinedog <fluorinedog@gmail.com>
pull/6242/head
FluorineDog 2021-07-01 10:32:15 +08:00 committed by GitHub
parent aaf15ec0f3
commit bf8b2be4a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 77 additions and 105 deletions

View File

@ -82,10 +82,9 @@ Search_SmallIndex(benchmark::State& state) {
segment->Insert(0, N, dataset_.row_ids_.data(), dataset_.timestamps_.data(), raw_data);
Timestamp time = 10000000;
std::vector<const PlaceholderGroup*> ph_group_arr = {ph_group.get()};
for (auto _ : state) {
auto qr = segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
auto qr = segment->Search(plan.get(), *ph_group, time);
}
}
@ -110,10 +109,8 @@ Search_Sealed(benchmark::State& state) {
segment->LoadIndex(info);
}
Timestamp time = 10000000;
std::vector<const PlaceholderGroup*> ph_group_arr = {ph_group.get()};
for (auto _ : state) {
auto qr = segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
auto qr = segment->Search(plan.get(), *ph_group, time);
}
}

View File

@ -73,13 +73,11 @@ SegmentInternalInterface::FillTargetEntry(const query::Plan* plan, QueryResult&
QueryResult
SegmentInternalInterface::Search(const query::Plan* plan,
const query::PlaceholderGroup** placeholder_groups,
const Timestamp* timestamps,
int64_t num_groups) const {
const query::PlaceholderGroup& placeholder_group,
Timestamp timestamp) const {
std::shared_lock lck(mutex_);
check_search(plan);
Assert(num_groups == 1);
query::ExecPlanNodeVisitor visitor(*this, timestamps[0], *placeholder_groups[0]);
query::ExecPlanNodeVisitor visitor(*this, timestamp, placeholder_group);
auto results = visitor.get_moved_result(*plan->plan_node_);
return results;
}

View File

@ -37,10 +37,7 @@ class SegmentInterface {
FillTargetEntry(const query::Plan* plan, QueryResult& results) const = 0;
virtual QueryResult
Search(const query::Plan* Plan,
const query::PlaceholderGroup* placeholder_groups[],
const Timestamp timestamps[],
int64_t num_groups) const = 0;
Search(const query::Plan* Plan, const query::PlaceholderGroup& placeholder_group, Timestamp timestamp) const = 0;
virtual std::unique_ptr<proto::segcore::RetrieveResults>
GetEntityById(const std::vector<FieldOffset>& field_offsets,
@ -84,9 +81,8 @@ class SegmentInternalInterface : public SegmentInterface {
QueryResult
Search(const query::Plan* Plan,
const query::PlaceholderGroup* placeholder_groups[],
const Timestamp timestamps[],
int64_t num_groups) const override;
const query::PlaceholderGroup& placeholder_group,
Timestamp timestamp) const override;
void
FillTargetEntry(const query::Plan* plan, QueryResult& results) const override;

View File

@ -67,19 +67,15 @@ DeleteQueryResult(CQueryResult query_result) {
CStatus
Search(CSegmentInterface c_segment,
CPlan c_plan,
CPlaceholderGroup* c_placeholder_groups,
uint64_t* timestamps,
int num_groups,
CPlaceholderGroup c_placeholder_group,
uint64_t timestamp,
CQueryResult* result) {
auto query_result = std::make_unique<milvus::QueryResult>();
try {
auto segment = (milvus::segcore::SegmentInterface*)c_segment;
auto plan = (milvus::query::Plan*)c_plan;
std::vector<const milvus::query::PlaceholderGroup*> placeholder_groups;
for (int i = 0; i < num_groups; ++i) {
placeholder_groups.push_back((const milvus::query::PlaceholderGroup*)c_placeholder_groups[i]);
}
*query_result = segment->Search(plan, placeholder_groups.data(), timestamps, num_groups);
auto phg_ptr = reinterpret_cast<const milvus::query::PlaceholderGroup*>(c_placeholder_group);
*query_result = segment->Search(plan, *phg_ptr, timestamp);
if (plan->plan_node_->query_info_.metric_type_ != milvus::MetricType::METRIC_INNER_PRODUCT) {
for (auto& dis : query_result->result_distances_) {
dis *= -1;

View File

@ -38,10 +38,9 @@ DeleteQueryResult(CQueryResult query_result);
CStatus
Search(CSegmentInterface c_segment,
CPlan plan,
CPlaceholderGroup* placeholder_groups,
uint64_t* timestamps,
int num_groups,
CPlan c_plan,
CPlaceholderGroup c_placeholder_group,
uint64_t timestamp,
CQueryResult* result);
CProtoResult

View File

@ -227,7 +227,7 @@ TEST(CApiTest, SearchTest) {
timestamps.push_back(1);
CQueryResult search_result;
auto res = Search(segment, plan, placeholderGroups.data(), timestamps.data(), 1, &search_result);
auto res = Search(segment, plan, placeholderGroup, timestamps[0], &search_result);
ASSERT_EQ(res.error_code, Success);
DeletePlan(plan);
@ -310,7 +310,7 @@ TEST(CApiTest, SearchTestWithExpr) {
timestamps.push_back(1);
CQueryResult search_result;
auto res = Search(segment, plan, placeholderGroups.data(), timestamps.data(), 1, &search_result);
auto res = Search(segment, plan, placeholderGroup, timestamps[0], &search_result);
ASSERT_EQ(res.error_code, Success);
DeletePlan(plan);
@ -626,9 +626,9 @@ TEST(CApiTest, Reduce) {
std::vector<CQueryResult> results;
CQueryResult res1;
CQueryResult res2;
auto res = Search(segment, plan, placeholderGroups.data(), timestamps.data(), 1, &res1);
auto res = Search(segment, plan, placeholderGroup, timestamps[0], &res1);
assert(res.error_code == Success);
res = Search(segment, plan, placeholderGroups.data(), timestamps.data(), 1, &res2);
res = Search(segment, plan, placeholderGroup, timestamps[0], &res2);
assert(res.error_code == Success);
results.push_back(res1);
results.push_back(res2);
@ -738,9 +738,9 @@ TEST(CApiTest, ReduceSearchWithExpr) {
std::vector<CQueryResult> results;
CQueryResult res1;
CQueryResult res2;
auto res = Search(segment, plan, placeholderGroups.data(), timestamps.data(), 1, &res1);
auto res = Search(segment, plan, placeholderGroup, timestamps[0], &res1);
assert(res.error_code == Success);
res = Search(segment, plan, placeholderGroups.data(), timestamps.data(), 1, &res2);
res = Search(segment, plan, placeholderGroup, timestamps[0], &res2);
assert(res.error_code == Success);
results.push_back(res1);
results.push_back(res2);
@ -924,8 +924,7 @@ TEST(CApiTest, UpdateSegmentIndex_Without_Predicate) {
Timestamp time = 10000000;
CQueryResult c_search_result_on_smallIndex;
auto res_before_load_index =
Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -975,7 +974,7 @@ TEST(CApiTest, UpdateSegmentIndex_Without_Predicate) {
assert(status.error_code == Success);
CQueryResult c_search_result_on_bigIndex;
auto res_after_load_index = Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_bigIndex);
auto res_after_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_bigIndex);
assert(res_after_load_index.error_code == Success);
auto search_result_on_raw_index_json = QueryResultToJson(*search_result_on_raw_index);
@ -1045,8 +1044,7 @@ TEST(CApiTest, UpdateSegmentIndex_Expr_Without_Predicate) {
Timestamp time = 10000000;
CQueryResult c_search_result_on_smallIndex;
auto res_before_load_index =
Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -1096,7 +1094,7 @@ TEST(CApiTest, UpdateSegmentIndex_Expr_Without_Predicate) {
assert(status.error_code == Success);
CQueryResult c_search_result_on_bigIndex;
auto res_after_load_index = Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_bigIndex);
auto res_after_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_bigIndex);
assert(res_after_load_index.error_code == Success);
auto search_result_on_raw_index_json = QueryResultToJson(*search_result_on_raw_index);
@ -1182,8 +1180,7 @@ TEST(CApiTest, UpdateSegmentIndex_With_float_Predicate_Range) {
Timestamp time = 10000000;
CQueryResult c_search_result_on_smallIndex;
auto res_before_load_index =
Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -1234,7 +1231,7 @@ TEST(CApiTest, UpdateSegmentIndex_With_float_Predicate_Range) {
assert(status.error_code == Success);
CQueryResult c_search_result_on_bigIndex;
auto res_after_load_index = Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_bigIndex);
auto res_after_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_bigIndex);
assert(res_after_load_index.error_code == Success);
auto search_result_on_bigIndex = (*(QueryResult*)c_search_result_on_bigIndex);
@ -1334,8 +1331,7 @@ TEST(CApiTest, UpdateSegmentIndex_Expr_With_float_Predicate_Range) {
Timestamp time = 10000000;
CQueryResult c_search_result_on_smallIndex;
auto res_before_load_index =
Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -1386,7 +1382,7 @@ TEST(CApiTest, UpdateSegmentIndex_Expr_With_float_Predicate_Range) {
assert(status.error_code == Success);
CQueryResult c_search_result_on_bigIndex;
auto res_after_load_index = Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_bigIndex);
auto res_after_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_bigIndex);
assert(res_after_load_index.error_code == Success);
auto search_result_on_bigIndex = (*(QueryResult*)c_search_result_on_bigIndex);
@ -1472,8 +1468,7 @@ TEST(CApiTest, UpdateSegmentIndex_With_float_Predicate_Term) {
Timestamp time = 10000000;
CQueryResult c_search_result_on_smallIndex;
auto res_before_load_index =
Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -1524,7 +1519,7 @@ TEST(CApiTest, UpdateSegmentIndex_With_float_Predicate_Term) {
assert(status.error_code == Success);
CQueryResult c_search_result_on_bigIndex;
auto res_after_load_index = Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_bigIndex);
auto res_after_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_bigIndex);
assert(res_after_load_index.error_code == Success);
auto search_result_on_bigIndex = (*(QueryResult*)c_search_result_on_bigIndex);
@ -1675,8 +1670,7 @@ TEST(CApiTest, UpdateSegmentIndex_Expr_With_float_Predicate_Term) {
Timestamp time = 10000000;
CQueryResult c_search_result_on_smallIndex;
auto res_before_load_index =
Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -1727,7 +1721,7 @@ TEST(CApiTest, UpdateSegmentIndex_Expr_With_float_Predicate_Term) {
assert(status.error_code == Success);
CQueryResult c_search_result_on_bigIndex;
auto res_after_load_index = Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_bigIndex);
auto res_after_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_bigIndex);
assert(res_after_load_index.error_code == Success);
auto search_result_on_bigIndex = (*(QueryResult*)c_search_result_on_bigIndex);
@ -1814,8 +1808,7 @@ TEST(CApiTest, UpdateSegmentIndex_With_binary_Predicate_Range) {
Timestamp time = 10000000;
CQueryResult c_search_result_on_smallIndex;
auto res_before_load_index =
Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -1867,7 +1860,7 @@ TEST(CApiTest, UpdateSegmentIndex_With_binary_Predicate_Range) {
assert(status.error_code == Success);
CQueryResult c_search_result_on_bigIndex;
auto res_after_load_index = Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_bigIndex);
auto res_after_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_bigIndex);
assert(res_after_load_index.error_code == Success);
auto search_result_on_bigIndex = (*(QueryResult*)c_search_result_on_bigIndex);
@ -1967,8 +1960,7 @@ TEST(CApiTest, UpdateSegmentIndex_Expr_With_binary_Predicate_Range) {
Timestamp time = 10000000;
CQueryResult c_search_result_on_smallIndex;
auto res_before_load_index =
Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
ASSERT_TRUE(res_before_load_index.error_code == Success) << res_before_load_index.error_msg;
// load index to segment
@ -2020,7 +2012,7 @@ TEST(CApiTest, UpdateSegmentIndex_Expr_With_binary_Predicate_Range) {
assert(status.error_code == Success);
CQueryResult c_search_result_on_bigIndex;
auto res_after_load_index = Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_bigIndex);
auto res_after_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_bigIndex);
assert(res_after_load_index.error_code == Success);
auto search_result_on_bigIndex = (*(QueryResult*)c_search_result_on_bigIndex);
@ -2106,8 +2098,7 @@ TEST(CApiTest, UpdateSegmentIndex_With_binary_Predicate_Term) {
Timestamp time = 10000000;
CQueryResult c_search_result_on_smallIndex;
auto res_before_load_index =
Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -2159,7 +2150,7 @@ TEST(CApiTest, UpdateSegmentIndex_With_binary_Predicate_Term) {
assert(status.error_code == Success);
CQueryResult c_search_result_on_bigIndex;
auto res_after_load_index = Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_bigIndex);
auto res_after_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_bigIndex);
assert(res_after_load_index.error_code == Success);
std::vector<CQueryResult> results;
@ -2317,8 +2308,7 @@ TEST(CApiTest, UpdateSegmentIndex_Expr_With_binary_Predicate_Term) {
Timestamp time = 10000000;
CQueryResult c_search_result_on_smallIndex;
auto res_before_load_index =
Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -2370,7 +2360,7 @@ TEST(CApiTest, UpdateSegmentIndex_Expr_With_binary_Predicate_Term) {
assert(status.error_code == Success);
CQueryResult c_search_result_on_bigIndex;
auto res_after_load_index = Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_bigIndex);
auto res_after_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_bigIndex);
assert(res_after_load_index.error_code == Success);
std::vector<CQueryResult> results;
@ -2581,7 +2571,7 @@ TEST(CApiTest, SealedSegment_search_float_Predicate_Range) {
assert(status.error_code == Success);
CQueryResult c_search_result_on_bigIndex;
auto res_after_load_index = Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_bigIndex);
auto res_after_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_bigIndex);
assert(res_after_load_index.error_code == Success);
auto search_result_on_bigIndex = (*(QueryResult*)c_search_result_on_bigIndex);
@ -2748,7 +2738,7 @@ TEST(CApiTest, SealedSegment_search_float_With_Expr_Predicate_Range) {
assert(status.error_code == Success);
CQueryResult c_search_result_on_bigIndex;
auto res_after_load_index = Search(segment, plan, placeholderGroups.data(), &time, 1, &c_search_result_on_bigIndex);
auto res_after_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_bigIndex);
assert(res_after_load_index.error_code == Success);
auto search_result_on_bigIndex = (*(QueryResult*)c_search_result_on_bigIndex);

View File

@ -175,8 +175,8 @@ TEST(Query, ExecWithPredicateLoader) {
auto ph_group_raw = CreatePlaceholderGroup(num_queries, 16, 1024);
auto ph_group = ParsePlaceholderGroup(plan.get(), ph_group_raw.SerializeAsString());
Timestamp time = 1000000;
std::vector<const PlaceholderGroup*> ph_group_arr = {ph_group.get()};
auto qr = segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
auto qr = segment->Search(plan.get(), *ph_group, time);
int topk = 5;
Json json = QueryResultToJson(qr);
@ -266,8 +266,8 @@ TEST(Query, ExecWithPredicateSmallN) {
auto ph_group_raw = CreatePlaceholderGroup(num_queries, 7, 1024);
auto ph_group = ParsePlaceholderGroup(plan.get(), ph_group_raw.SerializeAsString());
Timestamp time = 1000000;
std::vector<const PlaceholderGroup*> ph_group_arr = {ph_group.get()};
auto qr = segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
auto qr = segment->Search(plan.get(), *ph_group, time);
int topk = 5;
Json json = QueryResultToJson(qr);
@ -317,8 +317,8 @@ TEST(Query, ExecWithPredicate) {
auto ph_group_raw = CreatePlaceholderGroup(num_queries, 16, 1024);
auto ph_group = ParsePlaceholderGroup(plan.get(), ph_group_raw.SerializeAsString());
Timestamp time = 1000000;
std::vector<const PlaceholderGroup*> ph_group_arr = {ph_group.get()};
auto qr = segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
auto qr = segment->Search(plan.get(), *ph_group, time);
int topk = 5;
Json json = QueryResultToJson(qr);
@ -408,8 +408,8 @@ TEST(Query, ExecTerm) {
auto ph_group = ParsePlaceholderGroup(plan.get(), ph_group_raw.SerializeAsString());
QueryResult qr;
Timestamp time = 1000000;
std::vector<const PlaceholderGroup*> ph_group_arr = {ph_group.get()};
qr = segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
qr = segment->Search(plan.get(), *ph_group, time);
std::vector<std::vector<std::string>> results;
int topk = 5;
auto json = QueryResultToJson(qr);
@ -449,8 +449,8 @@ TEST(Query, ExecEmpty) {
auto ph_group_raw = CreatePlaceholderGroup(num_queries, 16, 1024);
auto ph_group = ParsePlaceholderGroup(plan.get(), ph_group_raw.SerializeAsString());
Timestamp time = 1000000;
std::vector<const PlaceholderGroup*> ph_group_arr = {ph_group.get()};
auto qr = segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
auto qr = segment->Search(plan.get(), *ph_group, time);
std::cout << QueryResultToJson(qr);
for (auto i : qr.internal_seg_offsets_) {
@ -498,8 +498,8 @@ TEST(Query, ExecWithoutPredicateFlat) {
auto ph_group = ParsePlaceholderGroup(plan.get(), ph_group_raw.SerializeAsString());
QueryResult qr;
Timestamp time = 1000000;
std::vector<const PlaceholderGroup*> ph_group_arr = {ph_group.get()};
qr = segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
qr = segment->Search(plan.get(), *ph_group, time);
std::vector<std::vector<std::string>> results;
int topk = 5;
auto json = QueryResultToJson(qr);
@ -542,8 +542,8 @@ TEST(Query, ExecWithoutPredicate) {
auto ph_group = ParsePlaceholderGroup(plan.get(), ph_group_raw.SerializeAsString());
QueryResult qr;
Timestamp time = 1000000;
std::vector<const PlaceholderGroup*> ph_group_arr = {ph_group.get()};
qr = segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
qr = segment->Search(plan.get(), *ph_group, time);
std::vector<std::vector<std::string>> results;
int topk = 5;
auto json = QueryResultToJson(qr);
@ -625,10 +625,9 @@ TEST(Indexing, InnerProduct) {
auto ph_group_raw = CreatePlaceholderGroupFromBlob(num_queries, 16, col.data());
auto ph_group = ParsePlaceholderGroup(plan.get(), ph_group_raw.SerializeAsString());
std::vector<Timestamp> ts{(Timestamp)N * 2};
const auto* ptr = ph_group.get();
Timestamp ts = N * 2;
QueryResult qr;
qr = segment->Search(plan.get(), &ptr, ts.data(), 1);
qr = segment->Search(plan.get(), *ph_group, ts);
std::cout << QueryResultToJson(qr).dump(2);
}
@ -728,8 +727,7 @@ TEST(Query, FillSegment) {
auto plan = CreatePlan(*schema, dsl);
auto ph_proto = CreatePlaceholderGroup(10, 16, 443);
auto ph = ParsePlaceholderGroup(plan.get(), ph_proto.SerializeAsString());
std::vector<const PlaceholderGroup*> groups = {ph.get()};
std::vector<Timestamp> timestamps = {N * 2UL};
Timestamp ts = N * 2UL;
auto topk = 5;
auto num_queries = 10;
@ -737,7 +735,7 @@ TEST(Query, FillSegment) {
plan->target_entries_.clear();
plan->target_entries_.push_back(schema->get_offset(FieldName("fakevec")));
plan->target_entries_.push_back(schema->get_offset(FieldName("the_value")));
QueryResult result = segment->Search(plan.get(), groups.data(), timestamps.data(), 1);
QueryResult result = segment->Search(plan.get(), *ph, ts);
// std::cout << QueryResultToJson(result).dump(2);
result.result_offsets_.resize(topk * num_queries);
segment->FillTargetEntry(plan.get(), result);
@ -816,8 +814,8 @@ TEST(Query, ExecWithPredicateBinary) {
auto ph_group = ParsePlaceholderGroup(plan.get(), ph_group_raw.SerializeAsString());
QueryResult qr;
Timestamp time = 1000000;
std::vector<const PlaceholderGroup*> ph_group_arr = {ph_group.get()};
qr = segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
qr = segment->Search(plan.get(), *ph_group, time);
int topk = 5;
Json json = QueryResultToJson(qr);

View File

@ -73,7 +73,7 @@ TEST(Sealed, without_predicate) {
Timestamp time = 1000000;
std::vector<const PlaceholderGroup*> ph_group_arr = {ph_group.get()};
qr = segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
qr = segment->Search(plan.get(), *ph_group, time);
auto pre_result = QueryResultToJson(qr);
auto indexing = std::make_shared<knowhere::IVF>();
@ -112,7 +112,7 @@ TEST(Sealed, without_predicate) {
segment->LoadIndexing(load_info);
qr = QueryResult();
qr = segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
qr = segment->Search(plan.get(), *ph_group, time);
auto post_result = QueryResultToJson(qr);
std::cout << ref_result.dump(1);
@ -174,7 +174,7 @@ TEST(Sealed, with_predicate) {
Timestamp time = 10000000;
std::vector<const PlaceholderGroup*> ph_group_arr = {ph_group.get()};
qr = segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
qr = segment->Search(plan.get(), *ph_group, time);
auto pre_qr = qr;
auto indexing = std::make_shared<knowhere::IVF>();
@ -204,7 +204,7 @@ TEST(Sealed, with_predicate) {
segment->LoadIndexing(load_info);
qr = QueryResult();
qr = segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
qr = segment->Search(plan.get(), *ph_group, time);
auto post_qr = qr;
for (int i = 0; i < num_queries; ++i) {
@ -264,16 +264,15 @@ TEST(Sealed, LoadFieldData) {
auto num_queries = 5;
auto ph_group_raw = CreatePlaceholderGroup(num_queries, 16, 1024);
auto ph_group = ParsePlaceholderGroup(plan.get(), ph_group_raw.SerializeAsString());
std::vector<const PlaceholderGroup*> ph_group_arr = {ph_group.get()};
ASSERT_ANY_THROW(segment->Search(plan.get(), ph_group_arr.data(), &time, 1));
ASSERT_ANY_THROW(segment->Search(plan.get(), *ph_group, time));
SealedLoader(dataset, *segment);
segment->DropFieldData(nothing_id);
segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
segment->Search(plan.get(), *ph_group, time);
segment->DropFieldData(fakevec_id);
ASSERT_ANY_THROW(segment->Search(plan.get(), ph_group_arr.data(), &time, 1));
ASSERT_ANY_THROW(segment->Search(plan.get(), *ph_group, time));
LoadIndexInfo vec_info;
vec_info.field_id = fakevec_id.get();
@ -291,18 +290,18 @@ TEST(Sealed, LoadFieldData) {
ASSERT_EQ(chunk_span2[i], ref2[i]);
}
auto qr = segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
auto qr = segment->Search(plan.get(), *ph_group, time);
auto json = QueryResultToJson(qr);
std::cout << json.dump(1);
segment->DropIndex(fakevec_id);
ASSERT_ANY_THROW(segment->Search(plan.get(), ph_group_arr.data(), &time, 1));
ASSERT_ANY_THROW(segment->Search(plan.get(), *ph_group, time));
segment->LoadIndex(vec_info);
auto qr2 = segment->Search(plan.get(), ph_group_arr.data(), &time, 1);
auto qr2 = segment->Search(plan.get(), *ph_group, time);
auto json2 = QueryResultToJson(qr);
ASSERT_EQ(json.dump(-2), json2.dump(-2));
segment->DropFieldData(double_id);
ASSERT_ANY_THROW(segment->Search(plan.get(), ph_group_arr.data(), &time, 1));
ASSERT_ANY_THROW(segment->Search(plan.get(), *ph_group, time));
auto std_json = Json::parse(R"(
[
[

View File

@ -232,12 +232,11 @@ func (s *Segment) segmentSearch(plan *Plan,
}
var searchResult SearchResult
var cTimestamp = (*C.ulong)(&timestamp[0])
var cPlaceHolder = (*C.CPlaceholderGroup)(&cPlaceholderGroups[0])
var cNumGroups = C.int(len(searchRequests))
ts := C.uint64_t(timestamp[0])
cPlaceHolderGroup := cPlaceholderGroups[0]
log.Debug("do search on segment", zap.Int64("segmentID", s.segmentID), zap.Int32("segmentType", int32(s.segmentType)))
var status = C.Search(s.segmentPtr, plan.cPlan, cPlaceHolder, cTimestamp, cNumGroups, &searchResult.cQueryResult)
var status = C.Search(s.segmentPtr, plan.cPlan, cPlaceHolderGroup, ts, &searchResult.cQueryResult)
errorCode := status.error_code
if errorCode != 0 {