From 2d33fa3a1faef96c6a2c9eb666a402c2230c34a9 Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Thu, 26 Dec 2024 12:19:13 +0800 Subject: [PATCH] adjust --- be/src/olap/base_tablet.cpp | 11 +---------- be/src/olap/base_tablet.h | 2 -- be/src/util/key_util.h | 18 +++++++++++++----- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/be/src/olap/base_tablet.cpp b/be/src/olap/base_tablet.cpp index b4a54e427d68dd..391675d44f074e 100644 --- a/be/src/olap/base_tablet.cpp +++ b/be/src/olap/base_tablet.cpp @@ -44,6 +44,7 @@ #include "util/crc32c.h" #include "util/debug_points.h" #include "util/doris_metrics.h" +#include "util/key_util.h" #include "vec/common/assert_cast.h" #include "vec/common/schema_util.h" #include "vec/data_types/data_type_factory.hpp" @@ -446,16 +447,6 @@ Status BaseTablet::lookup_row_data(const Slice& encoded_key, const RowLocation& return Status::OK(); } -bool BaseTablet::key_is_not_in_segment(Slice key, const KeyBoundsPB& segment_key_bounds, - 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::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, bool with_seq_col, const std::vector& specified_rowsets, diff --git a/be/src/olap/base_tablet.h b/be/src/olap/base_tablet.h index 9b61799eef9d4a..d3f1f8a480d73e 100644 --- a/be/src/olap/base_tablet.h +++ b/be/src/olap/base_tablet.h @@ -146,8 +146,6 @@ class BaseTablet { RowsetSharedPtr rowset, const TupleDescriptor* desc, OlapReaderStatistics& stats, std::string& values, bool write_to_cache = false); - bool key_is_not_in_segment(Slice key, const KeyBoundsPB& segment_key_bounds, - bool is_segments_key_bounds_truncated); // Lookup the row location of `encoded_key`, the function sets `row_location` on success. // NOTE: the method only works in unique key model with primary key index, you will got a // not supported error in other data model. diff --git a/be/src/util/key_util.h b/be/src/util/key_util.h index fd57566fa4f8b2..e0bf04007bd183 100644 --- a/be/src/util/key_util.h +++ b/be/src/util/key_util.h @@ -17,16 +17,12 @@ #pragma once +#include #include #include -#include #include -#include -#include "common/status.h" -#include "util/debug_util.h" -#include "util/faststring.h" #include "util/slice.h" namespace doris { @@ -111,4 +107,16 @@ void encode_key(std::string* buf, const RowType& row, size_t num_keys) { } } +// we can only know if a key is excluded from the segment +// based on strictly order compare result with segments key bounds +bool key_is_not_in_segment(Slice key, const KeyBoundsPB& segment_key_bounds, + 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::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); +} + } // namespace doris