memgraph/tests/integration/hardcoded_query/match_profile.cpp
florijan 971e006d13 Query stripping now uses a parse tree and differentiates between int literals in a range expression (not stripped) and outside of a range (stripped).
Summary: See above

Reviewers: buda, mislav.bradac

Reviewed By: mislav.bradac

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D98
2017-03-08 14:19:55 +01:00

47 lines
1.5 KiB
C++

#include <iostream>
#include <string>
#include "query/backend/cpp/typed_value.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;
// Query: MATCH (p:profile {profile_id: 112, partner_id: 77}) RETURN p
class CPUPlan : public PlanInterface<Stream> {
public:
bool run(GraphDbAccessor &db_accessor, const Parameters &args,
Stream &stream) {
stream.write_field("p");
for (auto vertex : db_accessor.vertices()) {
if (vertex.has_label(db_accessor.label("profile"))) {
TypedValue prop = vertex.PropsAt(db_accessor.property("profile_id"));
if (prop.type() == TypedValue::Type::Null) continue;
auto cmp = prop == args.At(0);
if (cmp.type() != TypedValue::Type::Bool) continue;
if (cmp.Value<bool>() != true) continue;
TypedValue prop2 = vertex.PropsAt(db_accessor.property("partner_id"));
if (prop2.type() == TypedValue::Type::Null) continue;
auto cmp2 = prop2 == args.At(1);
if (cmp2.type() != TypedValue::Type::Bool) continue;
if (cmp2.Value<bool>() != true) continue;
stream.write_vertex_record(vertex);
}
}
stream.write_meta("r");
db_accessor.commit();
return true;
}
~CPUPlan() {}
};
extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }