memgraph/src/query_engine/traverser/read_traverser.hpp

43 lines
1.2 KiB
C++
Raw Normal View History

2016-02-26 06:49:35 +08:00
#pragma once
2016-02-26 14:45:43 +08:00
#include "code.hpp"
2016-02-26 06:49:35 +08:00
#include "cypher/visitor/traverser.hpp"
2016-03-12 17:57:09 +08:00
#include "query_engine/util.hpp"
2016-02-26 06:49:35 +08:00
2016-02-26 14:45:43 +08:00
class ReadTraverser : public Traverser, public Code
2016-02-26 06:49:35 +08:00
{
2016-03-12 17:57:09 +08:00
private:
uint32_t index{0};
public:
std::string code;
void visit(ast::Match& match) override
{
code += line("auto& t = db.tx_engine.begin();");
Traverser::visit(match);
};
void visit(ast::Property& property) override
{
code += line("auto id = args[" + std::to_string(index) + "]->as<Int32>();");
code += line("auto vertex_accessor = db.graph.vertices.find(t, id.value);");
++index;
}
void visit(ast::Return& ret) override
{
code += line("t.commit();");
2016-06-27 06:43:28 +08:00
// code += line("auto &properties = vertex_accessor.properties();");
// code += line("ResultList::data_t data = {&properties};");
// code += line("auto result_data = "
// "std::make_shared<ResultList>(std::move(data));");
// code += line("QueryResult::data_t query_data = {{\"" +
// ret.return_list->value->name + "\", result_data}};");
// code += line("return std::make_shared<QueryResult>"
// "(std::move(query_data));");
2016-03-12 17:57:09 +08:00
}
2016-02-26 06:49:35 +08:00
};