Skip to content

Commit

Permalink
rename some ambiguous vars and function names
Browse files Browse the repository at this point in the history
  • Loading branch information
TangSiyang2001 committed Oct 17, 2024
1 parent 9a654da commit 4bba4bb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions be/src/olap/compaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ bool is_rowset_tidy(std::string& pre_max_key, const RowsetSharedPtr& rhs) {
}
}
std::string min_key;
auto ret = rhs->min_key(&min_key);
auto ret = rhs->first_key(&min_key);
if (!ret) {
return false;
}
if (min_key <= pre_max_key) {
return false;
}
CHECK(rhs->max_key(&pre_max_key));
CHECK(rhs->last_key(&pre_max_key));

return true;
}
Expand Down
8 changes: 6 additions & 2 deletions be/src/olap/rowset/rowset.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ class Rowset : public std::enable_shared_from_this<Rowset> {
_rowset_meta->get_segments_key_bounds(segments_key_bounds);
return Status::OK();
}
bool min_key(std::string* min_key) {

// min key of the first segment
bool first_key(std::string* min_key) {
KeyBoundsPB key_bounds;
bool ret = _rowset_meta->get_first_segment_key_bound(&key_bounds);
if (!ret) {
Expand All @@ -278,7 +280,9 @@ class Rowset : public std::enable_shared_from_this<Rowset> {
*min_key = key_bounds.min_key();
return true;
}
bool max_key(std::string* max_key) {

// max key of the last segment
bool last_key(std::string* max_key) {
KeyBoundsPB key_bounds;
bool ret = _rowset_meta->get_last_segment_key_bound(&key_bounds);
if (!ret) {
Expand Down
18 changes: 10 additions & 8 deletions be/src/vec/olap/block_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ Status BlockReader::next_block_with_aggregation(Block* block, bool* eof) {
return res;
}

bool BlockReader::_rowsets_overlapping(const ReaderParams& read_params) {
std::string cur_max_key;
bool BlockReader::_rowsets_mono_asc_disjoint(const ReaderParams& read_params) {
std::string cur_rs_last_key;
const std::vector<RowSetSplits>& rs_splits = read_params.rs_splits;
for (const auto& rs_split : rs_splits) {
if (rs_split.rs_reader->rowset()->num_rows() == 0) {
Expand All @@ -81,19 +81,21 @@ bool BlockReader::_rowsets_overlapping(const ReaderParams& read_params) {
if (rs_split.rs_reader->rowset()->is_segments_overlapping()) {
return true;
}
std::string min_key;
bool has_min_key = rs_split.rs_reader->rowset()->min_key(&min_key);
if (!has_min_key) {
std::string rs_first_key;
bool has_first_key = rs_split.rs_reader->rowset()->first_key(&rs_first_key);
if (!has_first_key) {
return true;
}
if (min_key <= cur_max_key) {
if (rs_first_key <= cur_rs_last_key) {
return true;
}
CHECK(rs_split.rs_reader->rowset()->max_key(&cur_max_key));
bool has_last_key = rs_split.rs_reader->rowset()->last_key(&cur_rs_last_key);
CHECK(has_last_key);
}

return false;
}

Status BlockReader::_init_collect_iter(const ReaderParams& read_params) {
auto res = _capture_rs_readers(read_params);
if (!res.ok()) {
Expand All @@ -105,7 +107,7 @@ Status BlockReader::_init_collect_iter(const ReaderParams& read_params) {
return res;
}
// check if rowsets are noneoverlapping
_is_rowsets_overlapping = _rowsets_overlapping(read_params);
_is_rowsets_overlapping = _rowsets_mono_asc_disjoint(read_params);
_vcollect_iter.init(this, _is_rowsets_overlapping, read_params.read_orderby_key,
read_params.read_orderby_key_reverse);

Expand Down
3 changes: 2 additions & 1 deletion be/src/vec/olap/block_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class BlockReader final : public TabletReader {

bool _get_next_row_same();

bool _rowsets_overlapping(const ReaderParams& read_params);
// return true if keys of rowsets are mono ascending and disjoint
bool _rowsets_mono_asc_disjoint(const ReaderParams& read_params);

VCollectIterator _vcollect_iter;
IteratorRowRef _next_row {{}, -1, false};
Expand Down

0 comments on commit 4bba4bb

Please sign in to comment.