#pragma once #include #include namespace NYql { struct TExprContext; struct IOptimizer { using TVarId = std::tuple; struct TVar { char Name = 0; // debug name: 'a', 'b', 'c', ... }; struct TRel { double Rows = 0; double TotalCost = 0; std::vector TargetVars; }; struct TEq { std::vector Vars; }; struct TInput { std::vector Rels; std::vector EqClasses; std::vector Left; std::vector 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 LeftVars = {}; std::vector RightVars = {}; std::vector Rels = {}; int Outer = -1; // index in Nodes int Inner = -1; // index in Nodes }; struct TOutput { std::vector 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& log = {}); IOptimizerNew* MakePgOptimizerNew(IProviderContext& pctx, TExprContext& ctx, const std::function& log = {}); } // namespace NYql