#include #include #include "query/parameters.hpp" #include "query/plan_interface.hpp" #include "query/typed_value.hpp" #include "storage/edge_accessor.hpp" #include "storage/vertex_accessor.hpp" #include "using.hpp" using std::cout; using std::endl; using query::TypedValue; // Query: CREATE (g:garment {garment_id: 1234, garment_category_id:1}) RETURN g class CPUPlan : public PlanInterface { public: bool run(GraphDbAccessor &db_accessor, const Parameters &args, Stream &stream) { auto v = db_accessor.InsertVertex(); v.add_label(db_accessor.Label("garment")); v.PropsSet(db_accessor.Property("garment_id"), args.At(0).second); v.PropsSet(db_accessor.Property("garment_category_id"), args.At(1).second); std::vector headers{std::string("g")}; stream.Header(headers); std::vector result{TypedValue(v)}; stream.Result(result); return true; } ~CPUPlan() {} }; extern "C" PlanInterface *produce() { return new CPUPlan(); } extern "C" void destruct(PlanInterface *p) { delete p; }