Skip to content

Commit

Permalink
adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
bobhan1 committed Dec 26, 2024
1 parent 904e46d commit 2d33fa3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
11 changes: 1 addition & 10 deletions be/src/olap/base_tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<RowsetSharedPtr>& specified_rowsets,
Expand Down
2 changes: 0 additions & 2 deletions be/src/olap/base_tablet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 13 additions & 5 deletions be/src/util/key_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@

#pragma once

#include <gen_cpp/olap_file.pb.h>
#include <gen_cpp/segment_v2.pb.h>

#include <cstdint>
#include <iterator>
#include <string>
#include <vector>

#include "common/status.h"
#include "util/debug_util.h"
#include "util/faststring.h"
#include "util/slice.h"

namespace doris {
Expand Down Expand Up @@ -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

0 comments on commit 2d33fa3

Please sign in to comment.