diff options
| author | vvvv <[email protected]> | 2024-11-06 23:54:28 +0300 |
|---|---|---|
| committer | vvvv <[email protected]> | 2024-11-07 00:04:25 +0300 |
| commit | cf2a23963ac10add28c50cc114fbf48953eca5aa (patch) | |
| tree | 174b849b8ecfa96b0c8e4409ab3287721a9210c8 /yql/essentials/parser/pg_wrapper/interface/optimizer.h | |
| parent | 3a3113a2bf5a7fab32bde414932082b264c559fc (diff) | |
Prepare move yql/minikql YQL-19206
types,jsonpath,dom
commit_hash:6b54be5968b6a30b6d97fe3a1611574bcefc749e
Diffstat (limited to 'yql/essentials/parser/pg_wrapper/interface/optimizer.h')
| -rw-r--r-- | yql/essentials/parser/pg_wrapper/interface/optimizer.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/yql/essentials/parser/pg_wrapper/interface/optimizer.h b/yql/essentials/parser/pg_wrapper/interface/optimizer.h new file mode 100644 index 00000000000..689d2f622f9 --- /dev/null +++ b/yql/essentials/parser/pg_wrapper/interface/optimizer.h @@ -0,0 +1,80 @@ +#pragma once + +#include <yql/essentials/core/cbo/cbo_optimizer_new.h> + +#include <functional> + +namespace NYql { + +struct TExprContext; + +struct IOptimizer { + using TVarId = std::tuple<int, int>; + + struct TVar { + char Name = 0; // debug name: 'a', 'b', 'c', ... + }; + + struct TRel { + double Rows = 0; + double TotalCost = 0; + + std::vector<TVar> TargetVars; + }; + + struct TEq { + std::vector<TVarId> Vars; + }; + + struct TInput { + std::vector<TRel> Rels; + std::vector<TEq> EqClasses; + std::vector<TEq> Left; + std::vector<TEq> Right; + + TString ToString() const; + void Normalize(); + }; + + enum class EJoinType { + Unknown, + Inner, + Left, + Right, + }; + + enum class EJoinStrategy { + Unknown, + Hash, + Loop + }; + + struct TJoinNode { + EJoinType Mode = EJoinType::Unknown; + EJoinStrategy Strategy = EJoinStrategy::Unknown; + // only a = b && c = d ... supported yet + std::vector<TVarId> LeftVars = {}; + std::vector<TVarId> RightVars = {}; + std::vector<int> Rels = {}; + int Outer = -1; // index in Nodes + int Inner = -1; // index in Nodes + }; + + struct TOutput { + std::vector<TJoinNode> Nodes; + TInput* Input = nullptr; + double Rows = 0; + double TotalCost = 0; + + TString ToString(bool printCost = true) const; + }; + + virtual ~IOptimizer() = default; + virtual TOutput JoinSearch() = 0; +}; + +IOptimizer* MakePgOptimizerInternal(const IOptimizer::TInput& input, const std::function<void(const TString&)>& log = {}); + +IOptimizerNew* MakePgOptimizerNew(IProviderContext& pctx, TExprContext& ctx, const std::function<void(const TString&)>& log = {}); + +} // namespace NYql |
