delete traverser (skeleton only)

This commit is contained in:
Marko Budiselic 2016-02-26 07:45:43 +01:00
parent 0e897b412a
commit 3eb84e8f1c
8 changed files with 49 additions and 23 deletions

View File

@ -12,7 +12,6 @@ using std::string;
class CodeGenerator
{
public:
void generate_cpp(const std::string& query,
const uint64_t stripped_hash,
const std::string& path)
@ -33,8 +32,7 @@ public:
{"class_name", "CodeCPU"},
{"stripped_hash", std::to_string(stripped_hash)},
{"query", query},
{"code", code_traverser.code},
{"return_type", "int"}
{"code", code_traverser.code}
}
);
utils::write_file(generated, path);

View File

@ -1,5 +1,7 @@
#include <iostream>
#define DEBUG 1
#include "utils/command_line/arguments.hpp"
#include "cypher/common.hpp"
#include "query_engine.hpp"

View File

@ -5,17 +5,12 @@
#include "query_program.hpp"
#include "database/db.hpp"
#include "utils/log/logger.hpp"
#include "query_engine/debug.hpp"
// preparations before execution
// execution
// postprocess the results
#define DEBUG 1
#include "query_engine/debug.hpp"
using std::cout;
using std::endl;
class ProgramExecutor
{
public:
@ -23,7 +18,7 @@ public:
auto execute(QueryProgram& program)
{
auto result = program.code->run(db, program.stripped.arguments);
print_props(*result->data["n"]->data[0]);
PRINT_PROPS(*result->data["n"]->data[0]);
return result;
}

View File

@ -0,0 +1,14 @@
#pragma once
#include <string>
struct Code
{
void reset()
{
code = "";
}
std::string code;
};

View File

@ -4,20 +4,15 @@
#include "cypher/visitor/traverser.hpp"
#include "cypher/ast/queries.hpp"
#include "code.hpp"
#include "write_traverser.hpp"
#include "read_traverser.hpp"
#include "update_traverser.hpp"
#include "delete_traverser.hpp"
class CodeTraverser : public Traverser
class CodeTraverser : public Traverser, public Code
{
public:
std::string code;
void reset()
{
code = "";
}
void visit(ast::WriteQuery& write_query) override
{
auto write_traverser = WriteTraverser();
@ -31,4 +26,18 @@ public:
read_query.accept(read_traverser);
code = read_traverser.code;
}
void visit(ast::UpdateQuery& update_query) override
{
auto update_traverser = UpdateTraverser();
update_query.accept(update_traverser);
code = update_traverser.code;
}
void visit(ast::DeleteQuery& delete_query) override
{
auto delete_traverser = DeleteTraverser();
delete_query.accept(delete_traverser);
code = delete_traverser.code;
}
};

View File

@ -0,0 +1,8 @@
#pragma once
#include "code.hpp"
#include "cypher/visitor/traverser.hpp"
class DeleteTraverser : public Traverser, public Code
{
};

View File

@ -1,9 +1,8 @@
#pragma once
#include "code.hpp"
#include "cypher/visitor/traverser.hpp"
class ReadTraverser : public Traverser
class ReadTraverser : public Traverser, public Code
{
public:
std::string code;
};

View File

@ -1,7 +1,8 @@
#pragma once
#include "code.hpp"
#include "cypher/visitor/traverser.hpp"
class UpdateTraverser : public Traverser
class UpdateTraverser : public Traverser, public Code
{
};