b90375c3ae
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
43 lines
1.3 KiB
C++
43 lines
1.3 KiB
C++
#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;
|
|
}
|
|
|
|
// Shorthand for a vector of pairs (logical_plan, cost).
|
|
typedef std::vector<
|
|
std::pair<std::unique_ptr<query::plan::LogicalOperator>, double>>
|
|
PlansWithCost;
|
|
|
|
// 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 &,
|
|
PlansWithCost &, const Args &, const query::AstStorage &)>
|
|
function;
|
|
// Number of arguments the function works with.
|
|
int arg_count;
|
|
// Explanation of the command.
|
|
std::string documentation;
|
|
};
|
|
|
|
#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)
|
|
|
|
void AddCommand(const std::string &name, const Command &command);
|
|
|
|
void RunInteractivePlanning(database::GraphDbAccessor *dba);
|