Update template.

Summary: Delete old implementations. Update template

Reviewers: buda

Reviewed By: buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D72
This commit is contained in:
Dominik Gleich 2017-02-27 13:51:54 +01:00
parent e74d9123b1
commit 1946ab6e07
17 changed files with 10 additions and 964 deletions

View File

@ -1,171 +0,0 @@
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include "query/plan_interface.hpp"
#include "query/util.hpp"
#include "storage/edge_x_vertex.hpp"
#include "storage/model/properties/all.hpp"
#include "storage/vertex_accessor.hpp"
#include "using.hpp"
#include "utils/memory/stack_allocator.hpp"
using std::cout;
using std::endl;
// Dressipi astar query of 4 clicks.
// Query: MATCH
// (a:garment)-[:default_outfit]-(b:garment)-[:default_outfit]-(c:garment)-[:default_outfit]-(d:garment)-[:default_outfit]-(a:garment)-[:default_outfit]-(c:garment),
// (b:garment)-[:default_outfit]-(d:garment) RETURN
// a.garment_id,b.garment_id,c.garment_id,d.garment_id
// TODO: figure out from the pattern in a query
constexpr size_t max_depth = 3;
// TODO: from query LIMIT 10
constexpr size_t limit = 10;
class Node {
public:
Node *parent = {nullptr};
VertexPropertyType<Float> tkey;
double cost;
int depth = {0};
double sum = {0.0};
VertexAccessor vacc;
Node(VertexAccessor vacc, double cost, VertexPropertyType<Float> const &tkey)
: cost(cost), vacc(vacc), tkey(tkey) {}
Node(VertexAccessor vacc, double cost, Node *parent,
VertexPropertyType<Float> const &tkey)
: cost(cost),
vacc(vacc),
parent(parent),
depth(parent->depth + 1),
tkey(tkey) {}
double sum_vertex_score() {
auto now = this;
double sum = 0;
do {
sum += (now->vacc.at(tkey).get())->value();
now = now->parent;
} while (now != nullptr);
this->sum = sum;
return sum;
}
};
bool vertex_filter_contained(DbAccessor &t, VertexAccessor &v, Node *before) {
if (v.fill()) {
bool found;
do {
found = false;
before = before->parent;
if (before == nullptr) {
return true;
}
} while (v.in_contains(before->vacc));
}
return false;
}
template <typename Stream>
auto astar(VertexAccessor &va, DbAccessor &t, plan_args_t &, Stream &) {
StackAllocator stack;
std::vector<Node *> results;
// TODO: variable part (extract)
VertexPropertyType<Float> tkey = t.vertex_property_key<Float>("score");
auto cmp = [](Node *left, Node *right) { return left->cost > right->cost; };
std::priority_queue<Node *, std::vector<Node *>, decltype(cmp)> queue(cmp);
Node *start = new (stack.allocate<Node>()) Node(va, 0, tkey);
queue.push(start);
size_t count = 0;
do {
auto now = queue.top();
queue.pop();
if (now->depth >= max_depth) {
now->sum_vertex_score();
results.emplace_back(now);
count++;
if (count >= limit) {
// the limit was reached -> STOP the execution
break;
}
// if the limit wasn't reached -> POP the next vertex
continue;
}
iter::for_all(now->vacc.out(), [&](auto edge) {
VertexAccessor va = edge.to();
if (vertex_filter_contained(t, va, now)) {
auto cost = 1 - va.at(tkey).get()->value();
Node *n =
new (stack.allocate<Node>()) Node(va, now->cost + cost, now, tkey);
queue.push(n);
}
});
} while (!queue.empty());
stack.free();
return results;
}
void reverse_stream_ids(Node *node, Stream &stream, VertexPropertyKey key) {
if (node == nullptr) return;
reverse_stream_ids(node->parent, stream, key);
stream.write(node->vacc.at(key).template as<Int64>());
}
class PlanCPU : public PlanInterface<Stream> {
public:
bool run(Db &db, const PlanArgsT &args, Stream &stream) override {
DbAccessor t(db);
indices_t indices = {{"garment_id", 0}};
auto properties = query_properties(indices, args);
auto &label = t.label_find_or_create("garment");
auto garment_id_prop_key =
t.vertex_property_key("garment_id", args[0].key.flags());
stream.write_fields(
{{"a.garment_id", "b.garment_id", "c.garment_id", "d.garment_id"}});
label.index()
.for_range(t)
.properties_filter(t, properties)
.for_all([&](auto va) {
auto results = astar(va, t, args, stream);
std::sort(results.begin(), results.end(),
[](Node *a, Node *b) { return a->sum > b->sum; });
for (auto node : results) {
stream.write_record();
stream.write_list_header(max_depth + 1);
reverse_stream_ids(node, stream, garment_id_prop_key);
}
});
stream.write_empty_fields();
stream.write_meta("r");
return t.commit();
}
~PlanCPU() {}
};
extern "C" PlanInterface<Stream> *produce() { return new PlanCPU(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }

View File

@ -1,49 +0,0 @@
#include <iostream>
#include <string>
#include "query/plan_interface.hpp"
#include "query/util.hpp"
#include "storage/edge_x_vertex.hpp"
#include "storage/model/properties/all.hpp"
#include "using.hpp"
using std::cout;
using std::endl;
// Query: CREATE (n:ACCOUNT {id: 2322, name: "TEST", country: "Croatia",
// "created_at": 2352352}) RETURN n
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(Db &db, const PlanArgsT &args, Stream &stream) override {
DbAccessor t(db);
auto prop_id = t.vertex_property_key("id", args[0].key.flags());
auto prop_name = t.vertex_property_key("name", args[1].key.flags());
auto prop_country = t.vertex_property_key("country", args[2].key.flags());
auto prop_created =
t.vertex_property_key("created_at", args[3].key.flags());
auto &label = t.label_find_or_create("ACCOUNT");
auto vertex_accessor = t.vertex_insert();
vertex_accessor.set(prop_id, std::move(args[0]));
vertex_accessor.set(prop_name, std::move(args[1]));
vertex_accessor.set(prop_country, std::move(args[2]));
vertex_accessor.set(prop_created, std::move(args[3]));
vertex_accessor.add_label(label);
stream.write_field("p");
stream.write_vertex_record(vertex_accessor);
stream.write_meta("w");
return t.commit();
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }

View File

@ -1,43 +0,0 @@
#include <iostream>
#include <string>
#include "query/plan_interface.hpp"
#include "query/util.hpp"
#include "storage/edge_x_vertex.hpp"
#include "storage/model/properties/all.hpp"
#include "using.hpp"
using std::cout;
using std::endl;
// Query: MATCH (a {id:0}), (p {id: 1}) CREATE (a)-[r:IS]->(p) RETURN r
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(Db &db, const PlanArgsT &args, Stream &stream) override {
DbAccessor t(db);
auto &edge_type = t.type_find_or_create("IS");
auto v1 = t.vertex_find(args[0].as<Int64>().value());
if (!option_fill(v1)) return t.commit(), false;
auto v2 = t.vertex_find(args[1].as<Int64>().value());
if (!option_fill(v2)) return t.commit(), false;
auto edge_accessor = t.edge_insert(v1.get(), v2.get());
edge_accessor.edge_type(edge_type);
stream.write_field("r");
stream.write_edge_record(edge_accessor);
stream.write_meta("w");
return t.commit();
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }

View File

@ -1,39 +0,0 @@
#include <iostream>
#include <string>
#include "query/plan_interface.hpp"
#include "query/util.hpp"
#include "storage/edge_x_vertex.hpp"
#include "storage/model/properties/all.hpp"
#include "using.hpp"
using std::cout;
using std::endl;
// Query: CREATE (n:LABEL {name: "TEST"}) RETURN n
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(Db &db, const PlanArgsT &args, Stream &stream) override {
DbAccessor t(db);
auto property_key = t.vertex_property_key("name", args[0].key.flags());
auto &label = t.label_find_or_create("LABEL");
auto vertex_accessor = t.vertex_insert();
vertex_accessor.set(property_key, std::move(args[0]));
vertex_accessor.add_label(label);
stream.write_field("n");
stream.write_vertex_record(vertex_accessor);
stream.write_meta("w");
return t.commit();
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }

View File

@ -1,39 +0,0 @@
#include <iostream>
#include <string>
#include "query/plan_interface.hpp"
#include "query/util.hpp"
#include "storage/edge_x_vertex.hpp"
#include "storage/model/properties/all.hpp"
#include "using.hpp"
using std::cout;
using std::endl;
// Query: CREATE (n:OTHER {name: "cleaner_test"}) RETURN n
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(Db &db, const PlanArgsT &args, Stream &stream) override {
DbAccessor t(db);
auto property_key = t.vertex_property_key("name", args[0].key.flags());
auto &label = t.label_find_or_create("OTHER");
auto vertex_accessor = t.vertex_insert();
vertex_accessor.set(property_key, std::move(args[0]));
vertex_accessor.add_label(label);
stream.write_field("n");
stream.write_vertex_record(vertex_accessor);
stream.write_meta("w");
return t.commit();
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }

View File

@ -1,37 +0,0 @@
#include <iostream>
#include <string>
#include "query/plan_interface.hpp"
#include "query/util.hpp"
#include "storage/edge_x_vertex.hpp"
#include "storage/model/properties/all.hpp"
#include "using.hpp"
using std::cout;
using std::endl;
// Query: CREATE (n {prop: 0}) RETURN n
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(Db &db, const PlanArgsT &args, Stream &stream) override {
DbAccessor t(db);
auto property_key = t.vertex_property_key("prop", args[0].key.flags());
auto vertex_accessor = t.vertex_insert();
vertex_accessor.set(property_key, std::move(args[0]));
stream.write_field("n");
stream.write_vertex_record(vertex_accessor);
stream.write_meta("w");
return t.commit();
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }

View File

@ -1,33 +0,0 @@
#include <iostream>
#include <string>
#include "query/plan_interface.hpp"
#include "query/util.hpp"
#include "storage/model/properties/all.hpp"
#include "using.hpp"
using std::cout;
using std::endl;
// Query: MATCH (n) DETACH DELETE n
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(Db &db, const PlanArgsT &args, Stream &stream) override {
DbAccessor t(db);
t.edge_access().fill().for_all([&](auto e) { e.remove(); });
t.vertex_access().fill().isolated().for_all([&](auto a) { a.remove(); });
stream.write_empty_fields();
stream.write_meta("w");
return t.commit();
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }

View File

@ -1,40 +0,0 @@
#include <iostream>
#include <string>
#include "query/plan_interface.hpp"
#include "query/util.hpp"
#include "storage/model/properties/all.hpp"
#include "using.hpp"
using std::cout;
using std::endl;
// Query: MATCH (p:garment {garment_id: 1}) DELETE g
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(Db &db, const PlanArgsT &args, Stream &stream) override {
DbAccessor t(db);
indices_t indices = {{"garment_id", 0}};
auto properties = query_properties(indices, args);
auto &label = t.label_find_or_create("garment");
label.index()
.for_range(t)
.properties_filter(t, properties)
.for_all([&](auto va) { va.remove(); });
stream.write_empty_fields();
stream.write_meta("w");
return t.commit();
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }

View File

@ -1,40 +0,0 @@
#include <iostream>
#include <string>
#include "query/plan_interface.hpp"
#include "query/util.hpp"
#include "storage/model/properties/all.hpp"
#include "using.hpp"
using std::cout;
using std::endl;
// Query: MATCH (p:profile {profile_id: 1}) DELETE p
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(Db &db, const PlanArgsT &args, Stream &stream) override {
DbAccessor t(db);
indices_t indices = {{"profile_id", 0}};
auto properties = query_properties(indices, args);
auto &label = t.label_find_or_create("profile");
label.index()
.for_range(t)
.properties_filter(t, properties)
.for_all([&](auto va) { va.remove(); });
stream.write_empty_fields();
stream.write_meta("w");
return t.commit();
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }

View File

@ -1,82 +0,0 @@
#include <iostream>
#include <string>
#include "query/plan_interface.hpp"
#include "query/util.hpp"
#include "storage/edge_x_vertex.hpp"
#include "storage/model/properties/all.hpp"
#include "using.hpp"
using std::cout;
using std::endl;
// Query: MATCH (p:profile {profile_id: 111,
// partner_id:55})-[s:score]-(g:garment {garment_id: 1234}) DELETE s
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(Db &db, const PlanArgsT &args, Stream &stream) override {
DbAccessor t(db);
auto &profile = t.label_find_or_create("profile");
auto &score = t.type_find_or_create("score");
auto &garment = t.label_find_or_create("garment");
indices_t profile_ind = {{"profile_id", 0}, {"partner_id", 1}};
indices_t garment_ind = {{"garment_id", 2}};
auto profile_prop = query_properties(profile_ind, args);
auto garment_prop = query_properties(garment_ind, args);
auto score_key = t.edge_property_key("score", args[3].key.flags());
// TODO: decide path (which index is better)
// 3 options p->s->g, g->s->p, g<-s->p
// NOTE! both direections have to be chacked
// because pattern is non directional
// OR
// even better, use index on label and property
// just one option p->s->g!
Option<const EdgeAccessor> e1;
profile.index()
.for_range(t)
.properties_filter(t, profile_prop)
.out()
.type(score)
.clone_to(e1)
.to()
.label(garment)
.properties_filter(t, garment_prop)
.for_all([&](auto va) -> void {
auto ea = e1.get().update();
ea.remove();
});
Option<const EdgeAccessor> e2;
profile.index()
.for_range(t)
.properties_filter(t, profile_prop)
.in()
.type(score)
.clone_to(e1)
.from()
.label(garment)
.properties_filter(t, garment_prop)
.for_all([&](auto va) -> void {
auto ea = e2.get().update();
ea.remove();
});
stream.write_empty_fields();
stream.write_meta("w");
return t.commit();
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }

View File

@ -1,80 +0,0 @@
#include <iostream>
#include <string>
#include "query/plan_interface.hpp"
#include "query/util.hpp"
#include "storage/edge_x_vertex.hpp"
#include "storage/model/properties/all.hpp"
#include "using.hpp"
using std::cout;
using std::endl;
// Query: MATCH (p:profile {profile_id: 111,
// partner_id:55})-[s:score]-(g:garment {garment_id: 1234}) SET s.score = 1550
// RETURN s.score
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(Db &db, const PlanArgsT &args, Stream &stream) override {
DbAccessor t(db);
auto &profile = t.label_find_or_create("profile");
auto &score = t.type_find_or_create("score");
auto &garment = t.label_find_or_create("garment");
indices_t profile_ind = {{"profile_id", 0}, {"partner_id", 1}};
indices_t garment_ind = {{"garment_id", 2}};
auto profile_prop = query_properties(profile_ind, args);
auto garment_prop = query_properties(garment_ind, args);
auto score_key = t.edge_property_key("score", args[3].key.flags());
// TODO: decide path (which index is better)
// 3 options p->s->g, g->s->p, g<-s->p
// NOTE! both direections have to be chacked
// because pattern is non directional
// OR
// even better, use index on label and property
// just one option p->s->g!
Option<const EdgeAccessor> e1;
profile.index()
.for_range(t)
.properties_filter(t, profile_prop)
.out()
.type(score)
.clone_to(e1)
.to()
.label(garment)
.properties_filter(t, garment_prop)
.for_all([&](auto va) -> void {
auto ea = e1.get().update();
ea.set(score_key, std::move(args[3]));
});
Option<const EdgeAccessor> e2;
profile.index()
.for_range(t)
.properties_filter(t, profile_prop)
.in()
.type(score)
.clone_to(e1)
.from()
.label(garment)
.properties_filter(t, garment_prop)
.for_all([&](auto va) -> void {
auto ea = e2.get().update();
ea.set(score_key, std::move(args[3]));
});
return t.commit();
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }

View File

@ -1,47 +0,0 @@
#include <iostream>
#include <string>
#include "query/plan_interface.hpp"
#include "query/util.hpp"
#include "storage/model/properties/all.hpp"
#include "using.hpp"
using std::cout;
using std::endl;
// Query: MATCH (g:garment {garment_id: 3456}) SET g.reveals = 50 RETURN g
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(Db &db, const PlanArgsT &args, Stream &stream) override {
DbAccessor t(db);
auto reveals_key = t.vertex_property_key("reveals", args[1].key.flags());
indices_t indices = {{"garment_id", 0}};
auto properties = query_properties(indices, args);
auto &label = t.label_find_or_create("garment");
stream.write_field("g");
label.index()
.for_range(t)
.properties_filter(t, properties)
.fill()
.for_all([&](auto va) {
va.set(reveals_key, args[1]);
stream.write_vertex_record(va);
});
stream.write_meta("w");
return t.commit();
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }

View File

@ -1,41 +0,0 @@
#include <iostream>
#include <string>
#include "query/plan_interface.hpp"
#include "query/util.hpp"
#include "storage/model/properties/all.hpp"
#include "using.hpp"
using std::cout;
using std::endl;
// Query: MATCH (p:profile {partner_id: 1}) RETURN p
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(Db &db, const PlanArgsT &args, Stream &stream) override {
DbAccessor t(db);
indices_t indices = {{"partner_id", 0}};
auto properties = query_properties(indices, args);
auto &label = t.label_find_or_create("profile");
stream.write_field("p");
label.index()
.for_range(t)
.properties_filter(t, properties)
.for_all([&](auto va) { stream.write_vertex_record(va); });
stream.write_meta("r");
return t.commit();
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }

View File

@ -1,41 +0,0 @@
#include <iostream>
#include <string>
#include "query/plan_interface.hpp"
#include "query/util.hpp"
#include "storage/model/properties/all.hpp"
#include "using.hpp"
using std::cout;
using std::endl;
// Query: MATCH (g:garment {garment_id: 1}) RETURN g
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(Db &db, const PlanArgsT &args, Stream &stream) override {
DbAccessor t(db);
indices_t indices = {{"garment_id", 0}};
auto properties = query_properties(indices, args);
auto &label = t.label_find_or_create("garment");
stream.write_field("g");
label.index()
.for_range(t)
.properties_filter(t, properties)
.for_all([&](auto va) -> void { stream.write_vertex_record(va); });
stream.write_meta("w");
return t.commit();
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }

View File

@ -1,65 +0,0 @@
#include <iostream>
#include <string>
#include "query/plan_interface.hpp"
#include "query/util.hpp"
#include "storage/model/properties/all.hpp"
#include "using.hpp"
using std::cout;
using std::endl;
// Query: MERGE (g1:garment {garment_id:1234})-[r:default_outfit]-(g2:garment
// {garment_id: 2345}) RETURN r
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(Db &db, const PlanArgsT &args, Stream &stream) override {
DbAccessor t(db);
// TODO: support for index on label and property
// prepare iterator for g1
indices_t indices_1 = {{"garment_id", 0}};
auto properties_1 = query_properties(indices_1, args);
auto &label_1 = t.label_find_or_create("garment");
auto it_vertex_1 =
label_1.index().for_range(t).properties_filter(t, properties_1);
// prepare iterator for g1
indices_t indices_2 = {{"garment_id", 1}};
auto properties_2 = query_properties(indices_2, args);
auto &label_2 = t.label_find_or_create("garment");
auto it_vertex_2 =
label_2.index().for_range(t).properties_filter(t, properties_2);
auto &edge_type = t.type_find_or_create("default_outfit");
// TODO: create g1 and g2 if don't exist
// TODO: figure out something better
stream.write_field("r");
it_vertex_1.fill().for_all([&](auto va1) -> void {
it_vertex_2.fill().for_all([&](auto va2) -> void {
auto edge_accessor = t.edge_insert(va1, va2);
edge_accessor.edge_type(edge_type);
stream.write_edge_record(edge_accessor);
});
});
stream.write_meta("w");
return t.commit();
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }

View File

@ -1,97 +0,0 @@
#include <iostream>
#include <string>
#include "query/plan_interface.hpp"
#include "query/util.hpp"
#include "storage/edge_x_vertex.hpp"
#include "storage/model/properties/all.hpp"
#include "using.hpp"
using std::cout;
using std::endl;
// Query: MERGE (p:profile {profile_id: 111, partner_id:
// 55})-[s:score]-(g.garment {garment_id: 1234}) SET s.score=1500 RETURN s
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(Db &db, const PlanArgsT &args, Stream &stream) override {
DbAccessor t(db);
auto &profile = t.label_find_or_create("profile");
auto &score = t.type_find_or_create("score");
auto &garment = t.label_find_or_create("garment");
indices_t profile_ind = {{"profile_id", 0}, {"partner_id", 1}};
indices_t garment_ind = {{"garment_id", 2}};
auto profile_prop = query_properties(profile_ind, args);
auto garment_prop = query_properties(garment_ind, args);
auto score_key = t.edge_property_key("score", args[3].key.flags());
stream.write_field("s");
// TODO: implement
bool exists = false;
Option<const EdgeAccessor> e1;
profile.index()
.for_range(t)
.properties_filter(t, profile_prop)
.out()
.type(score)
.clone_to(e1)
.to()
.label(garment)
.properties_filter(t, garment_prop)
.for_all([&](auto va) -> void {
exists = true;
auto ea = e1.get().update();
ea.set(score_key, args[3]);
stream.write_edge_record(ea);
});
Option<const EdgeAccessor> e2;
profile.index()
.for_range(t)
.properties_filter(t, profile_prop)
.in()
.type(score)
.clone_to(e1)
.from()
.label(garment)
.properties_filter(t, garment_prop)
.for_all([&](auto va) -> void {
exists = true;
auto ea = e2.get().update();
ea.set(score_key, args[3]);
stream.write_edge_record(ea);
});
if (!exists) {
auto it_vertex_garment =
garment.index().for_range(t).properties_filter(t, garment_prop);
auto it_vertex_profile =
profile.index().for_range(t).properties_filter(t, profile_prop);
it_vertex_profile.fill().for_all([&](auto va1) -> void {
it_vertex_garment.fill().for_all([&](auto va2) -> void {
auto ea = t.edge_insert(va1, va2);
ea.edge_type(score);
ea.set(score_key, args[3]);
stream.write_edge_record(ea);
});
});
}
stream.write_field("w");
return t.commit();
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }

View File

@ -1,10 +1,7 @@
#include <iostream>
#include <string>
#include "query/util.hpp"
#include "query/plan_interface.hpp"
#include "storage/model/properties/all.hpp"
#include "storage/edge_x_vertex.hpp"
#include "using.hpp"
using std::cout;
@ -12,24 +9,17 @@ using std::endl;
// Query:
class CPUPlan : public PlanInterface<Stream>
{
public:
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(GraphDbAccessor &db_accessor, const TypedValueStore<> &args,
Stream &stream) {
db_accessor.transaction_.commit();
return true;
}
bool run(Db &db, const PlanArgsT &args, Stream &stream) override
{
}
~CPUPlan() {}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream>* produce()
{
return new CPUPlan();
}
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream>* p)
{
delete p;
}
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }