query engine work in progress

This commit is contained in:
Marko Budiselic 2016-03-12 10:57:09 +01:00
parent a5fb18533e
commit a4fb7b60b1
6 changed files with 66 additions and 9 deletions

View File

@ -307,7 +307,7 @@ public:
Iterator(const Iterator&) = default;
};
SkipList() : header(Node::create(K(), std::move(T()), H)) {}
SkipList() : header(Node::create(K(), std::move(T(0)), H)) {}
friend class Accessor;

View File

@ -91,7 +91,6 @@ public:
VersionList(VersionList&& other) : id(other.id)
{
this->head = other.head.load();
this->identifier = other.id();
other.head = nullptr;
}

View File

@ -9,6 +9,7 @@
using std::cout;
using std::endl;
using std::cin;
int main(int argc, char** argv)
{
@ -16,22 +17,34 @@ int main(int argc, char** argv)
auto arguments = all_arguments(argc, argv);
// query extraction
auto cypher_query = extract_query(arguments);
cout << "QUERY: " << cypher_query << endl;
// auto cypher_query = extract_query(arguments);
// cout << "QUERY: " << cypher_query << endl;
QueryEngine engine;
// engine.execute(cypher_query);
using std::placeholders::_1;
auto f = std::bind(&QueryEngine::execute, &engine, _1);
// using std::placeholders::_1;
// auto f = std::bind(&QueryEngine::execute, &engine, _1);
cout << std::fixed << timer(f, cypher_query) << endl;
// cout << std::fixed << timer(f, cypher_query) << endl;
// double counter = 0;
// for (int i = 0; i < 1000000; ++i) {
// counter += timer(f, cypher_query);
// }
// cout << 1000000 / (counter / 1000000000) << "create_transactions per sec" << endl;
// shell
// std::string command;
// cout << "-- Memgraph query engine --" << endl;
// do {
// cout << "> ";
// std::getline(cin, command);
// engine.execute(command);
// } while (command != "quit");
engine.execute("CREATE (n{id:2}) RETURN n");
engine.execute("MATCH (n{id:0}) RETURN n");
return 0;
}

View File

@ -2,7 +2,41 @@
#include "code.hpp"
#include "cypher/visitor/traverser.hpp"
#include "query_engine/util.hpp"
class ReadTraverser : public Traverser, public Code
{
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();");
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));");
}
};

View File

@ -5,4 +5,15 @@
class UpdateTraverser : public Traverser, public Code
{
void visit(ast::Match& match) override
{
}
void visit(ast::Set& set) override
{
}
void visit(ast::Return& ret) override
{
}
};

View File

@ -27,8 +27,8 @@ public:
auto next = counter.next(std::memory_order_acquire);
// create new vertex record
VertexRecord vertex_record;
vertex_record.id(next);
VertexRecord vertex_record(next);
// vertex_record.id(next);
// insert the new vertex record into the vertex store
auto vertices_accessor = vertices.access();