2017-05-30 17:53:48 +08:00
|
|
|
/// @file
|
2017-08-24 14:42:19 +08:00
|
|
|
/// This file is an entry point for invoking various planners via
|
|
|
|
/// `MakeLogicalPlan` API.
|
2017-03-12 03:49:22 +08:00
|
|
|
|
2017-08-24 14:42:19 +08:00
|
|
|
#pragma once
|
2017-03-12 03:49:22 +08:00
|
|
|
|
2017-10-24 16:18:20 +08:00
|
|
|
#include "query/plan/preprocess.hpp"
|
2017-08-24 14:42:19 +08:00
|
|
|
#include "query/plan/rule_based_planner.hpp"
|
|
|
|
#include "query/plan/variable_start_planner.hpp"
|
2017-03-12 03:49:22 +08:00
|
|
|
|
|
|
|
namespace query {
|
|
|
|
|
2017-05-05 21:34:07 +08:00
|
|
|
class AstTreeStorage;
|
2017-03-16 16:45:55 +08:00
|
|
|
class SymbolTable;
|
2017-03-16 16:28:16 +08:00
|
|
|
|
2017-03-27 19:09:14 +08:00
|
|
|
namespace plan {
|
|
|
|
|
2017-05-30 17:53:48 +08:00
|
|
|
/// @brief Generates the LogicalOperator tree and returns the resulting plan.
|
2017-05-05 21:34:07 +08:00
|
|
|
///
|
2017-05-30 17:53:48 +08:00
|
|
|
/// @tparam TPlanner Type of the planner used for generation.
|
2017-08-24 14:42:19 +08:00
|
|
|
/// @tparam TDbAccessor Type of the database accessor used for generation.
|
2017-10-13 15:46:49 +08:00
|
|
|
/// @param context PlanningContext used for generating plans.
|
2017-06-01 20:23:01 +08:00
|
|
|
/// @return @c PlanResult which depends on the @c TPlanner used.
|
|
|
|
///
|
2017-10-13 15:46:49 +08:00
|
|
|
/// @sa PlanningContext
|
2017-06-01 20:23:01 +08:00
|
|
|
/// @sa RuleBasedPlanner
|
|
|
|
/// @sa VariableStartPlanner
|
2017-08-24 14:42:19 +08:00
|
|
|
template <template <class> class TPlanner, class TDbAccessor>
|
2017-10-13 15:46:49 +08:00
|
|
|
auto MakeLogicalPlan(PlanningContext<TDbAccessor> &context) {
|
|
|
|
context.bound_symbols.clear();
|
|
|
|
auto query_parts =
|
|
|
|
CollectQueryParts(context.symbol_table, context.ast_storage);
|
2017-08-24 14:42:19 +08:00
|
|
|
return TPlanner<decltype(context)>(context).Plan(query_parts);
|
2017-05-24 22:13:25 +08:00
|
|
|
}
|
2017-05-05 21:34:07 +08:00
|
|
|
|
|
|
|
} // namespace plan
|
2017-05-26 18:05:00 +08:00
|
|
|
|
|
|
|
} // namespace query
|