lidavidm commented on a change in pull request #12031:
URL: https://github.com/apache/arrow/pull/12031#discussion_r774824053
##########
File path: cpp/src/arrow/compute/exec/exec_plan.cc
##########
@@ -157,11 +157,46 @@ struct ExecPlanImpl : public ExecPlan {
return std::move(Impl{nodes_}.sorted);
}
+ std::pair<NodeVector, std::vector<int>> OrderedNodes() const {
+ struct Impl {
+ const std::vector<std::unique_ptr<ExecNode>>& nodes;
+ std::unordered_set<ExecNode*> visited;
+ NodeVector sorted;
+ std::vector<int> indents;
+
+ explicit Impl(const std::vector<std::unique_ptr<ExecNode>>& nodes) :
nodes(nodes) {
+ visited.reserve(nodes.size());
+
+ for (auto it = nodes.rbegin(); it != nodes.rend(); ++it) {
+ if (visited.count(it->get()) != 0) return;
+ Visit(it->get());
+ }
+
+ DCHECK_EQ(visited.size(), nodes.size());
+ }
+
+ void Visit(ExecNode* node, int indent = 0) {
+ for (auto input : node->inputs()) {
+ Visit(input, indent + 1);
Review comment:
It should not be possible, but I don't think anything really checks for
this, so the suggestion is just to be cautious. It's not strictly required,
though, just a suggestion.
--
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]