github-actions[bot] commented on code in PR #41701:
URL: https://github.com/apache/doris/pull/41701#discussion_r1797686781
##########
be/src/olap/memtable.cpp:
##########
@@ -578,6 +539,208 @@
}
}
+template <bool is_final>
+void MemTable::_aggregate_for_flexible_partial_update_without_seq_col(
+ const vectorized::ColumnsWithTypeAndName& block_data,
+ vectorized::MutableBlock& mutable_block, std::vector<RowInBlock*>&
temp_row_in_blocks) {
+ RowInBlock* prev_row = nullptr;
+ int row_pos = -1;
+ auto& skip_bitmaps = assert_cast<vectorized::ColumnBitmap*>(
+
mutable_block.mutable_columns()[_skip_bitmap_col_idx].get())
+ ->get_data();
+ auto& delete_signs = assert_cast<vectorized::ColumnInt8*>(
+
mutable_block.mutable_columns()[_delete_sign_col_idx].get())
+ ->get_data();
+ RowInBlock* row_with_delete_sign {nullptr};
+ RowInBlock* row_without_delete_sign {nullptr};
+
+ auto finalize_rows = [&]() {
+ if (row_with_delete_sign != nullptr) {
+ temp_row_in_blocks.push_back(row_with_delete_sign);
+ _finalize_one_row<is_final, false>(row_with_delete_sign,
block_data, ++row_pos);
+ row_with_delete_sign = nullptr;
+ }
+ if (row_without_delete_sign != nullptr) {
+ temp_row_in_blocks.push_back(row_without_delete_sign);
+ _finalize_one_row<is_final, false>(row_without_delete_sign,
block_data, ++row_pos);
+ row_without_delete_sign = nullptr;
+ }
+ _arena->clear();
+ };
+
+ auto add_row = [&](RowInBlock* row, bool with_delete_sign) {
+ if (with_delete_sign) {
+ row_with_delete_sign = row;
+ } else {
+ row_without_delete_sign = row;
+ }
+ };
+ for (RowInBlock* cur_row : _row_in_blocks) {
+ const BitmapValue& skip_bitmap = skip_bitmaps[cur_row->_row_pos];
+ bool cur_row_has_delete_sign =
(!skip_bitmap.contains(_delete_sign_col_unique_id) &&
+ delete_signs[cur_row->_row_pos] != 0);
+ prev_row =
+ (row_with_delete_sign == nullptr) ? row_without_delete_sign :
row_with_delete_sign;
+ // compare keys, the keys of row_with_delete_sign and
row_without_delete_sign is the same,
+ // choose any of them if it's valid
+ if (prev_row != nullptr && (*_vec_row_comparator)(prev_row, cur_row)
== 0) {
+ if (cur_row_has_delete_sign) {
+ if (row_without_delete_sign != nullptr) {
+ // if there exits row without delete sign, remove it first
+ _clear_row_agg(row_without_delete_sign);
+ _stat.merged_rows++;
+ row_without_delete_sign = nullptr;
+ }
+ // and then unconditionally replace the previous row
+ prev_row = row_with_delete_sign;
+ } else {
+ prev_row = row_without_delete_sign;
+ }
+
+ if (prev_row == nullptr) {
+ add_row(cur_row, cur_row_has_delete_sign);
+ } else {
+ if (!prev_row->has_init_agg()) {
+ _init_row_for_agg(prev_row, mutable_block);
+ }
+ _stat.merged_rows++;
+ _aggregate_two_row_in_block<true>(mutable_block, cur_row,
prev_row);
+ }
+ } else {
+ finalize_rows();
+ add_row(cur_row, cur_row_has_delete_sign);
+ }
+ }
+ // finalize the last lows
+ finalize_rows();
+}
+
+template <bool is_final>
+void MemTable::_aggregate_for_flexible_partial_update_with_seq_col(
Review Comment:
warning: function '_aggregate_for_flexible_partial_update_with_seq_col'
exceeds recommended size/complexity thresholds [readability-function-size]
```cpp
void MemTable::_aggregate_for_flexible_partial_update_with_seq_col(
^
```
<details>
<summary>Additional context</summary>
**be/src/olap/memtable.cpp:618:** 121 lines including whitespace and
comments (threshold 80)
```cpp
void MemTable::_aggregate_for_flexible_partial_update_with_seq_col(
^
```
</details>
##########
be/src/olap/memtable.cpp:
##########
@@ -452,6 +456,28 @@ void MemTable::_finalize_one_row(RowInBlock* row,
}
}
+void MemTable::_init_row_for_agg(RowInBlock* row, vectorized::MutableBlock&
mutable_block) {
+
row->init_agg_places(_arena->aligned_alloc(_total_size_of_aggregate_states, 16),
+ _offsets_of_aggregate_states.data());
+ for (auto cid = _tablet_schema->num_key_columns(); cid < _num_columns;
cid++) {
+ auto* col_ptr = mutable_block.mutable_columns()[cid].get();
+ auto* data = row->agg_places(cid);
+ _agg_functions[cid]->create(data);
+ _agg_functions[cid]->add(data, const_cast<const
doris::vectorized::IColumn**>(&col_ptr),
+ row->_row_pos, _arena.get());
+ }
+}
+void MemTable::_clear_row_agg(RowInBlock* row) {
Review Comment:
warning: method '_clear_row_agg' can be made const
[readability-make-member-function-const]
be/src/olap/memtable.h:259:
```diff
- void _clear_row_agg(RowInBlock* row);
+ void _clear_row_agg(RowInBlock* row) const;
```
```suggestion
void MemTable::_clear_row_agg(RowInBlock* row) const {
```
--
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]