38 virtual std::string
str()
const {
39 std::string ret{
out_.str()};
51 using id_map = std::unordered_map<std::uintptr_t, NodeInfo>;
64 std::vector<std::shared_ptr<RelAlgNode>>
const nodes);
71 auto [it, id_is_new] =
ids_.emplace(
90 if (!step || *step == 0) {
113 auto temp = std::move(
nodes);
114 for (
auto& node : temp) {
116 node->acceptChildren(*
this);
122 std::vector<RelAlgDagNode const*>
nodes;
130 std::function<void(RelAlgDagNode const*)>
callback;
134 std::vector<std::pair<std::string, RelAlgDagNode const*>>
nodes;
138 nodes.emplace_back(s, n);
145 template <
typename T>
147 static_assert(std::is_base_of_v<
RelAlgDagNode, std::remove_pointer_t<T>>);
148 auto it =
ids_.find(std::uintptr_t(static_cast<RelAlgDagNode const*>(child)));
150 it->second.used_node =
true;
153 child->accept(*
this, name);
157 template <
typename T>
159 static_assert(std::is_base_of_v<
RelAlgDagNode, std::remove_pointer_t<T>>);
166 auto ids = std::move(
ids_);
170 ids_ = std::move(ids);
178 id_map::iterator it =
emplace(t);
183 std::string key_text{!name.empty() ? (
"[" + name +
"] ") :
""};
184 out_ <<
"#" << it->second.id <<
" " << key_text;
189 out_ << t->toString(cfg);
200 t->acceptChildren(visitor);
201 for (
auto [key, child] : visitor.
nodes) {
205 if (dynamic_cast<RelScan const*>(child) ||
206 dynamic_cast<RexInput const*>(child)) {
278 ids_.find(std::uintptr_t(static_cast<RelAlgDagNode const*>(n->
getSourceNode())));
279 if (it !=
ids_.end()) {
280 out_ <<
": source #" << it->second.id;
317 std::vector<std::shared_ptr<RelAlgNode>>
const nodes) {
324 for (
auto const& node : nodes) {
325 if (node && node->getStepNumber() > 1) {
341 it->second.used_node =
true;
343 bfs.search(nodes.back().get());
347 nodes.back()->accept(*
this, {});
std::unordered_map< std::uintptr_t, NodeInfo > id_map
bool visit(RelLogicalValues const *n, std::string s) override
virtual id_map::iterator emplace(RelAlgDagNode const *n)
std::ostream & operator<<(std::ostream &os, const SessionInfo &session_info)
RelAlgDagViewer(bool showing_steps, bool verbose)
bool visit(RelLogicalUnion const *n, std::string s) override
bool visit(RelModify const *n, std::string s) override
bool visit(RelJoin const *n, std::string s) override
bool visit(RexSubQuery const *n, std::string s) override
virtual void handleQueryEngineVector(std::vector< std::shared_ptr< RelAlgNode >> const nodes)
bool visit(RexCase const *n, std::string s) override
bool visit(RelProject const *n, std::string s) override
bool visit(RelCompound const *n, std::string s) override
static constexpr size_t indent_spaces_
bool visit(RelTableFunction const *n, std::string s) override
virtual id_map::iterator emplaceVoid(void const *n)
bool visit(RelScan const *n, std::string s) override
bool visit(RexInput const *n, std::string s) override
bool visit(RexWindowFunctionOperator const *n, std::string s) override
bool visit(RelLeftDeepInnerJoin const *n, std::string s) override
std::function< void(RelAlgDagNode const *)> callback
bool visit(RexLiteral const *n, std::string s) override
virtual void accept(Visitor &v, std::string name) const =0
bool innerVisit(T t, std::string name, bool recurse=true)
virtual bool visitAny(RelAlgDagNode const *n, std::string s) override
bool visit(RexFunctionOperator const *n, std::string s) override
void setIdInPlanTree(size_t id) const
bool visit(RelFilter const *n, std::string s) override
bool visit(RelTranslatedJoin const *n, std::string s) override
bool visit(RexRef const *n, std::string s) override
void visitChild(T child, std::string name)
bool visit(RelAggregate const *n, std::string s) override
bool visit(RexAgg const *n, std::string s) override
bool visit(RexAbstractInput const *n, std::string s) override
bool visit(RexOperator const *n, std::string s) override
void beginNextLine(std::optional< size_t > step={})
virtual std::string str() const
std::vector< RelAlgDagNode const * > nodes
bool visit(RelSort const *n, std::string s) override