use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.
the class TestCaptureSchemaTableEdges method testLoadTableLabels.
@Test
public void testLoadTableLabels() throws Exception {
Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "pieter");
Vertex car1 = this.sqlgGraph.addVertex(T.label, "Car", "name", "bmw");
person1.addEdge("drives", car1);
Vertex car2 = this.sqlgGraph.addVertex(T.label, "Car", "name", "toyota");
person1.addEdge("drives", car2);
Vertex bmw = this.sqlgGraph.addVertex(T.label, "Model", "name", "bmw");
car1.addEdge("model", bmw);
Vertex toyota = this.sqlgGraph.addVertex(T.label, "Model", "name", "toyota");
car2.addEdge("model", toyota);
this.sqlgGraph.tx().commit();
this.sqlgGraph.close();
try (SqlgGraph sqlgGraph = SqlgGraph.open(configuration)) {
Map<SchemaTable, Pair<Set<SchemaTable>, Set<SchemaTable>>> localTabels = sqlgGraph.getTopology().getTableLabels();
assertTrue(localTabels.containsKey(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "V_Person")));
assertTrue(localTabels.containsKey(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "V_Car")));
assertTrue(localTabels.containsKey(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "V_Model")));
Pair<Set<SchemaTable>, Set<SchemaTable>> person = localTabels.get(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "V_Person"));
assertEquals(0, person.getLeft().size());
assertEquals(1, person.getRight().size());
assertEquals(sqlgGraph.getSqlDialect().getPublicSchema() + ".E_drives", person.getRight().iterator().next().toString());
Pair<Set<SchemaTable>, Set<SchemaTable>> car = localTabels.get(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "V_Car"));
assertEquals(1, car.getLeft().size());
assertEquals(1, car.getRight().size());
assertEquals(sqlgGraph.getSqlDialect().getPublicSchema() + ".E_drives", car.getLeft().iterator().next().toString());
Pair<Set<SchemaTable>, Set<SchemaTable>> model = localTabels.get(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "V_Model"));
assertEquals(1, model.getLeft().size());
assertEquals(0, model.getRight().size());
assertEquals(sqlgGraph.getSqlDialect().getPublicSchema() + ".E_model", model.getLeft().iterator().next().toString());
}
}
use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.
the class TestCaptureSchemaTableEdges method testCaptureSchemaTableLabels.
@Test
public void testCaptureSchemaTableLabels() {
Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "pieter");
Vertex car1 = this.sqlgGraph.addVertex(T.label, "Car", "name", "bmw");
person1.addEdge("drives", car1);
Vertex car2 = this.sqlgGraph.addVertex(T.label, "Car", "name", "toyota");
person1.addEdge("drives", car2);
Vertex bmw = this.sqlgGraph.addVertex(T.label, "Model", "name", "bmw");
car1.addEdge("model", bmw);
Vertex toyota = this.sqlgGraph.addVertex(T.label, "Model", "name", "toyota");
car2.addEdge("model", toyota);
this.sqlgGraph.tx().commit();
Map<SchemaTable, Pair<Set<SchemaTable>, Set<SchemaTable>>> localTabels = this.sqlgGraph.getTopology().getTableLabels();
assertTrue(localTabels.containsKey(SchemaTable.of(this.sqlgGraph.getSqlDialect().getPublicSchema(), "V_Person")));
assertTrue(localTabels.containsKey(SchemaTable.of(this.sqlgGraph.getSqlDialect().getPublicSchema(), "V_Car")));
assertTrue(localTabels.containsKey(SchemaTable.of(this.sqlgGraph.getSqlDialect().getPublicSchema(), "V_Model")));
Pair<Set<SchemaTable>, Set<SchemaTable>> person = localTabels.get(SchemaTable.of(this.sqlgGraph.getSqlDialect().getPublicSchema(), "V_Person"));
assertEquals(0, person.getLeft().size());
assertEquals(1, person.getRight().size());
assertEquals(this.sqlgGraph.getSqlDialect().getPublicSchema() + ".E_drives", person.getRight().iterator().next().toString());
Pair<Set<SchemaTable>, Set<SchemaTable>> car = localTabels.get(SchemaTable.of(this.sqlgGraph.getSqlDialect().getPublicSchema(), "V_Car"));
assertEquals(1, car.getLeft().size());
assertEquals(1, car.getRight().size());
assertEquals(this.sqlgGraph.getSqlDialect().getPublicSchema() + ".E_drives", car.getLeft().iterator().next().toString());
Pair<Set<SchemaTable>, Set<SchemaTable>> model = localTabels.get(SchemaTable.of(this.sqlgGraph.getSqlDialect().getPublicSchema(), "V_Model"));
assertEquals(1, model.getLeft().size());
assertEquals(0, model.getRight().size());
assertEquals(this.sqlgGraph.getSqlDialect().getPublicSchema() + ".E_model", model.getLeft().iterator().next().toString());
}
use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.
the class TestBatch method testVerticesBatchOn.
@Test
public void testVerticesBatchOn() throws InterruptedException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
this.sqlgGraph.tx().normalBatchModeOn();
for (int i = 0; i < 10000; i++) {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "MO1", "name", "marko" + i);
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "marko" + i);
v1.addEdge("Friend", v2, "name", "xxx");
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println(stopWatch.toString());
testVerticesBatchOn_assert(this.sqlgGraph);
if (this.sqlgGraph1 != null) {
Thread.sleep(1000);
testVerticesBatchOn_assert(this.sqlgGraph1);
}
}
use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.
the class TestBatch method testPerformance.
@Test
public void testPerformance() throws InterruptedException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
this.sqlgGraph.tx().normalBatchModeOn();
for (int i = 0; i < 10000; i++) {
Vertex person = this.sqlgGraph.addVertex(T.label, "Person", "name", "marko" + i);
Vertex spaceTime = this.sqlgGraph.addVertex(T.label, "SpaceTime", "name", "marko" + i);
Vertex space = this.sqlgGraph.addVertex(T.label, "Space", "name", "marko" + i);
Vertex time = this.sqlgGraph.addVertex(T.label, "Time", "name", "marko" + i);
person.addEdge("spaceTime", spaceTime, "context", 1);
spaceTime.addEdge("space", space, "dimension", 3);
spaceTime.addEdge("time", time, "dimension", 1);
if (i != 0 && i % 10000 == 0) {
this.sqlgGraph.tx().commit();
this.sqlgGraph.tx().normalBatchModeOn();
}
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println(stopWatch.toString());
stopWatch.reset();
stopWatch.start();
testPerformance_assert(this.sqlgGraph);
if (this.sqlgGraph1 != null) {
Thread.sleep(1000);
testPerformance_assert(this.sqlgGraph1);
}
stopWatch.stop();
System.out.println(stopWatch.toString());
}
use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.
the class TestBatchStreamVertex method testMilCompleteVertex.
@Test
public void testMilCompleteVertex() throws InterruptedException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
this.sqlgGraph.tx().streamingBatchModeOn();
for (int i = 1; i < 100_001; i++) {
LinkedHashMap<String, Object> keyValue = new LinkedHashMap<>();
for (int j = 0; j < 2; j++) {
keyValue.put("name" + j, "a" + i);
}
this.sqlgGraph.streamVertex("Person", keyValue);
if (i % 25_000 == 0) {
this.sqlgGraph.tx().commit();
this.sqlgGraph.tx().streamingBatchModeOn();
System.out.println(i);
}
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println(stopWatch.toString());
stopWatch.reset();
stopWatch.start();
Assert.assertEquals(100_000L, this.sqlgGraph.traversal().V().has(T.label, "Person").count().next().longValue());
stopWatch.stop();
System.out.println(stopWatch.toString());
if (this.sqlgGraph1 != null) {
Thread.sleep(SLEEP_TIME);
Assert.assertEquals(100_000L, this.sqlgGraph1.traversal().V().has(T.label, "Person").count().next().longValue());
}
}
Aggregations