optimizer.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #pragma once
  2. #include <yql/essentials/parser/pg_wrapper/interface/optimizer.h>
  3. struct Var;
  4. struct RelOptInfo;
  5. struct List;
  6. struct EquivalenceClass;
  7. struct Path;
  8. struct RestrictInfo;
  9. namespace NYql {
  10. class TPgOptimizer: public IOptimizer {
  11. public:
  12. TPgOptimizer(const TInput& input, const std::function<void(const TString&)>& log = {});
  13. ~TPgOptimizer();
  14. TOutput JoinSearch() override;
  15. private:
  16. TInput Input;
  17. std::function<void(const TString&)> Log;
  18. std::map<TVarId, Var*> Vars;
  19. std::vector<std::vector<RestrictInfo*>> RestrictInfos;
  20. std::vector<RestrictInfo*> LeftRestriction;
  21. std::vector<RestrictInfo*> RightRestriction;
  22. void MakeLeftOrRightRestrictions(std::vector<RestrictInfo*>& dst, const std::vector<TEq>& src);
  23. void LogNode(const TString& prefix, void* node);
  24. RelOptInfo* JoinSearchInternal();
  25. List* MakeEqClasses();
  26. EquivalenceClass* MakeEqClass(int eqId);
  27. Var* MakeVar(TVarId);
  28. TOutput MakeOutput(Path*);
  29. int MakeOutputJoin(TOutput& output, Path*);
  30. void LogOutput(const TString& prefix, const TOutput& output, int id);
  31. TString PrettyPrintVar(TVarId varId);
  32. };
  33. // export for tests
  34. Var* MakeVar(int relno, int varno);
  35. RelOptInfo* MakeRelOptInfo(const IOptimizer::TRel& r, int relno);
  36. List* MakeRelOptInfoList(const IOptimizer::TInput& input);
  37. } // namespace NYql