memgraph/tests/integration/hardcoded_query/match_all_n_detach_delete.cpp
Marko Budiselic 0fcda94162 Hardcoded query infrastructure - first concrete version - USEFUL FOR: POCs & pilots
Summary: Hardcoded query infrastructure - first concrete version - USEFUL FOR: POCs & pilots

Test Plan: manual + jenkins

Reviewers: sale, florijan

Reviewed By: florijan

Subscribers: pullbot, buda

Differential Revision: https://phabricator.memgraph.io/D45
2017-02-14 09:40:31 +01:00

44 lines
832 B
C++

#include <iostream>
#include <string>
#include "query/util.hpp"
#include "query/plan_interface.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;
}