2017-02-21 22:37:32 +08:00
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "query/plan_interface.hpp"
|
2017-02-23 21:19:52 +08:00
|
|
|
#include "storage/edge_accessor.hpp"
|
|
|
|
#include "storage/vertex_accessor.hpp"
|
2017-02-21 22:37:32 +08:00
|
|
|
#include "using.hpp"
|
2017-03-08 21:11:05 +08:00
|
|
|
#include "query/parameters.hpp"
|
2017-02-21 22:37:32 +08:00
|
|
|
|
|
|
|
using std::cout;
|
|
|
|
using std::endl;
|
|
|
|
|
2017-02-23 21:19:52 +08:00
|
|
|
// Query: CREATE (g:garment {garment_id: 1234, garment_category_id:1}) RETURN g
|
2017-02-21 22:37:32 +08:00
|
|
|
|
|
|
|
class CPUPlan : public PlanInterface<Stream> {
|
|
|
|
public:
|
2017-03-08 21:11:05 +08:00
|
|
|
bool run(GraphDbAccessor &db_accessor, const Parameters &args,
|
2017-02-21 22:37:32 +08:00
|
|
|
Stream &stream) {
|
2017-02-23 21:19:52 +08:00
|
|
|
auto v = db_accessor.insert_vertex();
|
|
|
|
v.add_label(db_accessor.label("garment"));
|
2017-03-08 21:11:05 +08:00
|
|
|
v.PropsSet(db_accessor.property("garment_id"), args.At(0));
|
|
|
|
v.PropsSet(db_accessor.property("garment_category_id"), args.At(1));
|
2017-02-23 21:19:52 +08:00
|
|
|
stream.write_field("g");
|
|
|
|
stream.write_vertex_record(v);
|
|
|
|
stream.write_meta("rw");
|
2017-03-06 21:17:55 +08:00
|
|
|
db_accessor.commit();
|
2017-02-24 18:27:54 +08:00
|
|
|
return true;
|
2017-02-21 22:37:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
~CPUPlan() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
|
|
|
|
|
|
|
|
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }
|