memgraph/tests/manual/query_engine.cpp

54 lines
1.3 KiB
C++
Raw Normal View History

#include <iostream>
#define DEBUG 1
#include "utils/command_line/arguments.hpp"
#include "cypher/common.hpp"
#include "query_engine/query_engine.hpp"
#include "utils/time/timer.hpp"
2016-07-18 01:32:35 +08:00
#include "utils/terminate_handler.hpp"
#include "communication/communication.hpp"
#include "logging/default.hpp"
#include "logging/streams/stdout.hpp"
using std::cout;
using std::endl;
using std::cin;
int main(void)
{
2016-07-18 01:32:35 +08:00
std::set_terminate(&terminate_handler);
logging::init_sync();
logging::log->pipe(std::make_unique<Stdout>());
Db db;
// TODO: write dummy socket that is going to execute test
using stream_t = bolt::RecordStream<CoutSocket>;
CoutSocket socket;
stream_t stream(socket);
QueryEngine<stream_t> engine;
cout << "-- Memgraph query engine --" << endl;
2016-07-18 01:32:35 +08:00
while (true) {
// read command
cout << "> ";
2016-07-18 01:32:35 +08:00
std::string command;
std::getline(cin, command);
2016-07-18 01:32:35 +08:00
if (command == "quit")
break;
// execute command
try {
engine.execute(command, db, stream);
2016-07-18 01:32:35 +08:00
} catch (const std::exception& e) {
cout << e.what() << endl;
} catch (const QueryEngineException& e) {
cout << e.what() << endl;
}
}
return 0;
}