memgraph/include/query/plan/program_executor.hpp

31 lines
762 B
C++
Raw Normal View History

#pragma once
#include <string>
#include "database/db.hpp"
#include "query/exception/query_engine.hpp"
#include "query/exception/plan_execution.hpp"
#include "query/plan/program.hpp"
#include "query/util.hpp"
// preparations before execution
// execution
// postprocess the results
template <typename Stream>
class ProgramExecutor
{
public:
// QueryProgram has to know about the Stream
// Stream has to be passed in this function for every execution
2016-08-30 12:34:08 +08:00
auto execute(QueryProgram<Stream> &program, Db &db, Stream &stream)
{
2016-07-18 01:32:35 +08:00
try {
return program.plan->run(db, program.stripped.arguments, stream);
// TODO: catch more exceptions
2016-07-18 01:32:35 +08:00
} catch (...) {
throw PlanExecutionException("");
2016-07-18 01:32:35 +08:00
}
}
};