use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.
the class TestBulkWithout method testBulkWithinMultipleHasContainers.
@Test
public void testBulkWithinMultipleHasContainers() throws InterruptedException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
Vertex god = this.sqlgGraph.addVertex(T.label, "God");
Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 1, "name", "pete");
god.addEdge("creator", person1);
Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 2, "name", "pete");
god.addEdge("creator", person2);
Vertex person3 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 3, "name", "john");
god.addEdge("creator", person3);
Vertex person4 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 4, "name", "pete");
god.addEdge("creator", person4);
Vertex person5 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 5, "name", "pete");
god.addEdge("creator", person5);
Vertex person6 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 6, "name", "pete");
god.addEdge("creator", person6);
Vertex person7 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 7, "name", "pete");
god.addEdge("creator", person7);
Vertex person8 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 8, "name", "pete");
god.addEdge("creator", person8);
Vertex person9 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 9, "name", "pete");
god.addEdge("creator", person9);
Vertex person10 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 10, "name", "pete");
god.addEdge("creator", person10);
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println(stopWatch.toString());
stopWatch.reset();
stopWatch.start();
testBulkWithinMultipleHasContainers_assert(this.sqlgGraph);
if (this.sqlgGraph1 != null) {
Thread.sleep(SLEEP_TIME);
testBulkWithinMultipleHasContainers_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 TestBulkWithout method testBulkWithout.
@Test
public void testBulkWithout() throws InterruptedException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
if (this.sqlgGraph.getSqlDialect().supportsBatchMode()) {
this.sqlgGraph.tx().normalBatchModeOn();
}
Vertex god = this.sqlgGraph.addVertex(T.label, "God");
List<String> uuids = new ArrayList<>();
for (int i = 0; i < 100; i++) {
String uuid = UUID.randomUUID().toString();
uuids.add(uuid);
Vertex person = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", uuid);
god.addEdge("creator", person);
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println(stopWatch.toString());
stopWatch.reset();
stopWatch.start();
testBulkWithout_assert(this.sqlgGraph, uuids);
if (this.sqlgGraph1 != null) {
Thread.sleep(SLEEP_TIME);
testBulkWithout_assert(this.sqlgGraph1, uuids);
}
stopWatch.stop();
System.out.println(stopWatch.toString());
}
use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.
the class TestBulkWithout method testBulkWithinVertexCompileStep.
@Test
public void testBulkWithinVertexCompileStep() throws InterruptedException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
if (this.sqlgGraph.getSqlDialect().supportsBatchMode()) {
this.sqlgGraph.tx().normalBatchModeOn();
}
Vertex god = this.sqlgGraph.addVertex(T.label, "God");
List<String> uuids = new ArrayList<>();
for (int i = 0; i < 100; i++) {
String uuid = UUID.randomUUID().toString();
uuids.add(uuid);
Vertex person = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", uuid);
god.addEdge("creator", person);
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println(stopWatch.toString());
stopWatch.reset();
stopWatch.start();
testBulkWithinVertexCompileStep_assert(this.sqlgGraph, god, uuids);
if (this.sqlgGraph1 != null) {
Thread.sleep(SLEEP_TIME);
testBulkWithinVertexCompileStep_assert(this.sqlgGraph1, god, uuids);
}
stopWatch.stop();
System.out.println(stopWatch.toString());
}
use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.
the class TestTraversalPerformance method testSpeedWithLargeSchemaFastQuery1.
@Test
public void testSpeedWithLargeSchemaFastQuery1() {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
Map<String, PropertyType> columns = new HashMap<>();
for (int i = 0; i < 100; i++) {
columns.put("property_" + i, PropertyType.STRING);
}
// Create a large schema, it slows the maps down
int NUMBER_OF_SCHEMA_ELEMENTS = 1_000;
for (int i = 0; i < NUMBER_OF_SCHEMA_ELEMENTS; i++) {
VertexLabel person = this.sqlgGraph.getTopology().ensureVertexLabelExist("Person_" + i, columns);
VertexLabel dog = this.sqlgGraph.getTopology().ensureVertexLabelExist("Dog_" + i, columns);
person.ensureEdgeLabelExist("pet_" + i, dog, columns);
if (i % 100 == 0) {
this.sqlgGraph.tx().commit();
}
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println("done creating schema time taken " + stopWatch.toString());
stopWatch.reset();
stopWatch.start();
Map<String, Object> columnValues = new HashMap<>();
for (int i = 0; i < 100; i++) {
columnValues.put("property_" + i, "asdasdasd");
}
for (int i = 0; i < NUMBER_OF_SCHEMA_ELEMENTS; i++) {
SqlgVertex person = (SqlgVertex) this.sqlgGraph.addVertex("Person_" + i, columnValues);
SqlgVertex dog = (SqlgVertex) this.sqlgGraph.addVertex("Dog_" + i, columnValues);
person.addEdgeWithMap("pet_" + i, dog, columnValues);
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println("done inserting data time taken " + stopWatch.toString());
stopWatch.reset();
stopWatch.start();
for (int i = 0; i < 10_000; i++) {
Assert.assertEquals(1, this.sqlgGraph.traversal().V().hasLabel("Person_0").out("pet_0").toList().size());
}
stopWatch.stop();
System.out.println("total query time " + stopWatch.toString());
}
use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.
the class TestForDocs method testHsqldbLargeLoad.
// //Create a 10000 objects, each with 2 properties
// @Test
// public void testAddPersons() {
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// for (int i = 0; i < 10000; i++) {
// this.sqlgGraph.addVertex(T.label, "Person", "prop1", "property1", "prop2", "property2");
// }
// this.sqlgGraph.tx().commit();
// stopWatch.stop();
// System.out.println("Time to insert: " + stopWatch.toString());
// stopWatch.reset();
// stopWatch.start();
// Assert.assertEquals(Long.valueOf(10000), this.sqlgGraph.traversal().V().existVertexLabel(T.label, "Person").count().next());
// stopWatch.stop();
// System.out.println("Time to read: " + stopWatch.toString());
// }
//
// //Create a 10001 Persons, each with 2 properties and one friend
// @Test
// public void testAddPersonAndFriends() {
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// Vertex previous = this.sqlgGraph.addVertex(T.label, "Person", "name", "first");
//
// for (int i = 0; i < 10000; i++) {
// Vertex current = this.sqlgGraph.addVertex(T.label, "Person", "name", "current" + i);
// previous.addEdge("friend", current);
// }
// this.sqlgGraph.tx().commit();
// stopWatch.stop();
// System.out.println("Time to insert: " + stopWatch.toString());
// stopWatch.reset();
// stopWatch.start();
// List<Vertex> persons = this.sqlgGraph.traversal().V().<Vertex>existVertexLabel(T.label, "Person").toList();
// Map<Vertex, List<Vertex>> friendMap = new HashMap<>();
// persons.forEach(
// p -> friendMap.put(p, p.in("friend").toList())
// );
// Assert.assertEquals(10001, friendMap.size());
// stopWatch.stop();
// System.out.println("Time to read all vertices: " + stopWatch.toString());
// }
//
// @Test
// public void testPostgresBatchMode() {
// this.sqlgGraph.tx().normalBatchModeOn();
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// for (int i = 1; i < 1000001; i++) {
// Vertex person = this.sqlgGraph.addVertex(T.label, "Person", "name", "John" + i);
// Vertex dog = this.sqlgGraph.addVertex(T.label, "Dog", "name", "snowy" + i);
// person.addEdge("pet", dog);
// if (i % 100000 == 0) {
// this.sqlgGraph.tx().commit();
// this.sqlgGraph.tx().normalBatchModeOn();
// }
// }
// this.sqlgGraph.tx().commit();
// stopWatch.stop();
// System.out.println("Time to insert: " + stopWatch.toString());
// stopWatch.reset();
// stopWatch.start();
//
// Assert.assertEquals(1000000, this.sqlgGraph.traversal().V().<Vertex>existVertexLabel(T.label, "Person").count().next().intValue());
// Assert.assertEquals(1000000, this.sqlgGraph.traversal().V().<Vertex>existVertexLabel(T.label, "Dog").count().next().intValue());
//
// stopWatch.stop();
// System.out.println("Time to read all vertices: " + stopWatch.toString());
// }
@Test
public void testHsqldbLargeLoad() {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
for (int i = 1; i < 1000001; i++) {
Vertex person = this.sqlgGraph.addVertex(T.label, "Person", "name", "John" + i);
Vertex dog = this.sqlgGraph.addVertex(T.label, "Dog", "name", "snowy" + i);
person.addEdge("pet", dog);
if (i % 100000 == 0) {
this.sqlgGraph.tx().commit();
}
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println("Time to insert: " + stopWatch.toString());
stopWatch.reset();
stopWatch.start();
Assert.assertEquals(1000000, this.sqlgGraph.traversal().V().<Vertex>has(T.label, "Person").count().next().intValue());
Assert.assertEquals(1000000, this.sqlgGraph.traversal().V().<Vertex>has(T.label, "Dog").count().next().intValue());
stopWatch.stop();
System.out.println("Time to read all vertices: " + stopWatch.toString());
}
Aggregations