query engine work in progress
This commit is contained in:
parent
a5fb18533e
commit
a4fb7b60b1
@ -307,7 +307,7 @@ public:
|
|||||||
Iterator(const Iterator&) = default;
|
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;
|
friend class Accessor;
|
||||||
|
|
||||||
|
@ -91,7 +91,6 @@ public:
|
|||||||
VersionList(VersionList&& other) : id(other.id)
|
VersionList(VersionList&& other) : id(other.id)
|
||||||
{
|
{
|
||||||
this->head = other.head.load();
|
this->head = other.head.load();
|
||||||
this->identifier = other.id();
|
|
||||||
other.head = nullptr;
|
other.head = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
using std::cin;
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
@ -16,22 +17,34 @@ int main(int argc, char** argv)
|
|||||||
auto arguments = all_arguments(argc, argv);
|
auto arguments = all_arguments(argc, argv);
|
||||||
|
|
||||||
// query extraction
|
// query extraction
|
||||||
auto cypher_query = extract_query(arguments);
|
// auto cypher_query = extract_query(arguments);
|
||||||
cout << "QUERY: " << cypher_query << endl;
|
// cout << "QUERY: " << cypher_query << endl;
|
||||||
|
|
||||||
QueryEngine engine;
|
QueryEngine engine;
|
||||||
// engine.execute(cypher_query);
|
// engine.execute(cypher_query);
|
||||||
|
|
||||||
using std::placeholders::_1;
|
// using std::placeholders::_1;
|
||||||
auto f = std::bind(&QueryEngine::execute, &engine, _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;
|
// double counter = 0;
|
||||||
// for (int i = 0; i < 1000000; ++i) {
|
// for (int i = 0; i < 1000000; ++i) {
|
||||||
// counter += timer(f, cypher_query);
|
// counter += timer(f, cypher_query);
|
||||||
// }
|
// }
|
||||||
// cout << 1000000 / (counter / 1000000000) << "create_transactions per sec" << endl;
|
// 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,41 @@
|
|||||||
|
|
||||||
#include "code.hpp"
|
#include "code.hpp"
|
||||||
#include "cypher/visitor/traverser.hpp"
|
#include "cypher/visitor/traverser.hpp"
|
||||||
|
#include "query_engine/util.hpp"
|
||||||
|
|
||||||
class ReadTraverser : public Traverser, public Code
|
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));");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -5,4 +5,15 @@
|
|||||||
|
|
||||||
class UpdateTraverser : public Traverser, public Code
|
class UpdateTraverser : public Traverser, public Code
|
||||||
{
|
{
|
||||||
|
void visit(ast::Match& match) override
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void visit(ast::Set& set) override
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void visit(ast::Return& ret) override
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -27,8 +27,8 @@ public:
|
|||||||
auto next = counter.next(std::memory_order_acquire);
|
auto next = counter.next(std::memory_order_acquire);
|
||||||
|
|
||||||
// create new vertex record
|
// create new vertex record
|
||||||
VertexRecord vertex_record;
|
VertexRecord vertex_record(next);
|
||||||
vertex_record.id(next);
|
// vertex_record.id(next);
|
||||||
|
|
||||||
// insert the new vertex record into the vertex store
|
// insert the new vertex record into the vertex store
|
||||||
auto vertices_accessor = vertices.access();
|
auto vertices_accessor = vertices.access();
|
||||||
|
Loading…
Reference in New Issue
Block a user