Skip to content

Commit 5edeeb5

Browse files
authored
Define new SubSearchResult constructor to avoid memory copy for growing (milvus-io#18000)
segment search Signed-off-by: yudong.cai <yudong.cai@zilliz.com>
1 parent 7d6624f commit 5edeeb5

3 files changed

Lines changed: 14 additions & 15 deletions

File tree

internal/core/src/query/SearchOnGrowing.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ FloatSearch(const segcore::SegmentGrowingImpl& segment,
9999
}
100100
final_qr.merge(sub_qr);
101101
}
102-
current_chunk_id = max_chunk;
103102
results.distances_ = std::move(final_qr.mutable_distances());
104103
results.seg_offsets_ = std::move(final_qr.mutable_seg_offsets());
105104
results.unity_topK_ = topk;

internal/core/src/query/SubSearchResult.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,6 @@ SubSearchResult::merge(const SubSearchResult& sub_result) {
6868
}
6969
}
7070

71-
SubSearchResult
72-
SubSearchResult::merge(const SubSearchResult& left, const SubSearchResult& right) {
73-
auto left_copy = left;
74-
left_copy.merge(right);
75-
return left_copy;
76-
}
77-
7871
void
7972
SubSearchResult::round_values() {
8073
if (round_decimal_ == -1)

internal/core/src/query/SubSearchResult.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#pragma once
1313

1414
#include <limits>
15+
#include <utility>
1516
#include <vector>
1617
#include "common/Types.h"
1718

@@ -20,12 +21,21 @@ namespace milvus::query {
2021
class SubSearchResult {
2122
public:
2223
SubSearchResult(int64_t num_queries, int64_t topk, const knowhere::MetricType& metric_type, int64_t round_decimal)
23-
: metric_type_(metric_type),
24-
num_queries_(num_queries),
24+
: num_queries_(num_queries),
2525
topk_(topk),
26+
round_decimal_(round_decimal),
27+
metric_type_(metric_type),
2628
seg_offsets_(num_queries * topk, -1),
27-
distances_(num_queries * topk, init_value(metric_type)),
28-
round_decimal_(round_decimal) {
29+
distances_(num_queries * topk, init_value(metric_type)) {
30+
}
31+
32+
SubSearchResult(SubSearchResult&& other)
33+
: num_queries_(other.num_queries_),
34+
topk_(other.topk_),
35+
round_decimal_(other.round_decimal_),
36+
metric_type_(other.metric_type_),
37+
seg_offsets_(std::move(other.seg_offsets_)),
38+
distances_(std::move(other.distances_)) {
2939
}
3040

3141
public:
@@ -88,9 +98,6 @@ class SubSearchResult {
8898
void
8999
round_values();
90100

91-
static SubSearchResult
92-
merge(const SubSearchResult& left, const SubSearchResult& right);
93-
94101
void
95102
merge(const SubSearchResult& sub_result);
96103

0 commit comments

Comments
 (0)