HappenLee commented on code in PR #10187:
URL: https://github.com/apache/doris/pull/10187#discussion_r905860563
##########
be/src/olap/schema_change.cpp:
##########
@@ -91,6 +92,147 @@ class RowBlockMerger {
std::priority_queue<MergeElement> _heap;
};
+class MultiBlockMerger {
+public:
+ MultiBlockMerger(TabletSharedPtr tablet) : _tablet(tablet), _cmp(tablet) {}
+
+ Status merge(const std::vector<std::unique_ptr<vectorized::Block>>& blocks,
+ RowsetWriter* rowset_writer, uint64_t* merged_rows) {
+ std::vector<RowRef> row_refs;
+ for (auto& block : blocks) {
+ for (uint16_t i = 0; i < block->rows(); i++) {
+ row_refs.emplace_back(block.get(), i);
+ }
+ }
+ // The block version is incremental.
+ std::stable_sort(row_refs.begin(), row_refs.end(), _cmp);
+
+ if (!row_refs.size()) {
+ return Status::OK();
+ }
+
+ auto finalized_block = _tablet->tablet_schema().create_block();
+ int rows = row_refs.size();
+ int columns = finalized_block.columns();
+ *merged_rows += rows;
+
+ std::vector<RowRef> pushed_row_refs;
+ if (_tablet->keys_type() == KeysType::DUP_KEYS) {
+ std::swap(pushed_row_refs, row_refs);
+ } else if (_tablet->keys_type() == KeysType::UNIQUE_KEYS) {
+ for (int i = 0; i < rows; i++) {
+ if (i == rows - 1 || _cmp.compare(row_refs[i], row_refs[i +
1])) {
+ pushed_row_refs.push_back(row_refs[i]);
+ }
+ }
+ } else {
Review Comment:
the logic is confusing, should change
--
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]