memgraph/tests/integration/hardcoded_query/create_garment.cpp
Matej Ferencevic 5a5ffface3 Modified hardcoded queries to use new encoder.
Summary:
Removed old encoder.

Changed namespace from bolt to communication::bolt.

Removed old include from new encoder.

Added an empty message success to encoder.

Changed order in communication::Server.

Changed bolt session to use new encoder.

Merge remote-tracking branch 'origin/dev' into mg_hardcoded_queries

Fixed PrintRecordStream.

Reviewers: buda, dgleich

Reviewed By: buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D158
2017-03-22 17:09:22 +01:00

39 lines
1.2 KiB
C++

#include <iostream>
#include <string>
#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;
// Query: CREATE (g:garment {garment_id: 1234, garment_category_id:1}) RETURN g
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(GraphDbAccessor &db_accessor, const Parameters &args,
Stream &stream) {
auto v = db_accessor.insert_vertex();
v.add_label(db_accessor.label("garment"));
v.PropsSet(db_accessor.property("garment_id"), args.At(0));
v.PropsSet(db_accessor.property("garment_category_id"), args.At(1));
std::vector<std::string> headers{std::string("g")};
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")))};
stream.Summary(meta);
db_accessor.commit();
return true;
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }