mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
fix: avoid mvcc when doing pk compare expr (#44353)
#44352 Signed-off-by: luzhang <luzhang@zilliz.com> Co-authored-by: luzhang <luzhang@zilliz.com>
This commit is contained in:
parent
e9bbb6aa9b
commit
baa84e0b2b
@ -1311,11 +1311,10 @@ PhyUnaryRangeFilterExpr::ExecRangeVisitorImplForPk(EvalCtx& context) {
|
||||
case proto::plan::LessThan:
|
||||
case proto::plan::LessEqual:
|
||||
case proto::plan::Equal:
|
||||
segment_->pk_range(op_type, pk, query_timestamp, cache_view);
|
||||
segment_->pk_range(op_type, pk, cache_view);
|
||||
break;
|
||||
case proto::plan::NotEqual: {
|
||||
segment_->pk_range(
|
||||
proto::plan::Equal, pk, query_timestamp, cache_view);
|
||||
segment_->pk_range(proto::plan::Equal, pk, cache_view);
|
||||
cache_view.flip();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1139,16 +1139,13 @@ ChunkedSegmentSealedImpl::search_sorted_pk(const PkType& pk,
|
||||
void
|
||||
ChunkedSegmentSealedImpl::pk_range(proto::plan::OpType op,
|
||||
const PkType& pk,
|
||||
Timestamp timestamp,
|
||||
BitsetTypeView& bitset) const {
|
||||
if (!is_sorted_by_pk_) {
|
||||
insert_record_.search_pk_range(pk, timestamp, op, bitset);
|
||||
insert_record_.search_pk_range(pk, op, bitset);
|
||||
return;
|
||||
}
|
||||
|
||||
search_sorted_pk_range(op, pk, bitset, [this, timestamp](int64_t offset) {
|
||||
return insert_record_.timestamps_[offset] <= timestamp;
|
||||
});
|
||||
search_sorted_pk_range(op, pk, bitset, [](int64_t offset) { return true; });
|
||||
}
|
||||
|
||||
template <typename Condition>
|
||||
|
||||
@ -205,7 +205,6 @@ class ChunkedSegmentSealedImpl : public SegmentSealed {
|
||||
void
|
||||
pk_range(proto::plan::OpType op,
|
||||
const PkType& pk,
|
||||
Timestamp timestamp,
|
||||
BitsetTypeView& bitset) const override;
|
||||
|
||||
template <typename Condition>
|
||||
|
||||
@ -444,16 +444,12 @@ TEST_P(TestChunkSegment, TestPkRange) {
|
||||
|
||||
// Test Equal operation
|
||||
if (pk_is_string) {
|
||||
segment_impl->pk_range(proto::plan::OpType::Equal,
|
||||
PkType("test1"),
|
||||
Timestamp(99999),
|
||||
bitset_sorted_view);
|
||||
segment_impl->pk_range(
|
||||
proto::plan::OpType::Equal, PkType("test1"), bitset_sorted_view);
|
||||
EXPECT_EQ(1, bitset_sorted_view.count());
|
||||
} else {
|
||||
segment_impl->pk_range(proto::plan::OpType::Equal,
|
||||
PkType(1),
|
||||
Timestamp(99999),
|
||||
bitset_sorted_view);
|
||||
segment_impl->pk_range(
|
||||
proto::plan::OpType::Equal, PkType(1), bitset_sorted_view);
|
||||
EXPECT_EQ(1, bitset_sorted_view.count());
|
||||
}
|
||||
|
||||
@ -462,15 +458,12 @@ TEST_P(TestChunkSegment, TestPkRange) {
|
||||
if (pk_is_string) {
|
||||
segment_impl->pk_range(proto::plan::OpType::LessEqual,
|
||||
PkType("test100"),
|
||||
Timestamp(99999),
|
||||
bitset_sorted_view);
|
||||
// only 'test0', 'test1', 'test10' are less than 'test100'
|
||||
EXPECT_EQ(bitset_sorted_view.count(), 4);
|
||||
} else {
|
||||
segment_impl->pk_range(proto::plan::OpType::LessEqual,
|
||||
PkType(100),
|
||||
Timestamp(99999),
|
||||
bitset_sorted_view);
|
||||
segment_impl->pk_range(
|
||||
proto::plan::OpType::LessEqual, PkType(100), bitset_sorted_view);
|
||||
EXPECT_EQ(bitset_sorted_view.count(), 101);
|
||||
}
|
||||
|
||||
@ -478,13 +471,11 @@ TEST_P(TestChunkSegment, TestPkRange) {
|
||||
if (pk_is_string) {
|
||||
segment_impl->pk_range(proto::plan::OpType::Equal,
|
||||
PkType(std::string("non_existent_pk")),
|
||||
Timestamp(99999),
|
||||
bitset_sorted_view);
|
||||
EXPECT_EQ(0, bitset_sorted_view.count());
|
||||
} else {
|
||||
segment_impl->pk_range(proto::plan::OpType::Equal,
|
||||
PkType(int64_t(999999)),
|
||||
Timestamp(99999),
|
||||
bitset_sorted_view);
|
||||
EXPECT_EQ(0, bitset_sorted_view.count());
|
||||
}
|
||||
|
||||
@ -488,6 +488,14 @@ class InsertRecordSealed {
|
||||
return res_offsets;
|
||||
}
|
||||
|
||||
void
|
||||
search_pk_range(const PkType& pk,
|
||||
proto::plan::OpType op,
|
||||
BitsetTypeView& bitset) const {
|
||||
pk2offset_->find_range(
|
||||
pk, op, bitset, [](int64_t offset) { return true; });
|
||||
}
|
||||
|
||||
void
|
||||
search_pk_range(const PkType& pk,
|
||||
Timestamp timestamp,
|
||||
@ -662,6 +670,14 @@ class InsertRecordGrowing {
|
||||
return res_offsets;
|
||||
}
|
||||
|
||||
void
|
||||
search_pk_range(const PkType& pk,
|
||||
proto::plan::OpType op,
|
||||
BitsetTypeView& bitset) const {
|
||||
pk2offset_->find_range(
|
||||
pk, op, bitset, [](int64_t offset) { return true; });
|
||||
}
|
||||
|
||||
void
|
||||
search_pk_range(const PkType& pk,
|
||||
Timestamp timestamp,
|
||||
|
||||
@ -410,9 +410,8 @@ class SegmentGrowingImpl : public SegmentGrowing {
|
||||
void
|
||||
pk_range(proto::plan::OpType op,
|
||||
const PkType& pk,
|
||||
Timestamp timestamp,
|
||||
BitsetTypeView& bitset) const override {
|
||||
insert_record_.search_pk_range(pk, timestamp, op, bitset);
|
||||
insert_record_.search_pk_range(pk, op, bitset);
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@ -542,7 +542,6 @@ class SegmentInternalInterface : public SegmentInterface {
|
||||
virtual void
|
||||
pk_range(proto::plan::OpType op,
|
||||
const PkType& pk,
|
||||
Timestamp timestamp,
|
||||
BitsetTypeView& bitset) const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user