1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // DuckDB |
3 | // |
4 | // duckdb/optimizer/deliminator.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #include "duckdb/parser/expression_map.hpp" |
12 | #include "duckdb/planner/column_binding_map.hpp" |
13 | #include "duckdb/planner/logical_operator.hpp" |
14 | #include "duckdb/planner/logical_operator_visitor.hpp" |
15 | |
16 | namespace duckdb { |
17 | |
18 | class Optimizer; |
19 | class DeliminatorPlanUpdater; |
20 | |
21 | //! The Deliminator optimizer traverses the logical operator tree and removes any redundant DelimGets/DelimJoins |
22 | class Deliminator { |
23 | public: |
24 | explicit Deliminator(ClientContext &context) : context(context) { |
25 | } |
26 | //! Perform DelimJoin elimination |
27 | unique_ptr<LogicalOperator> Optimize(unique_ptr<LogicalOperator> op); |
28 | |
29 | private: |
30 | //! Find Joins with a DelimGet that can be removed |
31 | void FindCandidates(unique_ptr<LogicalOperator> *op_ptr, vector<unique_ptr<LogicalOperator> *> &candidates); |
32 | //! Try to remove a Join with a DelimGet, returns true if it was successful |
33 | bool RemoveCandidate(unique_ptr<LogicalOperator> *plan, unique_ptr<LogicalOperator> *candidate, |
34 | DeliminatorPlanUpdater &updater); |
35 | //! Try to remove an inequality Join with a DelimGet, returns true if it was successful |
36 | bool RemoveInequalityCandidate(unique_ptr<LogicalOperator> *plan, unique_ptr<LogicalOperator> *candidate, |
37 | DeliminatorPlanUpdater &updater); |
38 | |
39 | private: |
40 | ClientContext &context; |
41 | }; |
42 | |
43 | } // namespace duckdb |
44 |