mirror of https://github.com/milvus-io/milvus.git
parent
37dc1639e8
commit
0304a8014b
|
@ -140,7 +140,15 @@ ExecPlanNodeVisitor::visit(RetrievePlanNode& node) {
|
|||
|
||||
segment->mask_with_timestamps(bitset_holder, timestamp_);
|
||||
|
||||
auto seg_offsets = std::move(segment->search_ids(bitset_holder, MAX_TIMESTAMP));
|
||||
BitsetView view;
|
||||
if (!bitset_holder.empty()) {
|
||||
bitset_holder.flip();
|
||||
view = BitsetView((uint8_t*)boost_ext::get_data(bitset_holder), bitset_holder.size());
|
||||
}
|
||||
|
||||
auto final_bitset = segment->get_filtered_bitmap(view, active_count, MAX_TIMESTAMP);
|
||||
|
||||
auto seg_offsets = std::move(segment->search_ids(final_bitset, MAX_TIMESTAMP));
|
||||
ret.result_offsets_.assign((int64_t*)seg_offsets.data(), (int64_t*)seg_offsets.data() + seg_offsets.size());
|
||||
retrieve_ret_ = ret;
|
||||
}
|
||||
|
|
|
@ -485,6 +485,27 @@ SegmentGrowingImpl::search_ids(const boost::dynamic_bitset<>& bitset, Timestamp
|
|||
return res_offsets;
|
||||
}
|
||||
|
||||
std::vector<SegOffset>
|
||||
SegmentGrowingImpl::search_ids(const BitsetView& bitset, Timestamp timestamp) const {
|
||||
std::vector<SegOffset> res_offsets;
|
||||
|
||||
for (int i = 0; i < bitset.size(); ++i) {
|
||||
if (!bitset.test(i)) {
|
||||
SegOffset the_offset(-1);
|
||||
auto offset = SegOffset(i);
|
||||
if (record_.timestamps_[offset.get()] < timestamp) {
|
||||
the_offset = std::max(the_offset, offset);
|
||||
}
|
||||
|
||||
if (the_offset == SegOffset(-1)) {
|
||||
continue;
|
||||
}
|
||||
res_offsets.push_back(the_offset);
|
||||
}
|
||||
}
|
||||
return res_offsets;
|
||||
}
|
||||
|
||||
std::pair<std::unique_ptr<IdArray>, std::vector<SegOffset>>
|
||||
SegmentGrowingImpl::search_ids(const IdArray& id_array, Timestamp timestamp) const {
|
||||
AssertInfo(id_array.has_int_id(), "Id array doesn't have int_id element");
|
||||
|
|
|
@ -191,6 +191,9 @@ class SegmentGrowingImpl : public SegmentGrowing {
|
|||
std::vector<SegOffset>
|
||||
search_ids(const boost::dynamic_bitset<>& view, Timestamp timestamp) const override;
|
||||
|
||||
std::vector<SegOffset>
|
||||
search_ids(const BitsetView& view, Timestamp timestamp) const override;
|
||||
|
||||
protected:
|
||||
int64_t
|
||||
num_chunk() const override;
|
||||
|
|
|
@ -129,6 +129,9 @@ class SegmentInternalInterface : public SegmentInterface {
|
|||
virtual std::vector<SegOffset>
|
||||
search_ids(const boost::dynamic_bitset<>& view, Timestamp timestamp) const = 0;
|
||||
|
||||
virtual std::vector<SegOffset>
|
||||
search_ids(const BitsetView& view, Timestamp timestamp) const = 0;
|
||||
|
||||
protected:
|
||||
// internal API: return chunk_data in span
|
||||
virtual SpanBase
|
||||
|
|
|
@ -574,6 +574,17 @@ SegmentSealedImpl::search_ids(const boost::dynamic_bitset<>& bitset, Timestamp t
|
|||
return std::move(dst_offset);
|
||||
}
|
||||
|
||||
std::vector<SegOffset>
|
||||
SegmentSealedImpl::search_ids(const BitsetView& bitset, Timestamp timestamp) const {
|
||||
std::vector<SegOffset> dst_offset;
|
||||
for (int i = 0; i < bitset.size(); i++) {
|
||||
if (!bitset.test(i)) {
|
||||
dst_offset.emplace_back(SegOffset(i));
|
||||
}
|
||||
}
|
||||
return std::move(dst_offset);
|
||||
}
|
||||
|
||||
std::string
|
||||
SegmentSealedImpl::debug() const {
|
||||
std::string log_str;
|
||||
|
|
|
@ -148,6 +148,9 @@ class SegmentSealedImpl : public SegmentSealed {
|
|||
std::pair<std::unique_ptr<IdArray>, std::vector<SegOffset>>
|
||||
search_ids(const IdArray& id_array, Timestamp timestamp) const override;
|
||||
|
||||
std::vector<SegOffset>
|
||||
search_ids(const BitsetView& view, Timestamp timestamp) const override;
|
||||
|
||||
std::vector<SegOffset>
|
||||
search_ids(const boost::dynamic_bitset<>& view, Timestamp timestamp) const override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue