-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[featrue](expr) support common subexpression elimination be part #32673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -220,6 +220,26 @@ class ExecNode { | |||||
| return _output_row_descriptor ? *_output_row_descriptor : _row_descriptor; | ||||||
| } | ||||||
| virtual const RowDescriptor& intermediate_row_desc() const { return _row_descriptor; } | ||||||
|
|
||||||
| // input expr -> intermediate_projections[0] -> intermediate_projections[1] -> intermediate_projections[2] ... -> final projections -> output expr | ||||||
| // prepare _row_descriptor intermediate_row_desc[0] intermediate_row_desc[1] intermediate_row_desc.end() _output_row_descriptor | ||||||
|
|
||||||
| [[nodiscard]] const RowDescriptor& intermediate_row_desc(int idx) { | ||||||
| if (idx == 0) { | ||||||
| return intermediate_row_desc(); | ||||||
| } | ||||||
| DCHECK((idx - 1) < _intermediate_output_row_descriptor.size()); | ||||||
| return _intermediate_output_row_descriptor[idx - 1]; | ||||||
| } | ||||||
|
|
||||||
| [[nodiscard]] const RowDescriptor& projections_row_desc() const { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: method 'projections_row_desc' can be made static [readability-convert-member-functions-to-static]
Suggested change
|
||||||
| if (_intermediate_output_row_descriptor.empty()) { | ||||||
| return intermediate_row_desc(); | ||||||
| } else { | ||||||
| return _intermediate_output_row_descriptor.back(); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| int64_t rows_returned() const { return _num_rows_returned; } | ||||||
| int64_t limit() const { return _limit; } | ||||||
| bool reached_limit() const { return _limit != -1 && _num_rows_returned >= _limit; } | ||||||
|
|
@@ -270,6 +290,10 @@ class ExecNode { | |||||
| std::unique_ptr<RowDescriptor> _output_row_descriptor; | ||||||
| vectorized::VExprContextSPtrs _projections; | ||||||
|
|
||||||
| std::vector<RowDescriptor> _intermediate_output_row_descriptor; | ||||||
| // Used in common subexpression elimination to compute intermediate results. | ||||||
| std::vector<vectorized::VExprContextSPtrs> _intermediate_projections; | ||||||
|
|
||||||
| /// Resource information sent from the frontend. | ||||||
| const TBackendResourceProfile _resource_profile; | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -135,6 +135,9 @@ class PipelineXLocalStateBase { | |||||
| RuntimeState* _state = nullptr; | ||||||
| vectorized::VExprContextSPtrs _conjuncts; | ||||||
| vectorized::VExprContextSPtrs _projections; | ||||||
| // Used in common subexpression elimination to compute intermediate results. | ||||||
| std::vector<vectorized::VExprContextSPtrs> _intermediate_projections; | ||||||
|
|
||||||
| bool _closed = false; | ||||||
| vectorized::Block _origin_block; | ||||||
| }; | ||||||
|
|
@@ -155,6 +158,22 @@ class OperatorXBase : public OperatorBase { | |||||
| if (tnode.__isset.output_tuple_id) { | ||||||
| _output_row_descriptor.reset(new RowDescriptor(descs, {tnode.output_tuple_id}, {true})); | ||||||
| } | ||||||
| if (tnode.__isset.output_tuple_id) { | ||||||
| _output_row_descriptor = std::make_unique<RowDescriptor>( | ||||||
| descs, std::vector {tnode.output_tuple_id}, std::vector {true}); | ||||||
| } | ||||||
| if (!tnode.intermediate_output_tuple_id_list.empty()) { | ||||||
| DCHECK(tnode.__isset.output_tuple_id) << " no final output tuple id"; | ||||||
| // common subexpression elimination | ||||||
| DCHECK_EQ(tnode.intermediate_output_tuple_id_list.size(), | ||||||
| tnode.intermediate_projections_list.size()); | ||||||
| _intermediate_output_row_descriptor.reserve( | ||||||
| tnode.intermediate_output_tuple_id_list.size()); | ||||||
| for (auto output_tuple_id : tnode.intermediate_output_tuple_id_list) { | ||||||
| _intermediate_output_row_descriptor.push_back( | ||||||
| RowDescriptor(descs, std::vector {output_tuple_id}, std::vector {true})); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| OperatorXBase(ObjectPool* pool, int node_id, int operator_id) | ||||||
|
|
@@ -247,6 +266,25 @@ class OperatorXBase : public OperatorBase { | |||||
| return _row_descriptor; | ||||||
| } | ||||||
|
|
||||||
| // input expr -> intermediate_projections[0] -> intermediate_projections[1] -> intermediate_projections[2] ... -> final projections -> output expr | ||||||
| // prepare _row_descriptor intermediate_row_desc[0] intermediate_row_desc[1] intermediate_row_desc.end() _output_row_descriptor | ||||||
|
|
||||||
| [[nodiscard]] const RowDescriptor& intermediate_row_desc(int idx) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: method 'intermediate_row_desc' can be made const [readability-make-member-function-const]
Suggested change
|
||||||
| if (idx == 0) { | ||||||
| return intermediate_row_desc(); | ||||||
| } | ||||||
| DCHECK((idx - 1) < _intermediate_output_row_descriptor.size()); | ||||||
| return _intermediate_output_row_descriptor[idx - 1]; | ||||||
| } | ||||||
|
|
||||||
| [[nodiscard]] const RowDescriptor& projections_row_desc() const { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: method 'projections_row_desc' can be made static [readability-convert-member-functions-to-static]
Suggested change
|
||||||
| if (_intermediate_output_row_descriptor.empty()) { | ||||||
| return intermediate_row_desc(); | ||||||
| } else { | ||||||
| return _intermediate_output_row_descriptor.back(); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| [[nodiscard]] std::string debug_string() const override { return ""; } | ||||||
|
|
||||||
| virtual std::string debug_string(int indentation_level = 0) const; | ||||||
|
|
@@ -318,6 +356,10 @@ class OperatorXBase : public OperatorBase { | |||||
| std::unique_ptr<RowDescriptor> _output_row_descriptor = nullptr; | ||||||
| vectorized::VExprContextSPtrs _projections; | ||||||
|
|
||||||
| std::vector<RowDescriptor> _intermediate_output_row_descriptor; | ||||||
| // Used in common subexpression elimination to compute intermediate results. | ||||||
| std::vector<vectorized::VExprContextSPtrs> _intermediate_projections; | ||||||
|
|
||||||
| /// Resource information sent from the frontend. | ||||||
| const TBackendResourceProfile _resource_profile; | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -719,6 +719,15 @@ void Block::swap(Block&& other) noexcept { | |
| row_same_bit = std::move(other.row_same_bit); | ||
| } | ||
|
|
||
| void Block::shuffle_columns(const std::vector<int>& result_column_ids) { | ||
| Container tmp_data; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tmp_data(result_column_ids.size()) |
||
| tmp_data.reserve(result_column_ids.size()); | ||
| for (const int result_column_id : result_column_ids) { | ||
| tmp_data.push_back(data[result_column_id]); | ||
| } | ||
| swap(Block {tmp_data}); | ||
| } | ||
|
|
||
| void Block::update_hash(SipHash& hash) const { | ||
| for (size_t row_no = 0, num_rows = rows(); row_no < num_rows; ++row_no) { | ||
| for (const auto& col : data) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'intermediate_row_desc' can be made const [readability-make-member-function-const]