2018-10-10 16:23:10 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "query/frontend/semantic/symbol_table.hpp"
|
|
|
|
#include "query/plan/operator.hpp"
|
|
|
|
|
|
|
|
namespace database {
|
|
|
|
class GraphDbAccessor;
|
|
|
|
}
|
|
|
|
|
2019-02-05 23:12:02 +08:00
|
|
|
struct InteractivePlan {
|
|
|
|
// Original plan after going only through the RuleBasedPlanner.
|
|
|
|
std::unique_ptr<query::plan::LogicalOperator> unoptimized_plan;
|
|
|
|
// Storage for the AST used in unoptimized_plan
|
|
|
|
query::AstStorage ast_storage;
|
|
|
|
// Final plan after being rewritten and optimized.
|
|
|
|
std::unique_ptr<query::plan::LogicalOperator> final_plan;
|
|
|
|
// Cost of the final plan.
|
|
|
|
double cost;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<InteractivePlan> PlansWithCost;
|
2018-10-10 16:23:10 +08:00
|
|
|
|
|
|
|
// Encapsulates a consoles command function.
|
|
|
|
struct Command {
|
|
|
|
typedef std::vector<std::string> Args;
|
|
|
|
// Function of this command
|
|
|
|
std::function<void(database::GraphDbAccessor &, const query::SymbolTable &,
|
Remove GraphDbAccessor and storage types from Ast
Summary:
This diff removes the need for a database when parsing a query and
creating an Ast. Instead of storing storage::{Label,Property,EdgeType}
in Ast nodes, we store the name and an index into all of the names. This
allows for easy creation of a map from {Label,Property,EdgeType} index
into the concrete storage type. Obviously, this comes with a performance
penalty during execution, but it should be minor. The upside is that the
query/frontend minimally depends on storage (PropertyValue), which makes
writing tests easier as well as running them a lot faster (there is no
database setup). This is most noticeable in the ast_serialization test
which took a long time due to start up of a distributed database.
Reviewers: mtomic, llugovic
Reviewed By: mtomic
Subscribers: mferencevic, pullbot
Differential Revision: https://phabricator.memgraph.io/D1774
2019-01-14 21:41:37 +08:00
|
|
|
PlansWithCost &, const Args &, const query::AstStorage &)>
|
2018-10-10 16:23:10 +08:00
|
|
|
function;
|
|
|
|
// Number of arguments the function works with.
|
|
|
|
int arg_count;
|
|
|
|
// Explanation of the command.
|
|
|
|
std::string documentation;
|
|
|
|
};
|
|
|
|
|
Remove GraphDbAccessor and storage types from Ast
Summary:
This diff removes the need for a database when parsing a query and
creating an Ast. Instead of storing storage::{Label,Property,EdgeType}
in Ast nodes, we store the name and an index into all of the names. This
allows for easy creation of a map from {Label,Property,EdgeType} index
into the concrete storage type. Obviously, this comes with a performance
penalty during execution, but it should be minor. The upside is that the
query/frontend minimally depends on storage (PropertyValue), which makes
writing tests easier as well as running them a lot faster (there is no
database setup). This is most noticeable in the ast_serialization test
which took a long time due to start up of a distributed database.
Reviewers: mtomic, llugovic
Reviewed By: mtomic
Subscribers: mferencevic, pullbot
Differential Revision: https://phabricator.memgraph.io/D1774
2019-01-14 21:41:37 +08:00
|
|
|
#define DEFCOMMAND(Name) \
|
|
|
|
void Name##Command(database::GraphDbAccessor &dba, \
|
|
|
|
const query::SymbolTable &symbol_table, \
|
|
|
|
PlansWithCost &plans, const Command::Args &args, \
|
|
|
|
const query::AstStorage &ast_storage)
|
2018-10-10 16:23:10 +08:00
|
|
|
|
|
|
|
void AddCommand(const std::string &name, const Command &command);
|
|
|
|
|
|
|
|
void RunInteractivePlanning(database::GraphDbAccessor *dba);
|