use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.
the class TestBatchServerSideEdgeCreation method testBulkEdges2.
@Test
public void testBulkEdges2() throws InterruptedException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
this.sqlgGraph.tx().streamingBatchModeOn();
List<Pair<String, String>> uids = new ArrayList<>();
LinkedHashMap properties = new LinkedHashMap();
String uuid1Cache = null;
String uuid2Cache = null;
for (int i = 0; i < 1000; i++) {
String uuid1 = UUID.randomUUID().toString();
String uuid2 = UUID.randomUUID().toString();
if (i == 50) {
uuid1Cache = uuid1;
uuid2Cache = uuid2;
}
uids.add(Pair.of(uuid1, uuid2));
properties.put("id", uuid1);
this.sqlgGraph.streamVertex("Person", properties);
properties.put("id", uuid2);
this.sqlgGraph.streamVertex("Person", properties);
}
this.sqlgGraph.tx().flush();
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println(stopWatch.toString());
stopWatch.reset();
stopWatch.start();
this.sqlgGraph.tx().streamingBatchModeOn();
SchemaTable person = SchemaTable.of(this.sqlgGraph.getSqlDialect().getPublicSchema(), "Person");
this.sqlgGraph.bulkAddEdges("Person", "Person", "friend", Pair.of("id", "id"), uids);
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println(stopWatch.toString());
testBulkEdges2_assert(this.sqlgGraph, uuid1Cache, uuid2Cache);
if (this.sqlgGraph1 != null) {
Thread.sleep(SLEEP_TIME);
testBulkEdges2_assert(this.sqlgGraph1, uuid1Cache, uuid2Cache);
}
}
use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.
the class TestBatchServerSideEdgeCreation method testBulkEdgesTempTableUnique.
@Test
public void testBulkEdgesTempTableUnique() {
this.sqlgGraph.tx().streamingBatchModeOn();
List<Pair<String, String>> uids = new ArrayList<>();
LinkedHashMap properties = new LinkedHashMap();
for (int i = 0; i < 1000; i++) {
String uuid1 = UUID.randomUUID().toString();
String uuid2 = UUID.randomUUID().toString();
uids.add(Pair.of(uuid1, uuid2));
properties.put("id", uuid1);
this.sqlgGraph.streamVertex("Person", properties);
properties.put("id", uuid2);
this.sqlgGraph.streamVertex("Person", properties);
}
this.sqlgGraph.tx().flush();
this.sqlgGraph.tx().streamingBatchModeOn();
SchemaTable person = SchemaTable.of(this.sqlgGraph.getSqlDialect().getPublicSchema(), "Person");
this.sqlgGraph.bulkAddEdges("Person", "Person", "friend", Pair.of("id", "id"), uids);
this.sqlgGraph.tx().commit();
// and again
this.sqlgGraph.tx().streamingBatchModeOn();
uids.clear();
for (int i = 0; i < 1000; i++) {
String uuid1 = UUID.randomUUID().toString();
String uuid2 = UUID.randomUUID().toString();
uids.add(Pair.of(uuid1, uuid2));
properties.put("id", uuid1);
this.sqlgGraph.streamVertex("Person", properties);
properties.put("id", uuid2);
this.sqlgGraph.streamVertex("Person", properties);
}
this.sqlgGraph.tx().flush();
this.sqlgGraph.tx().streamingBatchModeOn();
this.sqlgGraph.bulkAddEdges("Person", "Person", "friend", Pair.of("id", "id"), uids);
this.sqlgGraph.tx().commit();
}
use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.
the class TestBatchStreamEdge method createMilPersonVertex.
private ArrayList<SqlgVertex> createMilPersonVertex() {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
ArrayList<SqlgVertex> result = new ArrayList<>();
this.sqlgGraph.tx().normalBatchModeOn();
for (int i = 1; i < NUMBER_OF_VERTICES + 1; i++) {
Map<String, Object> keyValue = new LinkedHashMap<>();
for (int j = 0; j < 100; j++) {
keyValue.put("name" + j, "aaaaaaaaaa" + i);
}
SqlgVertex person = (SqlgVertex) this.sqlgGraph.addVertex("Person", keyValue);
result.add(person);
if (i % (NUMBER_OF_VERTICES / 10) == 0) {
this.sqlgGraph.tx().commit();
this.sqlgGraph.tx().normalBatchModeOn();
}
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println("createMilPersonVertex took " + stopWatch.toString());
return result;
}
use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.
the class TestBatchStreamEdge method testMilCompleteEdges.
@Test
public void testMilCompleteEdges() {
ArrayList<SqlgVertex> persons = createMilPersonVertex();
ArrayList<SqlgVertex> cars = createMilCarVertex();
this.sqlgGraph.tx().commit();
StopWatch stopWatch = new StopWatch();
stopWatch.start();
this.sqlgGraph.tx().streamingBatchModeOn();
LinkedHashMap<String, Object> keyValues = new LinkedHashMap<>();
keyValues.put("name", "halo");
keyValues.put("name2", "halo");
for (int i = 0; i < NUMBER_OF_VERTICES; i++) {
SqlgVertex person = persons.get(0);
SqlgVertex car = cars.get(i);
person.streamEdge("person_car", car, keyValues);
}
this.sqlgGraph.tx().commit();
int mb = 1024 * 1024;
// get Runtime instance
Runtime instance = Runtime.getRuntime();
System.out.println("***** Heap utilization statistics [MB] *****\n");
// available memory
System.out.println("Total Memory: " + instance.totalMemory() / mb);
// free memory
System.out.println("Free Memory: " + instance.freeMemory() / mb);
// used memory
System.out.println("Used Memory: " + (instance.totalMemory() - instance.freeMemory()) / mb);
// Maximum available memory
System.out.println("Max Memory: " + instance.maxMemory() / mb);
Assert.assertEquals(NUMBER_OF_VERTICES, this.sqlgGraph.traversal().V(persons.get(0)).out("person_car").toList().size());
stopWatch.stop();
System.out.println("testMilCompleteEdges took " + stopWatch.toString());
}
use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.
the class TestBatch method testEscapingCharacters.
@Test
public void testEscapingCharacters() 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, "test1", "\\", "test2", "\nhalo", "test3", "\rhalo", "test4", "\thalo");
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "marko" + i, "test1", "\\", "test2", "\nhalo", "test3", "\rhalo", "test4", "\thalo");
v1.addEdge("Friend", v2, "name", "xxx");
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println(stopWatch.toString());
testEscapingCharacters_assert(this.sqlgGraph);
if (this.sqlgGraph1 != null) {
Thread.sleep(1000);
testEscapingCharacters_assert(this.sqlgGraph1);
}
}
Aggregations