From bfe30a972359bbcf253f46e9486e304188df7a18 Mon Sep 17 00:00:00 2001 From: Artem Zuikov Date: Thu, 25 Jun 2020 22:26:03 +0300 Subject: [PATCH] remove a trick with expression continuation --- .../ExpressionBlockInputStream.cpp | 29 ------------------- src/Interpreters/ExpressionActions.cpp | 16 ++++------ src/Interpreters/ExpressionActions.h | 2 +- .../InflatingExpressionTransform.cpp | 6 ++-- .../Transforms/InflatingExpressionTransform.h | 1 - 5 files changed, 9 insertions(+), 45 deletions(-) diff --git a/src/DataStreams/ExpressionBlockInputStream.cpp b/src/DataStreams/ExpressionBlockInputStream.cpp index cce02af8262..9673395a21a 100644 --- a/src/DataStreams/ExpressionBlockInputStream.cpp +++ b/src/DataStreams/ExpressionBlockInputStream.cpp @@ -44,33 +44,4 @@ Block ExpressionBlockInputStream::readImpl() return res; } -Block InflatingExpressionBlockInputStream::readImpl() -{ - if (!initialized) - { - if (expression->resultIsAlwaysEmpty()) - return {}; - - initialized = true; - } - - Block res; - bool keep_going = not_processed && not_processed->empty(); /// There's data inside expression. - - if (!not_processed || keep_going) - { - not_processed.reset(); - - res = children.back()->read(); - if (res || keep_going) - expression->execute(res, not_processed, action_number); - } - else - { - res = std::move(not_processed->block); - expression->execute(res, not_processed, action_number); - } - return res; -} - } diff --git a/src/Interpreters/ExpressionActions.cpp b/src/Interpreters/ExpressionActions.cpp index 0a99fcd6f21..845c1c789f7 100644 --- a/src/Interpreters/ExpressionActions.cpp +++ b/src/Interpreters/ExpressionActions.cpp @@ -676,19 +676,13 @@ void ExpressionActions::execute(Block & block, bool dry_run) const } } -/// @warning It's a tricky method that allows to continue ONLY ONE action in reason of one-to-many ALL JOIN logic. -void ExpressionActions::execute(Block & block, ExtraBlockPtr & not_processed, size_t & start_action) const +void ExpressionActions::execute(Block & block, ExtraBlockPtr & not_processed) const { - size_t i = start_action; - start_action = 0; - for (; i < actions.size(); ++i) - { - actions[i].execute(block, false, not_processed); - checkLimits(block); + if (actions.size() != 1) + throw Exception("Continuation over multiple expressions is not supported", ErrorCodes::LOGICAL_ERROR); - if (not_processed) - start_action = i; - } + actions[0].execute(block, false, not_processed); + checkLimits(block); } bool ExpressionActions::hasJoinOrArrayJoin() const diff --git a/src/Interpreters/ExpressionActions.h b/src/Interpreters/ExpressionActions.h index 8f66e6c5c3a..89f10184bd8 100644 --- a/src/Interpreters/ExpressionActions.h +++ b/src/Interpreters/ExpressionActions.h @@ -212,7 +212,7 @@ public: void execute(Block & block, bool dry_run = false) const; /// Execute the expression on the block with continuation. - void execute(Block & block, ExtraBlockPtr & not_processed, size_t & start_action) const; + void execute(Block & block, ExtraBlockPtr & not_processed) const; bool hasJoinOrArrayJoin() const; diff --git a/src/Processors/Transforms/InflatingExpressionTransform.cpp b/src/Processors/Transforms/InflatingExpressionTransform.cpp index de4e93ef8d2..5fc5bdc2304 100644 --- a/src/Processors/Transforms/InflatingExpressionTransform.cpp +++ b/src/Processors/Transforms/InflatingExpressionTransform.cpp @@ -59,7 +59,7 @@ Block InflatingExpressionTransform::readExecute(Chunk & chunk) res = getInputPort().getHeader().cloneWithColumns(chunk.detachColumns()); if (res) - expression->execute(res, not_processed, action_number); + expression->execute(res, not_processed); } else if (not_processed->empty()) /// There's not processed data inside expression. { @@ -67,12 +67,12 @@ Block InflatingExpressionTransform::readExecute(Chunk & chunk) res = getInputPort().getHeader().cloneWithColumns(chunk.detachColumns()); not_processed.reset(); - expression->execute(res, not_processed, action_number); + expression->execute(res, not_processed); } else { res = std::move(not_processed->block); - expression->execute(res, not_processed, action_number); + expression->execute(res, not_processed); } return res; } diff --git a/src/Processors/Transforms/InflatingExpressionTransform.h b/src/Processors/Transforms/InflatingExpressionTransform.h index b490d0699ad..ee77eaee19c 100644 --- a/src/Processors/Transforms/InflatingExpressionTransform.h +++ b/src/Processors/Transforms/InflatingExpressionTransform.h @@ -27,7 +27,6 @@ private: bool initialized = false; ExtraBlockPtr not_processed; - size_t action_number = 0; Block readExecute(Chunk & chunk); };