dataroaring commented on code in PR #45287:
URL: https://github.com/apache/doris/pull/45287#discussion_r1895743928
##########
be/src/olap/rowset/rowset_meta.cpp:
##########
@@ -220,6 +220,30 @@ int64_t RowsetMeta::segment_file_size(int seg_id) {
: -1;
}
+void RowsetMeta::set_segments_key_bounds(const std::vector<KeyBoundsPB>&
segments_key_bounds) {
+ for (const KeyBoundsPB& key_bounds : segments_key_bounds) {
+ KeyBoundsPB* new_key_bounds =
_rowset_meta_pb.add_segments_key_bounds();
+ *new_key_bounds = key_bounds;
+ }
+
+ bool enable_truncated {config::segments_key_bounds_truncation_threshold >
0};
Review Comment:
```suggestion
int32_t truncation_threshold =
config::segments_key_bounds_truncation_threshold > 0;
```
##########
be/src/olap/rowset/rowset_meta.cpp:
##########
@@ -220,6 +220,30 @@ int64_t RowsetMeta::segment_file_size(int seg_id) {
: -1;
}
+void RowsetMeta::set_segments_key_bounds(const std::vector<KeyBoundsPB>&
segments_key_bounds) {
+ for (const KeyBoundsPB& key_bounds : segments_key_bounds) {
+ KeyBoundsPB* new_key_bounds =
_rowset_meta_pb.add_segments_key_bounds();
+ *new_key_bounds = key_bounds;
+ }
+
+ bool enable_truncated {config::segments_key_bounds_truncation_threshold >
0};
+ bool really_do_truncation {false};
+ if (enable_truncated) {
+ int32_t threshold = config::segments_key_bounds_truncation_threshold;
+ for (auto& segment_key_bounds :
*_rowset_meta_pb.mutable_segments_key_bounds()) {
+ if (segment_key_bounds.min_key().size() > threshold) {
+ really_do_truncation = true;
+ segment_key_bounds.mutable_min_key()->resize(threshold);
Review Comment:
```suggestion
segment_key_bounds.mutable_min_key()->resize(truncation_threshold);
```
##########
be/src/olap/rowset/rowset_meta.cpp:
##########
@@ -220,6 +220,30 @@ int64_t RowsetMeta::segment_file_size(int seg_id) {
: -1;
}
+void RowsetMeta::set_segments_key_bounds(const std::vector<KeyBoundsPB>&
segments_key_bounds) {
+ for (const KeyBoundsPB& key_bounds : segments_key_bounds) {
+ KeyBoundsPB* new_key_bounds =
_rowset_meta_pb.add_segments_key_bounds();
+ *new_key_bounds = key_bounds;
+ }
+
+ bool enable_truncated {config::segments_key_bounds_truncation_threshold >
0};
+ bool really_do_truncation {false};
+ if (enable_truncated) {
+ int32_t threshold = config::segments_key_bounds_truncation_threshold;
+ for (auto& segment_key_bounds :
*_rowset_meta_pb.mutable_segments_key_bounds()) {
+ if (segment_key_bounds.min_key().size() > threshold) {
+ really_do_truncation = true;
+ segment_key_bounds.mutable_min_key()->resize(threshold);
+ }
+ if (segment_key_bounds.max_key().size() > threshold) {
Review Comment:
```suggestion
if (segment_key_bounds.max_key().size() > truncation_threshold) {
```
##########
be/src/olap/compaction.cpp:
##########
@@ -105,11 +106,13 @@ bool is_rowset_tidy(std::string& pre_max_key, const
RowsetSharedPtr& rhs) {
if (!ret) {
return false;
}
- if (min_key <= pre_max_key) {
+ 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,
Review Comment:
```suggestion
if (!Slice::lhs_is_strictly_less_than_rhs(Slice {pre_max_key},
pre_rs_key_bounds_truncated,
```
##########
be/src/olap/rowset/rowset_meta.cpp:
##########
@@ -220,6 +220,30 @@ int64_t RowsetMeta::segment_file_size(int seg_id) {
: -1;
}
+void RowsetMeta::set_segments_key_bounds(const std::vector<KeyBoundsPB>&
segments_key_bounds) {
+ for (const KeyBoundsPB& key_bounds : segments_key_bounds) {
+ KeyBoundsPB* new_key_bounds =
_rowset_meta_pb.add_segments_key_bounds();
+ *new_key_bounds = key_bounds;
+ }
+
+ bool enable_truncated {config::segments_key_bounds_truncation_threshold >
0};
+ bool really_do_truncation {false};
+ if (enable_truncated) {
+ int32_t threshold = config::segments_key_bounds_truncation_threshold;
Review Comment:
```suggestion
```
##########
be/src/olap/rowset/rowset_meta.cpp:
##########
@@ -220,6 +220,30 @@ int64_t RowsetMeta::segment_file_size(int seg_id) {
: -1;
}
+void RowsetMeta::set_segments_key_bounds(const std::vector<KeyBoundsPB>&
segments_key_bounds) {
+ for (const KeyBoundsPB& key_bounds : segments_key_bounds) {
+ KeyBoundsPB* new_key_bounds =
_rowset_meta_pb.add_segments_key_bounds();
+ *new_key_bounds = key_bounds;
+ }
+
+ bool enable_truncated {config::segments_key_bounds_truncation_threshold >
0};
+ bool really_do_truncation {false};
+ if (enable_truncated) {
+ int32_t threshold = config::segments_key_bounds_truncation_threshold;
+ for (auto& segment_key_bounds :
*_rowset_meta_pb.mutable_segments_key_bounds()) {
+ if (segment_key_bounds.min_key().size() > threshold) {
Review Comment:
```suggestion
if (segment_key_bounds.min_key().size() > truncation_threshold) {
```
##########
be/src/olap/rowset/rowset_meta.cpp:
##########
@@ -220,6 +220,30 @@ int64_t RowsetMeta::segment_file_size(int seg_id) {
: -1;
}
+void RowsetMeta::set_segments_key_bounds(const std::vector<KeyBoundsPB>&
segments_key_bounds) {
+ for (const KeyBoundsPB& key_bounds : segments_key_bounds) {
+ KeyBoundsPB* new_key_bounds =
_rowset_meta_pb.add_segments_key_bounds();
+ *new_key_bounds = key_bounds;
+ }
+
+ bool enable_truncated {config::segments_key_bounds_truncation_threshold >
0};
+ bool really_do_truncation {false};
+ if (enable_truncated) {
Review Comment:
```suggestion
if (truncation_threshold > 0) {
```
##########
be/src/util/slice.cpp:
##########
@@ -27,4 +27,23 @@ 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,
Review Comment:
add ut for the function.
##########
be/src/olap/rowset/rowset_meta.cpp:
##########
@@ -220,6 +220,30 @@ int64_t RowsetMeta::segment_file_size(int seg_id) {
: -1;
}
+void RowsetMeta::set_segments_key_bounds(const std::vector<KeyBoundsPB>&
segments_key_bounds) {
+ for (const KeyBoundsPB& key_bounds : segments_key_bounds) {
+ KeyBoundsPB* new_key_bounds =
_rowset_meta_pb.add_segments_key_bounds();
+ *new_key_bounds = key_bounds;
+ }
+
+ bool enable_truncated {config::segments_key_bounds_truncation_threshold >
0};
+ bool really_do_truncation {false};
+ if (enable_truncated) {
+ int32_t threshold = config::segments_key_bounds_truncation_threshold;
+ for (auto& segment_key_bounds :
*_rowset_meta_pb.mutable_segments_key_bounds()) {
+ if (segment_key_bounds.min_key().size() > threshold) {
+ really_do_truncation = true;
+ segment_key_bounds.mutable_min_key()->resize(threshold);
+ }
+ if (segment_key_bounds.max_key().size() > threshold) {
+ really_do_truncation = true;
+ segment_key_bounds.mutable_max_key()->resize(threshold);
Review Comment:
```suggestion
segment_key_bounds.mutable_max_key()->resize(truncation_threshold);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]