2016-07-11 09:39:33 +08:00
|
|
|
#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"
|
2016-08-11 11:47:30 +08:00
|
|
|
#include "communication/communication.hpp"
|
2016-08-29 01:50:54 +08:00
|
|
|
#include "logging/default.hpp"
|
|
|
|
#include "logging/streams/stdout.hpp"
|
2016-07-11 09:39:33 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2016-08-29 01:50:54 +08:00
|
|
|
logging::init_sync();
|
|
|
|
logging::log->pipe(std::make_unique<Stdout>());
|
|
|
|
|
2016-08-10 16:39:02 +08:00
|
|
|
Db db;
|
2016-08-11 11:47:30 +08:00
|
|
|
// TODO: write dummy socket that is going to execute test
|
2016-08-29 01:50:54 +08:00
|
|
|
using stream_t = bolt::RecordStream<CoutSocket>;
|
|
|
|
CoutSocket socket;
|
|
|
|
stream_t stream(socket);
|
|
|
|
QueryEngine<stream_t> engine;
|
2016-07-11 09:39:33 +08:00
|
|
|
|
|
|
|
cout << "-- Memgraph query engine --" << endl;
|
2016-07-18 01:32:35 +08:00
|
|
|
|
|
|
|
while (true) {
|
|
|
|
// read command
|
2016-07-11 09:39:33 +08:00
|
|
|
cout << "> ";
|
2016-07-18 01:32:35 +08:00
|
|
|
std::string command;
|
2016-07-11 09:39:33 +08:00
|
|
|
std::getline(cin, command);
|
2016-07-18 01:32:35 +08:00
|
|
|
if (command == "quit")
|
|
|
|
break;
|
|
|
|
|
|
|
|
// execute command
|
|
|
|
try {
|
2016-08-11 11:47:30 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2016-07-11 09:39:33 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|