From 621196e587787f1d7f740555ec42d412845b6542 Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Tue, 24 Dec 2024 11:11:57 +0800 Subject: [PATCH] fix --- be/src/common/config.cpp | 2 +- be/src/olap/base_tablet.cpp | 8 ++++---- be/src/olap/compaction.cpp | 4 ++-- be/src/olap/rowset/rowset_meta.cpp | 13 ++++++------- be/src/util/slice.cpp | 4 ++-- be/src/util/slice.h | 4 ++-- be/src/vec/olap/block_reader.cpp | 6 +++--- .../olap/segments_key_bounds_truncation_test.cpp | 6 +++--- 8 files changed, 23 insertions(+), 24 deletions(-) diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp index b016b5d42795e0..693e15b468f5d0 100644 --- a/be/src/common/config.cpp +++ b/be/src/common/config.cpp @@ -1407,7 +1407,7 @@ DEFINE_mBool(enable_sleep_between_delete_cumu_compaction, "false"); DEFINE_mInt32(compaction_num_per_round, "1"); // the max length of segments key bounds, in bytes -DEFINE_mInt32(segments_key_bounds_truncation_threshold, "100"); +DEFINE_mInt32(segments_key_bounds_truncation_threshold, "-1"); // clang-format off #ifdef BE_TEST diff --git a/be/src/olap/base_tablet.cpp b/be/src/olap/base_tablet.cpp index 5c33b5ea8e4abf..b4a54e427d68dd 100644 --- a/be/src/olap/base_tablet.cpp +++ b/be/src/olap/base_tablet.cpp @@ -450,10 +450,10 @@ bool BaseTablet::key_is_not_in_segment(Slice key, const KeyBoundsPB& segment_key bool is_segments_key_bounds_truncated) { Slice maybe_truncated_min_key {segment_key_bounds.min_key()}; Slice maybe_truncated_max_key {segment_key_bounds.max_key()}; - return Slice::origin_is_strictly_less_than(key, false, maybe_truncated_min_key, - is_segments_key_bounds_truncated) || - Slice::origin_is_strictly_less_than(maybe_truncated_max_key, - is_segments_key_bounds_truncated, key, false); + return Slice::lhs_is_strictly_less_than_rhs(key, false, maybe_truncated_min_key, + is_segments_key_bounds_truncated) || + Slice::lhs_is_strictly_less_than_rhs(maybe_truncated_max_key, + is_segments_key_bounds_truncated, key, false); } Status BaseTablet::lookup_row_key(const Slice& encoded_key, TabletSchema* latest_schema, diff --git a/be/src/olap/compaction.cpp b/be/src/olap/compaction.cpp index fbad3f05a5e88f..67a9cceb94977f 100644 --- a/be/src/olap/compaction.cpp +++ b/be/src/olap/compaction.cpp @@ -107,8 +107,8 @@ bool is_rowset_tidy(std::string& pre_max_key, bool& pre_rs_key_bounds_truncated, return false; } bool cur_rs_key_bounds_truncated {rhs->is_segments_key_bounds_truncated()}; - if (!Slice::origin_is_strictly_less_than(Slice {pre_max_key}, pre_rs_key_bounds_truncated, - Slice {min_key}, cur_rs_key_bounds_truncated)) { + if (!Slice::lhs_is_strictly_less_than_rhs(Slice {pre_max_key}, pre_rs_key_bounds_truncated, + Slice {min_key}, cur_rs_key_bounds_truncated)) { return false; } CHECK(rhs->last_key(&pre_max_key)); diff --git a/be/src/olap/rowset/rowset_meta.cpp b/be/src/olap/rowset/rowset_meta.cpp index 24960d1d2cd663..2cc4628575a03a 100644 --- a/be/src/olap/rowset/rowset_meta.cpp +++ b/be/src/olap/rowset/rowset_meta.cpp @@ -226,18 +226,17 @@ void RowsetMeta::set_segments_key_bounds(const std::vector& segment *new_key_bounds = key_bounds; } - bool enable_truncated {config::segments_key_bounds_truncation_threshold > 0}; + int32_t truncation_threshold = config::segments_key_bounds_truncation_threshold; bool really_do_truncation {false}; - if (enable_truncated) { - int32_t threshold = config::segments_key_bounds_truncation_threshold; + if (truncation_threshold > 0) { for (auto& segment_key_bounds : *_rowset_meta_pb.mutable_segments_key_bounds()) { - if (segment_key_bounds.min_key().size() > threshold) { + if (segment_key_bounds.min_key().size() > truncation_threshold) { really_do_truncation = true; - segment_key_bounds.mutable_min_key()->resize(threshold); + segment_key_bounds.mutable_min_key()->resize(truncation_threshold); } - if (segment_key_bounds.max_key().size() > threshold) { + if (segment_key_bounds.max_key().size() > truncation_threshold) { really_do_truncation = true; - segment_key_bounds.mutable_max_key()->resize(threshold); + segment_key_bounds.mutable_max_key()->resize(truncation_threshold); } } } diff --git a/be/src/util/slice.cpp b/be/src/util/slice.cpp index eb5f7ffeccd603..9c15f901f25270 100644 --- a/be/src/util/slice.cpp +++ b/be/src/util/slice.cpp @@ -27,8 +27,8 @@ Slice::Slice(const faststring& s) data((char*)(s.data())), size(s.size()) {} -bool Slice::origin_is_strictly_less_than(Slice X, bool X_is_truncated, Slice Y, - bool Y_is_truncated) { +bool Slice::lhs_is_strictly_less_than_rhs(Slice X, bool X_is_truncated, Slice Y, + [[maybe_unused]] bool Y_is_truncated) { // suppose X is a prefix of X', Y is a prefix of Y' if (!X_is_truncated) { // (X_is_truncated == false) means X' == X diff --git a/be/src/util/slice.h b/be/src/util/slice.h index 797add4d41e289..2bda5c3a0bc6c1 100644 --- a/be/src/util/slice.h +++ b/be/src/util/slice.h @@ -278,8 +278,8 @@ struct Slice { // Y is (maybe) a truncated prefix of string Y' // return true only if we can determine that X' is strictly less than Y' // based on these maybe truncated prefixes - static bool origin_is_strictly_less_than(Slice X, bool X_is_truncated, Slice Y, - bool Y_is_truncated); + static bool lhs_is_strictly_less_than_rhs(Slice X, bool X_is_truncated, Slice Y, + bool Y_is_truncated); }; inline std::ostream& operator<<(std::ostream& os, const Slice& slice) { diff --git a/be/src/vec/olap/block_reader.cpp b/be/src/vec/olap/block_reader.cpp index 58e09b912d5b82..5374a2c2d73ee5 100644 --- a/be/src/vec/olap/block_reader.cpp +++ b/be/src/vec/olap/block_reader.cpp @@ -90,9 +90,9 @@ bool BlockReader::_rowsets_not_mono_asc_disjoint(const ReaderParams& read_params } bool cur_rs_key_bounds_truncated { rs_split.rs_reader->rowset()->is_segments_key_bounds_truncated()}; - if (!Slice::origin_is_strictly_less_than(Slice {pre_rs_last_key}, - pre_rs_key_bounds_truncated, Slice {rs_first_key}, - cur_rs_key_bounds_truncated)) { + if (!Slice::lhs_is_strictly_less_than_rhs(Slice {pre_rs_last_key}, + pre_rs_key_bounds_truncated, Slice {rs_first_key}, + cur_rs_key_bounds_truncated)) { return true; } bool has_last_key = rs_split.rs_reader->rowset()->last_key(&pre_rs_last_key); diff --git a/be/test/olap/segments_key_bounds_truncation_test.cpp b/be/test/olap/segments_key_bounds_truncation_test.cpp index a9bc2c6483cdb5..8530d9d52ea87e 100644 --- a/be/test/olap/segments_key_bounds_truncation_test.cpp +++ b/be/test/olap/segments_key_bounds_truncation_test.cpp @@ -333,7 +333,7 @@ class SegmentsKeyBoundsTruncationTest : public testing::Test { }; TEST_F(SegmentsKeyBoundsTruncationTest, CompareFuncTest) { - // test `Slice::origin_is_strictly_less_than` + // test `Slice::lhs_is_strictly_less_than_rhs` // enumerating all possible combinations // this test is reduntant, n = 3 is enough constexpr int n = 8; @@ -363,8 +363,8 @@ TEST_F(SegmentsKeyBoundsTruncationTest, CompareFuncTest) { b.truncate(l2); } - bool res1 = Slice::origin_is_strictly_less_than(a, X_is_truncated, b, - Y_is_truncated); + bool res1 = Slice::lhs_is_strictly_less_than_rhs(a, X_is_truncated, b, + Y_is_truncated); bool res2 = (X.compare(Y) < 0); ++total; if (res1 && res2) {