ArianaVillegas commented on a change in pull request #12031:
URL: https://github.com/apache/arrow/pull/12031#discussion_r774809343
##########
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);
+ }
+
+ indents.push_back(indent);
+ sorted.push_back(node);
+ visited.insert(node);
+ }
+ };
+
+ auto result = Impl{nodes_};
Review comment:
I think it is not necessary because the function OrderedNodes() is a
variant of TopoSort (), so with that, it should reflect the direction of data
flow.
--
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]