|
15 | 15 | #define GRAPH_ENABLE_STRICT \ |
16 | 16 | "schema.config().option('graph.schema_mode').set('production')" |
17 | 17 |
|
| 18 | +#define GRAPH_SCHEMA \ |
| 19 | + "schema.propertyKey('name').Text().ifNotExists().create();" \ |
| 20 | + "schema.propertyKey('age').Int().ifNotExists().create();" \ |
| 21 | + "schema.propertyKey('lang').Text().ifNotExists().create();" \ |
| 22 | + "schema.propertyKey('weight').Float().ifNotExists().create();" \ |
| 23 | + "schema.vertexLabel('person').properties('name', 'age').ifNotExists().create();" \ |
| 24 | + "schema.vertexLabel('software').properties('name', 'lang').ifNotExists().create();" \ |
| 25 | + "schema.edgeLabel('created').properties('weight').connection('person', 'software').ifNotExists().create();" \ |
| 26 | + "schema.edgeLabel('created').connection('software', 'software').add();" \ |
| 27 | + "schema.edgeLabel('knows').properties('weight').connection('person', 'person').ifNotExists().create();" |
| 28 | + |
| 29 | +#define GRAPH_DATA \ |
| 30 | + "Vertex marko = graph.addVertex(label, 'person', 'name', 'marko', 'age', 29);" \ |
| 31 | + "Vertex vadas = graph.addVertex(label, 'person', 'name', 'vadas', 'age', 27);" \ |
| 32 | + "Vertex lop = graph.addVertex(label, 'software', 'name', 'lop', 'lang', 'java');" \ |
| 33 | + "Vertex josh = graph.addVertex(label, 'person', 'name', 'josh', 'age', 32);" \ |
| 34 | + "Vertex ripple = graph.addVertex(label, 'software', 'name', 'ripple', 'lang', 'java');" \ |
| 35 | + "Vertex peter = graph.addVertex(label, 'person', 'name', 'peter', 'age', 35);" \ |
| 36 | + "marko.addEdge('knows', vadas, 'weight', 0.5f);" \ |
| 37 | + "marko.addEdge('knows', josh, 'weight', 1.0f);" \ |
| 38 | + "marko.addEdge('created', lop, 'weight', 0.4f);" \ |
| 39 | + "josh.addEdge('created', ripple, 'weight', 1.0f);" \ |
| 40 | + "josh.addEdge('created', lop, 'weight', 0.4f);" \ |
| 41 | + "peter.addEdge('created', lop, 'weight', 0.2f);" |
| 42 | + |
18 | 43 | DseIntegration::DseIntegration() |
19 | 44 | : Integration() |
20 | 45 | , dse_session_() {} |
@@ -42,27 +67,37 @@ void DseIntegration::connect() { |
42 | 67 | void DseIntegration::create_graph(const std::string& graph_name, |
43 | 68 | const std::string& replication_strategy, |
44 | 69 | const std::string& duration) { |
45 | | - // Create the graph statement using the pre-determined replication config |
46 | | - test::driver::DseGraphObject graph_object; |
47 | | - graph_object.add<std::string>("name", graph_name); |
48 | | - graph_object.add<std::string>("replication", replication_strategy); |
49 | | - graph_object.add<std::string>("duration", duration); |
50 | | - test::driver::DseGraphStatement graph_statement(GRAPH_CREATE); |
51 | | - graph_statement.bind(graph_object); |
52 | | - CHECK_FAILURE; |
| 70 | + // Create the graph statement using the pre-determined replication config |
| 71 | + test::driver::DseGraphObject graph_object; |
| 72 | + graph_object.add<std::string>("name", graph_name); |
| 73 | + graph_object.add<std::string>("replication", replication_strategy); |
| 74 | + graph_object.add<std::string>("duration", duration); |
| 75 | + test::driver::DseGraphStatement graph_statement(GRAPH_CREATE); |
| 76 | + graph_statement.bind(graph_object); |
| 77 | + CHECK_FAILURE; |
53 | 78 |
|
54 | | - // Execute the graph statement and ensure it was created |
55 | | - dse_session_.execute(graph_statement); |
56 | | - CHECK_FAILURE; |
| 79 | + // Execute the graph statement and ensure it was created |
| 80 | + dse_session_.execute(graph_statement); |
| 81 | + CHECK_FAILURE; |
57 | 82 |
|
58 | | - // Enable testing functionality for the graph |
59 | | - test::driver::DseGraphOptions options; |
60 | | - options.set_name(graph_name); |
61 | | - dse_session_.execute(GRAPH_ALLOW_SCANS, options); |
62 | | - CHECK_FAILURE; |
63 | | - dse_session_.execute(GRAPH_ENABLE_STRICT, options); |
64 | | - CHECK_FAILURE; |
65 | | - } |
| 83 | + // Enable testing functionality for the graph |
| 84 | + test::driver::DseGraphOptions options; |
| 85 | + options.set_name(graph_name); |
| 86 | + dse_session_.execute(GRAPH_ALLOW_SCANS, options); |
| 87 | + CHECK_FAILURE; |
| 88 | + dse_session_.execute(GRAPH_ENABLE_STRICT, options); |
| 89 | + CHECK_FAILURE; |
| 90 | +} |
| 91 | + |
| 92 | +void DseIntegration::populate_classic_graph(const std::string& graph_name) { |
| 93 | + // Initialize the graph pre-populated data |
| 94 | + test::driver::DseGraphOptions options; |
| 95 | + options.set_name(graph_name); |
| 96 | + dse_session_.execute(GRAPH_SCHEMA, options); |
| 97 | + CHECK_FAILURE; |
| 98 | + dse_session_.execute(GRAPH_DATA, options); |
| 99 | + CHECK_FAILURE; |
| 100 | +} |
66 | 101 |
|
67 | 102 | void DseIntegration::create_graph(const std::string& duration /*= "PT30S"*/) { |
68 | 103 | create_graph(test_name_, replication_strategy_, duration); |
|
0 commit comments