2017-03-23 21:45:51 +08:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "dbms/dbms.hpp"
|
|
|
|
#include "query/console.hpp"
|
|
|
|
#include "query/interpreter.hpp"
|
2017-03-24 17:23:18 +08:00
|
|
|
#include "utils/random_graph_generator.hpp"
|
|
|
|
|
2017-06-01 18:09:18 +08:00
|
|
|
#include "logging/default.hpp"
|
|
|
|
#include "logging/streams/stdout.hpp"
|
|
|
|
|
2017-03-28 15:27:13 +08:00
|
|
|
void random_generate(Dbms &dbms, uint node_count, int edge_factor = 5) {
|
2017-03-24 17:23:18 +08:00
|
|
|
auto dba = dbms.active();
|
|
|
|
utils::RandomGraphGenerator generator(*dba);
|
|
|
|
|
2017-03-28 15:27:13 +08:00
|
|
|
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));
|
2017-03-24 17:23:18 +08:00
|
|
|
|
|
|
|
generator.Commit();
|
|
|
|
}
|
2017-03-23 21:45:51 +08:00
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
REGISTER_ARGS(argc, argv);
|
|
|
|
|
2017-03-28 15:27:13 +08:00
|
|
|
// parse the first cmd line argument as the count of nodes to randomly create
|
2017-06-01 18:09:18 +08:00
|
|
|
uint node_count = 0;
|
2017-03-28 15:27:13 +08:00
|
|
|
if (argc > 1) {
|
|
|
|
node_count = (uint) std::stoul(argv[1]);
|
|
|
|
permanent_assert(node_count < 10000000,
|
|
|
|
"More then 10M nodes requested, that's too much");
|
|
|
|
}
|
|
|
|
|
2017-06-01 18:09:18 +08:00
|
|
|
// TODO switch to GFlags, once finally available
|
|
|
|
if (argc > 2) {
|
|
|
|
logging::init_sync();
|
|
|
|
logging::log->pipe(std::make_unique<Stdout>());
|
|
|
|
}
|
|
|
|
|
2017-03-23 21:45:51 +08:00
|
|
|
Dbms dbms;
|
2017-03-24 17:23:18 +08:00
|
|
|
std::cout << "Generating graph..." << std::endl;
|
2017-03-28 15:27:13 +08:00
|
|
|
// fill_db(dbms);
|
|
|
|
random_generate(dbms, node_count);
|
2017-03-24 16:49:56 +08:00
|
|
|
query::Repl(dbms);
|
2017-03-23 21:45:51 +08:00
|
|
|
return 0;
|
|
|
|
}
|