Query::Plan::Set - set ops API defined. ConsoleTest random graph generation modified
Reviewers: teon.banek, mislav.bradac, buda Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D190
This commit is contained in:
parent
d9500337f2
commit
7b81b2b132
@ -30,10 +30,14 @@ class EdgeFilter;
|
||||
class Filter;
|
||||
class Produce;
|
||||
class Delete;
|
||||
class SetProperty;
|
||||
class SetProperties;
|
||||
class SetLabels;
|
||||
|
||||
using LogicalOperatorVisitor =
|
||||
::utils::Visitor<CreateNode, CreateExpand, ScanAll, Expand, NodeFilter,
|
||||
EdgeFilter, Filter, Produce, Delete>;
|
||||
EdgeFilter, Filter, Produce, Delete, SetProperty,
|
||||
SetProperties, SetLabels>;
|
||||
|
||||
class LogicalOperator : public ::utils::Visitable<LogicalOperatorVisitor> {
|
||||
public:
|
||||
@ -809,5 +813,71 @@ class Delete : public LogicalOperator {
|
||||
// ignored when deleting edges
|
||||
bool detach_;
|
||||
};
|
||||
|
||||
class SetProperty : public LogicalOperator {
|
||||
public:
|
||||
SetProperty(const std::shared_ptr<LogicalOperator> input, PropertyLookup *lhs,
|
||||
Expression *rhs)
|
||||
: input_(input), lhs_(lhs), rhs_(rhs) {}
|
||||
|
||||
void Accept(LogicalOperatorVisitor &visitor) override {
|
||||
visitor.Visit(*this);
|
||||
input_->Accept(visitor);
|
||||
visitor.PostVisit(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<LogicalOperator> input_;
|
||||
PropertyLookup *lhs_;
|
||||
Expression *rhs_;
|
||||
};
|
||||
|
||||
class SetProperties : public LogicalOperator {
|
||||
public:
|
||||
/**
|
||||
* Defines how setting the properties works. UPDATE means
|
||||
* that the current property set is augmented with additional
|
||||
* ones (existing props of the same name are replaced), while
|
||||
* REPLACE means that the old props are discarded and replaced
|
||||
* with new ones.
|
||||
*/
|
||||
enum class Op { UPDATE, REPLACE };
|
||||
|
||||
SetProperties(const std::shared_ptr<LogicalOperator> input,
|
||||
const Symbol input_symbol, Expression *rhs, Op op)
|
||||
: input_(input), input_symbol_(input_symbol), rhs_(rhs), op_(op) {}
|
||||
|
||||
void Accept(LogicalOperatorVisitor &visitor) override {
|
||||
visitor.Visit(*this);
|
||||
input_->Accept(visitor);
|
||||
visitor.PostVisit(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<LogicalOperator> input_;
|
||||
const Symbol input_symbol_;
|
||||
Expression *rhs_;
|
||||
Op op_;
|
||||
};
|
||||
|
||||
class SetLabels : public LogicalOperator {
|
||||
public:
|
||||
SetLabels(const std::shared_ptr<LogicalOperator> input,
|
||||
const Symbol input_symbol,
|
||||
const std::vector<GraphDb::Label> &labels)
|
||||
: input_(input), input_symbol_(input_symbol), labels_(labels) {}
|
||||
|
||||
void Accept(LogicalOperatorVisitor &visitor) override {
|
||||
visitor.Visit(*this);
|
||||
input_->Accept(visitor);
|
||||
visitor.PostVisit(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<LogicalOperator> input_;
|
||||
const Symbol input_symbol_;
|
||||
std::vector<GraphDb::Label> labels_;
|
||||
};
|
||||
|
||||
} // namespace plan
|
||||
} // namespace query
|
||||
|
@ -5,14 +5,17 @@
|
||||
#include "query/interpreter.hpp"
|
||||
#include "utils/random_graph_generator.hpp"
|
||||
|
||||
void random_generate(Dbms &dbms) {
|
||||
void random_generate(Dbms &dbms, uint node_count, int edge_factor = 5) {
|
||||
auto dba = dbms.active();
|
||||
utils::RandomGraphGenerator generator(*dba);
|
||||
|
||||
generator.AddVertices(1000000, {"Person"});
|
||||
generator.AddEdges(5000000, "Friend");
|
||||
generator.SetVertexProperty<int>(1000000, "age", utils::RandomIntGenerator(3, 60));
|
||||
generator.SetVertexProperty<int>(1000000, "height", utils::RandomIntGenerator(120, 200));
|
||||
auto edge_count = node_count * edge_factor;
|
||||
generator.AddVertices(node_count, {"Person"});
|
||||
generator.AddEdges(edge_count, "Friend");
|
||||
generator.SetVertexProperty<int>(node_count, "age",
|
||||
utils::RandomIntGenerator(3, 60));
|
||||
generator.SetVertexProperty<int>(node_count, "height",
|
||||
utils::RandomIntGenerator(120, 200));
|
||||
|
||||
generator.Commit();
|
||||
}
|
||||
@ -75,10 +78,18 @@ void fill_db(Dbms &dbms) {
|
||||
int main(int argc, char *argv[]) {
|
||||
REGISTER_ARGS(argc, argv);
|
||||
|
||||
// parse the first cmd line argument as the count of nodes to randomly create
|
||||
uint node_count = 100000;
|
||||
if (argc > 1) {
|
||||
node_count = (uint) std::stoul(argv[1]);
|
||||
permanent_assert(node_count < 10000000,
|
||||
"More then 10M nodes requested, that's too much");
|
||||
}
|
||||
|
||||
Dbms dbms;
|
||||
std::cout << "Generating graph..." << std::endl;
|
||||
// fill_db(dbms);
|
||||
random_generate(dbms);
|
||||
// fill_db(dbms);
|
||||
random_generate(dbms, node_count);
|
||||
query::Repl(dbms);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user