Fix bugs needed to run qa tests

Reviewers: buda

Reviewed By: buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D216
This commit is contained in:
Mislav Bradac 2017-04-04 17:27:57 +02:00
parent e2949a88ce
commit a58e269176
18 changed files with 115 additions and 89 deletions

View File

@ -0,0 +1,28 @@
###########################
# MEMGRAPH DEFAULT CONFIG #
###########################
# NOTE: all paths are relative to the run folder
# (where the executable is runned)
# path to the codes which will be compiled
compile_path: "./compiled/"
# path to the template (cpp) for codes generation
template_cpp_path: "./template/plan_template_cpp"
# path to the folder with snapshots
snapshots_path: "snapshots"
# cleaning cycle interval
# if set to -1 the GC will not run
cleaning_cycle_sec: "30"
# snapshot cycle interval
snapshot_cycle_sec: "60"
# max number of snapshots which will be kept on the disk at some point
max_retained_snapshots: "3"
# by default query engine runs in interpret mode
interpret: false

View File

@ -54,7 +54,7 @@ State StateExecutorRun(Session &session) {
}
return EXECUTOR;
// !! QUERY ENGINE -> RUN METHOD -> EXCEPTION HANDLING !!
// !! QUERY ENGINE -> RUN METHOD -> EXCEPTION HANDLING !!
} catch (const query::SyntaxException &e) {
db_accessor->abort();
session.encoder_.MessageFailure(
@ -79,7 +79,7 @@ State StateExecutorRun(Session &session) {
}
// TODO (mferencevic): finish the error handling, cover all exceptions
// which can be raised from query engine
// * [abort, MessageFailure, return ERROR] should be extracted into
// * [abort, MessageFailure, return ERROR] should be extracted into
// separate function (or something equivalent)
//
// !! QUERY ENGINE -> RUN METHOD -> EXCEPTION HANDLING !!
@ -96,6 +96,7 @@ State StateExecutorRun(Session &session) {
} else if (message_type == MessageCode::Reset) {
// TODO: rollback current transaction
// discard all records waiting to be sent
session.encoder_.MessageSuccess();
return EXECUTOR;
} else {
logger.error("Unrecognized message recieved");

View File

@ -5,12 +5,12 @@
#include "data_structures/bitset/static_bitset.hpp"
#include "query/backend/cpp/typed_value.hpp"
#include "query/parameters.hpp"
#include "query/plan_interface.hpp"
#include "storage/edge_accessor.hpp"
#include "storage/vertex_accessor.hpp"
#include "using.hpp"
#include "utils/assert.hpp"
#include "query/parameters.hpp"
using std::cout;
using std::endl;
@ -30,7 +30,9 @@ enum CliqueQuery { SCORE_AND_LIMIT, FIND_ALL };
bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args,
Stream &stream, enum CliqueQuery query_type) {
std::vector<std::string> headers{std::string("a.garment_id"), std::string("b.garment_id"), std::string("c.garment_id"), std::string("d.garment_id")};
std::vector<std::string> headers{
std::string("a.garment_id"), std::string("b.garment_id"),
std::string("c.garment_id"), std::string("d.garment_id")};
if (query_type != CliqueQuery::FIND_ALL)
headers.push_back(std::string("score"));
stream.Header(headers);
@ -69,8 +71,8 @@ bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args,
edges_indexed.push_back(&edges[i]);
}
const int n = vertices_indexed.size();
auto cmp_vertex = [](const VertexAccessor *a, const VertexAccessor *b)
-> bool { return *a < *b; };
auto cmp_vertex = [](const VertexAccessor *a,
const VertexAccessor *b) -> bool { return *a < *b; };
auto cmp_edge = [](const EdgeAccessor *a, const EdgeAccessor *b) -> bool {
if (a->from() != b->from()) return a->from() < b->from();
return a->to() < b->to();
@ -80,15 +82,15 @@ bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args,
* @param v VertexAccessor to a vertex.
* @return position of vertex or -1 if it doesn't exist.
*/
auto query =
[&vertices_indexed, &cmp_vertex](const VertexAccessor &v) -> int {
int pos = lower_bound(vertices_indexed.begin(), vertices_indexed.end(),
&v, cmp_vertex) -
vertices_indexed.begin();
if (pos == (int)vertices_indexed.size() || *vertices_indexed[pos] != v)
return -1;
return pos;
};
auto query = [&vertices_indexed,
&cmp_vertex](const VertexAccessor &v) -> int {
int pos = lower_bound(vertices_indexed.begin(), vertices_indexed.end(), &v,
cmp_vertex) -
vertices_indexed.begin();
if (pos == (int)vertices_indexed.size() || *vertices_indexed[pos] != v)
return -1;
return pos;
};
/**
* Update bitset of neighbours. Set bit to 1 for index of every vertex
* endpoint of edges with type default_outfit.
@ -145,16 +147,15 @@ bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args,
* @return EdgeAccessor* if it exists, nullptr otherwise.
*/
auto get_edge = [&edges_indexed](
const VertexAccessor &first,
const VertexAccessor &second) -> EdgeAccessor *{
auto cmp_edge_to_pair =
[](const EdgeAccessor *edge,
const pair<const VertexAccessor *, const VertexAccessor *> &e)
-> bool {
if (edge->from() != *e.first) return edge->from() < *e.first;
if (edge->to() != *e.second) return edge->to() < *e.second;
return false;
};
const VertexAccessor &first,
const VertexAccessor &second) -> EdgeAccessor * {
auto cmp_edge_to_pair = [](
const EdgeAccessor *edge,
const pair<const VertexAccessor *, const VertexAccessor *> &e) -> bool {
if (edge->from() != *e.first) return edge->from() < *e.first;
if (edge->to() != *e.second) return edge->to() < *e.second;
return false;
};
auto pos = lower_bound(edges_indexed.begin(), edges_indexed.end(),
std::make_pair(&first, &second), cmp_edge_to_pair) -
edges_indexed.begin();
@ -178,20 +179,18 @@ bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args,
* @param V index of clique vertices in vertices_indexed.
* @return score if profile_index exists, else 0.
*/
auto calc_score =
[&db_accessor, &vertices, &profile_index, &vertices_indexed, &get_edge](
const std::vector<int> &V) -> int {
int res = 0;
if (profile_index == -1) return 0;
for (auto x : V) {
auto edge = get_edge(vertices[profile_index], *vertices_indexed[x]);
if (edge == nullptr) continue;
auto prop = TypedValue(edge->PropsAt(db_accessor.property("score")));
if (prop.type() == TypedValue::Type::Int)
res += prop.Value<int64_t>();
}
return res;
};
auto calc_score = [&db_accessor, &vertices, &profile_index, &vertices_indexed,
&get_edge](const std::vector<int> &V) -> int {
int res = 0;
if (profile_index == -1) return 0;
for (auto x : V) {
auto edge = get_edge(vertices[profile_index], *vertices_indexed[x]);
if (edge == nullptr) continue;
auto prop = TypedValue(edge->PropsAt(db_accessor.property("score")));
if (prop.type() == TypedValue::Type::Int) res += prop.Value<int64_t>();
}
return res;
};
if (query_type == CliqueQuery::SCORE_AND_LIMIT) {
auto cmp_results = [&calc_score](const std::vector<int> &first,
const std::vector<int> &second) {
@ -207,15 +206,15 @@ bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args,
std::vector<TypedValue> result;
for (auto x : results[i]) {
result.push_back(vertices_indexed[x]
->PropsAt(db_accessor.property("garment_id"))
.Value<int64_t>());
->PropsAt(db_accessor.property("garment_id"))
.Value<int64_t>());
}
if (query_type == CliqueQuery::SCORE_AND_LIMIT)
result.push_back(calc_score(results[i]));
stream.Result(result);
}
std::map<std::string, TypedValue> meta{std::make_pair(std::string("type"), TypedValue(std::string("r")))};
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("r")))};
stream.Summary(meta);
db_accessor.commit();
return true;
}

View File

@ -1,11 +1,11 @@
#include <iostream>
#include <string>
#include "query/parameters.hpp"
#include "query/plan_interface.hpp"
#include "storage/edge_accessor.hpp"
#include "storage/vertex_accessor.hpp"
#include "using.hpp"
#include "query/parameters.hpp"
using std::cout;
using std::endl;
@ -26,9 +26,9 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Header(headers);
std::vector<TypedValue> result{TypedValue(v)};
stream.Result(result);
std::map<std::string, TypedValue> meta{std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
db_accessor.commit();
return true;
}

View File

@ -1,11 +1,11 @@
#include <iostream>
#include <string>
#include "query/parameters.hpp"
#include "query/plan_interface.hpp"
#include "storage/edge_accessor.hpp"
#include "storage/vertex_accessor.hpp"
#include "using.hpp"
#include "query/parameters.hpp"
using std::cout;
using std::endl;
@ -24,9 +24,9 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Header(headers);
std::vector<TypedValue> result{TypedValue(v)};
stream.Result(result);
std::map<std::string, TypedValue> meta{std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
db_accessor.commit();
return true;
}

View File

@ -1,11 +1,11 @@
#include <iostream>
#include <string>
#include "query/parameters.hpp"
#include "query/plan_interface.hpp"
#include "storage/edge_accessor.hpp"
#include "storage/vertex_accessor.hpp"
#include "using.hpp"
#include "query/parameters.hpp"
using std::cout;
using std::endl;
@ -26,9 +26,9 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Header(headers);
std::vector<TypedValue> result{TypedValue(v)};
stream.Result(result);
std::map<std::string, TypedValue> meta{std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
db_accessor.commit();
return true;
}

View File

@ -1,11 +1,11 @@
#include <iostream>
#include <string>
#include "query/parameters.hpp"
#include "query/plan_interface.hpp"
#include "storage/edge_accessor.hpp"
#include "storage/vertex_accessor.hpp"
#include "using.hpp"
#include "query/parameters.hpp"
using std::cout;
using std::endl;
@ -24,9 +24,9 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Header(headers);
std::vector<TypedValue> result{TypedValue(v)};
stream.Result(result);
std::map<std::string, TypedValue> meta{std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
db_accessor.commit();
return true;
}

View File

@ -1,11 +1,11 @@
#include <iostream>
#include <string>
#include "query/parameters.hpp"
#include "query/plan_interface.hpp"
#include "storage/edge_accessor.hpp"
#include "storage/vertex_accessor.hpp"
#include "using.hpp"
#include "query/parameters.hpp"
using std::cout;
using std::endl;
@ -26,9 +26,9 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Header(headers);
std::vector<TypedValue> result{TypedValue(v)};
stream.Result(result);
std::map<std::string, TypedValue> meta{std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
db_accessor.commit();
return true;
}

View File

@ -1,11 +1,11 @@
#include <iostream>
#include <string>
#include "query/parameters.hpp"
#include "query/plan_interface.hpp"
#include "storage/edge_accessor.hpp"
#include "storage/vertex_accessor.hpp"
#include "using.hpp"
#include "query/parameters.hpp"
using std::cout;
using std::endl;
@ -26,9 +26,9 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Header(headers);
std::vector<TypedValue> result{TypedValue(v)};
stream.Result(result);
std::map<std::string, TypedValue> meta{std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
db_accessor.commit();
return true;
}

View File

@ -2,10 +2,10 @@
#include <string>
#include "query/backend/cpp/typed_value.hpp"
#include "query/parameters.hpp"
#include "query/plan_interface.hpp"
#include "query/stripped.hpp"
#include "using.hpp"
#include "query/parameters.hpp"
using std::cout;
using std::endl;
@ -19,9 +19,9 @@ class CPUPlan : public PlanInterface<Stream> {
for (auto v : db_accessor.vertices()) db_accessor.detach_remove_vertex(v);
std::vector<std::string> headers;
stream.Header(headers);
std::map<std::string, TypedValue> meta{std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
db_accessor.commit();
return true;
}

View File

@ -2,11 +2,11 @@
#include <string>
#include "query/backend/cpp/typed_value.hpp"
#include "query/parameters.hpp"
#include "query/plan_interface.hpp"
#include "storage/edge_accessor.hpp"
#include "storage/vertex_accessor.hpp"
#include "using.hpp"
#include "query/parameters.hpp"
using std::cout;
using std::endl;
@ -30,9 +30,9 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Result(result);
}
}
std::map<std::string, TypedValue> meta{std::make_pair(std::string("type"), TypedValue(std::string("r")))};
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("r")))};
stream.Summary(meta);
db_accessor.commit();
return true;
}
~CPUPlan() {}

View File

@ -2,11 +2,11 @@
#include <string>
#include "query/backend/cpp/typed_value.hpp"
#include "query/parameters.hpp"
#include "query/plan_interface.hpp"
#include "storage/edge_accessor.hpp"
#include "storage/vertex_accessor.hpp"
#include "using.hpp"
#include "query/parameters.hpp"
using std::cout;
using std::endl;
@ -48,9 +48,9 @@ class CPUPlan : public PlanInterface<Stream> {
std::vector<TypedValue> result{TypedValue(e)};
stream.Result(result);
}
std::map<std::string, TypedValue> meta{std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
db_accessor.commit();
return true;
}

View File

@ -2,8 +2,8 @@
#include <string>
#include "query/backend/cpp/typed_value.hpp"
#include "query/plan_interface.hpp"
#include "query/parameters.hpp"
#include "query/plan_interface.hpp"
#include "storage/edge_accessor.hpp"
#include "storage/vertex_accessor.hpp"
#include "using.hpp"
@ -14,9 +14,8 @@ using std::endl;
// General query type: MATCH (g:garment {garment_id: 1234}) SET g:'GENERAL'
// RETURN g
bool run_general_query(GraphDbAccessor &db_accessor,
const Parameters &args, Stream &stream,
const std::string &general_label) {
bool run_general_query(GraphDbAccessor &db_accessor, const Parameters &args,
Stream &stream, const std::string &general_label) {
std::vector<std::string> headers{std::string("g")};
stream.Header(headers);
for (auto vertex : db_accessor.vertices()) {
@ -31,8 +30,8 @@ bool run_general_query(GraphDbAccessor &db_accessor,
stream.Result(result);
}
}
std::map<std::string, TypedValue> meta{std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
db_accessor.commit();
return true;
}

View File

@ -2,11 +2,11 @@
#include <string>
#include "query/backend/cpp/typed_value.hpp"
#include "query/parameters.hpp"
#include "query/plan_interface.hpp"
#include "storage/edge_accessor.hpp"
#include "storage/vertex_accessor.hpp"
#include "using.hpp"
#include "query/parameters.hpp"
using std::cout;
using std::endl;
@ -36,9 +36,9 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Result(result);
}
}
std::map<std::string, TypedValue> meta{std::make_pair(std::string("type"), TypedValue(std::string("r")))};
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("r")))};
stream.Summary(meta);
db_accessor.commit();
return true;
}
~CPUPlan() {}

View File

@ -2,12 +2,12 @@
#include <string>
#include "query/backend/cpp/typed_value.hpp"
#include "query/parameters.hpp"
#include "query/plan_interface.hpp"
#include "query/stripped.hpp"
#include "storage/edge_accessor.hpp"
#include "storage/vertex_accessor.hpp"
#include "using.hpp"
#include "query/parameters.hpp"
using std::cout;
using std::endl;
@ -51,9 +51,9 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Result(result);
}
}
std::map<std::string, TypedValue> meta{std::make_pair(std::string("type"), TypedValue(std::string("r")))};
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("r")))};
stream.Summary(meta);
db_accessor.commit();
return true;
}

View File

@ -2,11 +2,11 @@
#include <string>
#include "query/backend/cpp/typed_value.hpp"
#include "query/parameters.hpp"
#include "query/plan_interface.hpp"
#include "storage/edge_accessor.hpp"
#include "storage/vertex_accessor.hpp"
#include "using.hpp"
#include "query/parameters.hpp"
using std::cout;
using std::endl;
@ -55,9 +55,9 @@ class CPUPlan : public PlanInterface<Stream> {
std::vector<TypedValue> result{TypedValue(e)};
stream.Result(result);
}
std::map<std::string, TypedValue> meta{std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
db_accessor.commit();
return true;
}

View File

@ -2,11 +2,11 @@
#include <string>
#include "query/backend/cpp/typed_value.hpp"
#include "query/parameters.hpp"
#include "query/plan_interface.hpp"
#include "storage/edge_accessor.hpp"
#include "storage/vertex_accessor.hpp"
#include "using.hpp"
#include "query/parameters.hpp"
using std::cout;
using std::endl;
@ -51,9 +51,9 @@ class CPUPlan : public PlanInterface<Stream> {
stream.Result(result);
}
}
std::map<std::string, TypedValue> meta{std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
std::map<std::string, TypedValue> meta{
std::make_pair(std::string("type"), TypedValue(std::string("rw")))};
stream.Summary(meta);
db_accessor.commit();
return true;
}

View File

@ -14,7 +14,6 @@ class CPUPlan : public PlanInterface<Stream> {
public:
bool run(GraphDbAccessor &db_accessor, const StrippedArguments &args,
Stream &stream) {
db_accessor.commit();
return true;
}