github-actions[bot] commented on code in PR #38216:
URL: https://github.com/apache/doris/pull/38216#discussion_r1686427798
##########
be/src/olap/base_tablet.cpp:
##########
@@ -925,42 +920,197 @@ Status BaseTablet::fetch_value_by_rowids(RowsetSharedPtr
input_rowset, uint32_t
return Status::OK();
}
+Status BaseTablet::read_columns_by_plan(TabletSchemaSPtr tablet_schema,
+ const std::map<RowsetId,
RowsetSharedPtr>& rsid_to_rowset,
+ const PartialUpdateReadPlan& read_plan,
+ const std::vector<uint32_t>*
cids_full_read,
+ vectorized::Block* block_full_read,
+ std::map<uint32_t, uint32_t>*
full_read_index) {
+ auto full_read_columns = block_full_read->mutate_columns();
+ uint32_t read_idx1 = 0;
+ return std::visit(
+ vectorized::Overload {
+ [&](const RowStoreReadPlan& row_store_read_plan) -> Status
{
+ for (const auto& [rowset_id, segment_read_infos] :
row_store_read_plan) {
+ auto rowset = rsid_to_rowset.at(rowset_id);
+ CHECK(rowset);
+ for (const auto& [segment_id, rows_info] :
segment_read_infos) {
+ std::vector<uint32_t> rids;
+ for (const auto& [id_and_pos, cids] :
rows_info) {
+ // set read index for missing columns
+ rids.emplace_back(id_and_pos.rid);
+ (*full_read_index)[id_and_pos.pos] =
read_idx1++;
+ }
+
+ auto st = fetch_value_through_row_column(
+ rowset, *tablet_schema, segment_id,
rids, rows_info,
+ cids_full_read, nullptr,
block_full_read, nullptr, false);
+ if (!st.ok()) {
+ LOG(WARNING) << "failed to fetch value
through row column";
+ return st;
+ }
+ }
+ }
+ return Status::OK();
+ },
+ [&](const ColumnStoreReadPlan& column_store_read_plan) ->
Status {
+ for (const auto& [rowset_id, segment_read_infos] :
column_store_read_plan) {
+ auto rowset = rsid_to_rowset.at(rowset_id);
+ CHECK(rowset);
+
+ for (const auto& [segment_id, columns_info] :
segment_read_infos) {
+ std::vector<uint32_t> rids;
+ for (auto [rid, pos] :
columns_info.missing_column_rows) {
+ rids.emplace_back(rid);
+ // set read index for missing columns
+ (*full_read_index)[pos] = read_idx1++;
+ }
+
+ // read values for missing columns
+ for (size_t i = 0; i < cids_full_read->size();
++i) {
+ TabletColumn tablet_column =
+
tablet_schema->column(cids_full_read->at(i));
+ auto st = fetch_value_by_rowids(rowset,
segment_id, rids,
+
tablet_column,
+
full_read_columns[i]);
+ if (!st.ok()) {
+ LOG(WARNING) << "failed to fetch value
by rowids";
+ return st;
+ }
+ }
+ }
+ }
+ return Status::OK();
+ }},
+ read_plan);
+}
+
+Status BaseTablet::read_columns_by_plan(
Review Comment:
warning: function 'read_columns_by_plan' exceeds recommended size/complexity
thresholds [readability-function-size]
```cpp
Status BaseTablet::read_columns_by_plan(
^
```
<details>
<summary>Additional context</summary>
**be/src/olap/base_tablet.cpp:987:** 92 lines including whitespace and
comments (threshold 80)
```cpp
Status BaseTablet::read_columns_by_plan(
^
```
</details>
##########
be/src/olap/base_tablet.cpp:
##########
@@ -925,42 +920,197 @@
return Status::OK();
}
+Status BaseTablet::read_columns_by_plan(TabletSchemaSPtr tablet_schema,
+ const std::map<RowsetId,
RowsetSharedPtr>& rsid_to_rowset,
+ const PartialUpdateReadPlan& read_plan,
+ const std::vector<uint32_t>*
cids_full_read,
+ vectorized::Block* block_full_read,
+ std::map<uint32_t, uint32_t>*
full_read_index) {
+ auto full_read_columns = block_full_read->mutate_columns();
+ uint32_t read_idx1 = 0;
+ return std::visit(
+ vectorized::Overload {
+ [&](const RowStoreReadPlan& row_store_read_plan) -> Status
{
+ for (const auto& [rowset_id, segment_read_infos] :
row_store_read_plan) {
+ auto rowset = rsid_to_rowset.at(rowset_id);
+ CHECK(rowset);
+ for (const auto& [segment_id, rows_info] :
segment_read_infos) {
+ std::vector<uint32_t> rids;
+ for (const auto& [id_and_pos, cids] :
rows_info) {
+ // set read index for missing columns
+ rids.emplace_back(id_and_pos.rid);
+ (*full_read_index)[id_and_pos.pos] =
read_idx1++;
+ }
+
+ auto st = fetch_value_through_row_column(
+ rowset, *tablet_schema, segment_id,
rids, rows_info,
+ cids_full_read, nullptr,
block_full_read, nullptr, false);
+ if (!st.ok()) {
+ LOG(WARNING) << "failed to fetch value
through row column";
+ return st;
+ }
+ }
+ }
+ return Status::OK();
+ },
+ [&](const ColumnStoreReadPlan& column_store_read_plan) ->
Status {
+ for (const auto& [rowset_id, segment_read_infos] :
column_store_read_plan) {
+ auto rowset = rsid_to_rowset.at(rowset_id);
+ CHECK(rowset);
+
+ for (const auto& [segment_id, columns_info] :
segment_read_infos) {
+ std::vector<uint32_t> rids;
+ for (auto [rid, pos] :
columns_info.missing_column_rows) {
+ rids.emplace_back(rid);
+ // set read index for missing columns
+ (*full_read_index)[pos] = read_idx1++;
+ }
+
+ // read values for missing columns
+ for (size_t i = 0; i < cids_full_read->size();
++i) {
+ TabletColumn tablet_column =
+
tablet_schema->column(cids_full_read->at(i));
+ auto st = fetch_value_by_rowids(rowset,
segment_id, rids,
+
tablet_column,
+
full_read_columns[i]);
+ if (!st.ok()) {
+ LOG(WARNING) << "failed to fetch value
by rowids";
+ return st;
+ }
+ }
+ }
+ }
+ return Status::OK();
+ }},
+ read_plan);
+}
+
+Status BaseTablet::read_columns_by_plan(
+ TabletSchemaSPtr tablet_schema, const std::map<RowsetId,
RowsetSharedPtr>& rsid_to_rowset,
+ const PartialUpdateReadPlan& read_plan, const std::vector<uint32_t>*
cids_full_read,
+ const std::vector<uint32_t>* cids_point_read, vectorized::Block*
block_full_read,
+ vectorized::Block* block_point_read, std::map<uint32_t, uint32_t>*
full_read_index,
+ std::map<uint32_t, std::map<uint32_t, uint32_t>>* point_read_index) {
+ auto full_read_columns = block_full_read->mutate_columns();
+ auto point_read_columns = block_point_read->mutate_columns();
+
+ uint32_t read_idx1 = 0;
+ std::map<uint32_t, uint32_t> read_idx2;
+ for (uint32_t cid : *cids_point_read) {
+ read_idx2[cid] = 0;
+ }
+
+ return std::visit(
+ vectorized::Overload {
+ [&](const RowStoreReadPlan& row_store_read_plan) -> Status
{
+ for (const auto& [rowset_id, segment_read_infos] :
row_store_read_plan) {
+ auto rowset = rsid_to_rowset.at(rowset_id);
+ CHECK(rowset);
+ for (const auto& [segment_id, rows_info] :
segment_read_infos) {
+ std::vector<uint32_t> rids;
+ for (const auto& [id_and_pos, cids] :
rows_info) {
+ // set read index for missing columns
+ rids.emplace_back(id_and_pos.rid);
+ (*full_read_index)[id_and_pos.pos] =
read_idx1++;
+ for (const auto cid : cids) {
+ // set read index for partial update
columns
+
(*point_read_index)[cid][id_and_pos.pos] = read_idx2[cid]++;
+ }
+ }
+
+ auto st = fetch_value_through_row_column(
+ rowset, *tablet_schema, segment_id,
rids, rows_info,
+ cids_full_read, cids_point_read,
block_full_read,
+ block_point_read, true);
+ if (!st.ok()) {
+ LOG(WARNING) << "failed to fetch value
through row column";
+ return st;
+ }
+ }
+ }
+ return Status::OK();
+ },
+ [&](const ColumnStoreReadPlan& column_store_read_plan) ->
Status {
+ for (const auto& [rowset_id, segment_read_infos] :
column_store_read_plan) {
+ auto rowset = rsid_to_rowset.at(rowset_id);
+ CHECK(rowset);
+
+ for (const auto& [segment_id, columns_info] :
segment_read_infos) {
+ std::vector<uint32_t> rids;
+ for (auto [rid, pos] :
columns_info.missing_column_rows) {
+ rids.emplace_back(rid);
+ // set read index for missing columns
+ (*full_read_index)[pos] = read_idx1++;
+ }
+
+ // read values for missing columns
+ for (size_t i = 0; i < cids_full_read->size();
++i) {
+ TabletColumn tablet_column =
+
tablet_schema->column(cids_full_read->at(i));
+ auto st = fetch_value_by_rowids(rowset,
segment_id, rids,
+
tablet_column,
+
full_read_columns[i]);
+ if (!st.ok()) {
+ LOG(WARNING) << "failed to fetch value
by rowids";
+ return st;
+ }
+ }
+ // read values for cells with indicator values
in including columns
+ for (size_t i = 0; i <
cids_point_read->size(); i++) {
+ const auto& rows_info =
columns_info.partial_update_rows;
+ uint32_t cid = cids_point_read->at(i);
+ if (!rows_info.empty() &&
rows_info.contains(cid)) {
+ std::vector<uint32_t> rids;
+ for (auto [rid, pos] :
rows_info.at(cid)) {
+ rids.emplace_back(rid);
+ // set read index for partial
update columns
+ (*point_read_index)[cid][pos] =
read_idx2[cid]++;
+ }
+
+ TabletColumn tablet_column =
tablet_schema->column(cid);
+ auto st =
fetch_value_by_rowids(rowset, segment_id, rids,
+
tablet_column,
+
point_read_columns[i]);
+ if (!st.ok()) {
+ LOG(WARNING) << "failed to fetch
value by rowids";
+ return st;
+ }
+ }
+ }
+ }
+ }
+ return Status::OK();
+ }},
+ read_plan);
+}
+
Status BaseTablet::generate_new_block_for_partial_update(
Review Comment:
warning: function 'generate_new_block_for_partial_update' has cognitive
complexity of 95 (threshold 50) [readability-function-cognitive-complexity]
```cpp
Status BaseTablet::generate_new_block_for_partial_update(
^
```
<details>
<summary>Additional context</summary>
**be/src/olap/base_tablet.cpp:1103:** +1, including nesting penalty of 0,
nesting level increased to 1
```cpp
if (const vectorized::ColumnWithTypeAndName* delete_sign_column =
^
```
**be/src/olap/base_tablet.cpp:1114:** +1, including nesting penalty of 0,
nesting level increased to 1
```cpp
if (delete_sign_column_data != nullptr) {
^
```
**be/src/olap/base_tablet.cpp:1115:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
for (auto i = 0; i < missing_cids.size(); ++i) {
^
```
**be/src/olap/base_tablet.cpp:1117:** +3, including nesting penalty of 2,
nesting level increased to 3
```cpp
if (column.has_default_value()) {
^
```
**be/src/olap/base_tablet.cpp:1121:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
RETURN_IF_ERROR(old_full_read_block.get_by_position(i).type->from_string(
^
```
**be/src/common/status.h:618:** expanded from macro 'RETURN_IF_ERROR'
```cpp
do { \
^
```
**be/src/olap/base_tablet.cpp:1121:** +5, including nesting penalty of 4,
nesting level increased to 5
```cpp
RETURN_IF_ERROR(old_full_read_block.get_by_position(i).type->from_string(
^
```
**be/src/common/status.h:620:** expanded from macro 'RETURN_IF_ERROR'
```cpp
if (UNLIKELY(!_status_.ok())) { \
^
```
**be/src/olap/base_tablet.cpp:1127:** +1, including nesting penalty of 0,
nesting level increased to 1
```cpp
if (!indicator_maps) {
^
```
**be/src/olap/base_tablet.cpp:1132:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
RETURN_IF_ERROR(read_columns_by_plan(rowset_schema, rsid_to_rowset,
read_plan_ori,
^
```
**be/src/common/status.h:618:** expanded from macro 'RETURN_IF_ERROR'
```cpp
do { \
^
```
**be/src/olap/base_tablet.cpp:1132:** +3, including nesting penalty of 2,
nesting level increased to 3
```cpp
RETURN_IF_ERROR(read_columns_by_plan(rowset_schema, rsid_to_rowset,
read_plan_ori,
^
```
**be/src/common/status.h:620:** expanded from macro 'RETURN_IF_ERROR'
```cpp
if (UNLIKELY(!_status_.ok())) { \
^
```
**be/src/olap/base_tablet.cpp:1136:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
RETURN_IF_ERROR(read_columns_by_plan(rowset_schema, rsid_to_rowset,
read_plan_update,
^
```
**be/src/common/status.h:618:** expanded from macro 'RETURN_IF_ERROR'
```cpp
do { \
^
```
**be/src/olap/base_tablet.cpp:1136:** +3, including nesting penalty of 2,
nesting level increased to 3
```cpp
RETURN_IF_ERROR(read_columns_by_plan(rowset_schema, rsid_to_rowset,
read_plan_update,
^
```
**be/src/common/status.h:620:** expanded from macro 'RETURN_IF_ERROR'
```cpp
if (UNLIKELY(!_status_.ok())) { \
^
```
**be/src/olap/base_tablet.cpp:1142:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
for (auto i = 0; i < missing_cids.size(); ++i) {
^
```
**be/src/olap/base_tablet.cpp:1144:** +3, including nesting penalty of 2,
nesting level increased to 3
```cpp
for (auto idx = 0; idx < read_index_old.size(); ++idx) {
^
```
**be/src/olap/base_tablet.cpp:1153:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
if (delete_sign_column_data != nullptr &&
^
```
**be/src/olap/base_tablet.cpp:1153:** +1
```cpp
if (delete_sign_column_data != nullptr &&
^
```
**be/src/olap/base_tablet.cpp:1155:** +5, including nesting penalty of 4,
nesting level increased to 5
```cpp
if (rs_column.has_default_value()) {
^
```
**be/src/olap/base_tablet.cpp:1157:** +1, nesting level increased to 5
```cpp
} else if (rs_column.is_nullable()) {
^
```
**be/src/olap/base_tablet.cpp:1160:** +1, nesting level increased to 5
```cpp
} else {
^
```
**be/src/olap/base_tablet.cpp:1170:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
for (auto i = 0; i < update_cids.size(); ++i) {
^
```
**be/src/olap/base_tablet.cpp:1171:** +3, including nesting penalty of 2,
nesting level increased to 3
```cpp
for (auto idx = 0; idx < read_index_update.size(); ++idx) {
^
```
**be/src/olap/base_tablet.cpp:1179:** +1, nesting level increased to 1
```cpp
} else {
^
```
**be/src/olap/base_tablet.cpp:1197:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
RETURN_IF_ERROR(read_columns_by_plan(rowset_schema, rsid_to_rowset,
read_plan_ori,
^
```
**be/src/common/status.h:618:** expanded from macro 'RETURN_IF_ERROR'
```cpp
do { \
^
```
**be/src/olap/base_tablet.cpp:1197:** +3, including nesting penalty of 2,
nesting level increased to 3
```cpp
RETURN_IF_ERROR(read_columns_by_plan(rowset_schema, rsid_to_rowset,
read_plan_ori,
^
```
**be/src/common/status.h:620:** expanded from macro 'RETURN_IF_ERROR'
```cpp
if (UNLIKELY(!_status_.ok())) { \
^
```
**be/src/olap/base_tablet.cpp:1204:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
RETURN_IF_ERROR(read_columns_by_plan(rowset_schema, rsid_to_rowset,
read_plan_update,
^
```
**be/src/common/status.h:618:** expanded from macro 'RETURN_IF_ERROR'
```cpp
do { \
^
```
**be/src/olap/base_tablet.cpp:1204:** +3, including nesting penalty of 2,
nesting level increased to 3
```cpp
RETURN_IF_ERROR(read_columns_by_plan(rowset_schema, rsid_to_rowset,
read_plan_update,
^
```
**be/src/common/status.h:620:** expanded from macro 'RETURN_IF_ERROR'
```cpp
if (UNLIKELY(!_status_.ok())) { \
^
```
**be/src/olap/base_tablet.cpp:1209:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
for (size_t i = 0; i < missing_cids.size(); ++i) {
^
```
**be/src/olap/base_tablet.cpp:1210:** +3, including nesting penalty of 2,
nesting level increased to 3
```cpp
for (auto idx = 0; idx < full_read_index_old.size(); ++idx) {
^
```
**be/src/olap/base_tablet.cpp:1219:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
if (delete_sign_column_data != nullptr &&
^
```
**be/src/olap/base_tablet.cpp:1221:** +5, including nesting penalty of 4,
nesting level increased to 5
```cpp
if (rs_column.has_default_value()) {
^
```
**be/src/olap/base_tablet.cpp:1223:** +1, nesting level increased to 5
```cpp
} else if (rs_column.is_nullable()) {
^
```
**be/src/olap/base_tablet.cpp:1226:** +1, nesting level increased to 5
```cpp
} else {
^
```
**be/src/olap/base_tablet.cpp:1237:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
for (size_t i = 0; i < update_cids.size(); i++) {
^
```
**be/src/olap/base_tablet.cpp:1239:** +3, including nesting penalty of 2,
nesting level increased to 3
```cpp
if (!cids_point_read.contains(cid)) {
^
```
**be/src/olap/base_tablet.cpp:1240:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
for (auto idx = 0; idx < full_read_index_old.size(); ++idx) {
^
```
**be/src/olap/base_tablet.cpp:1247:** +2, including nesting penalty of 1,
nesting level increased to 2
```cpp
for (size_t i = 0; i < point_read_cids.size(); i++) {
^
```
**be/src/olap/base_tablet.cpp:1249:** +3, including nesting penalty of 2,
nesting level increased to 3
```cpp
for (uint32_t idx = 0; i < full_read_index_old.size(); i++) {
^
```
**be/src/olap/base_tablet.cpp:1250:** +4, including nesting penalty of 3,
nesting level increased to 4
```cpp
if (point_read_index_old[cid].contains(idx)) {
^
```
**be/src/olap/base_tablet.cpp:1254:** +1, nesting level increased to 4
```cpp
} else {
^
```
</details>
--
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]