use of org.umlg.sqlg.structure.SqlgVertex 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.umlg.sqlg.structure.SqlgVertex in project sqlg by pietermartin.
the class TestBatchStreamEdge method testStreamLocalTime.
@Test
public void testStreamLocalTime() throws InterruptedException {
this.sqlgGraph.tx().streamingBatchModeOn();
LinkedHashMap<String, Object> keyValues = new LinkedHashMap<>();
keyValues.put("name", "halo");
keyValues.put("surname", "halo");
for (int i = 0; i < 10; i++) {
keyValues.put("age", i);
this.sqlgGraph.streamVertex("Man", keyValues);
}
this.sqlgGraph.tx().flush();
for (int i = 0; i < 10; i++) {
keyValues.put("age", i);
this.sqlgGraph.streamVertex("Female", keyValues);
}
this.sqlgGraph.tx().flush();
int count = 0;
List<Vertex> men = this.sqlgGraph.traversal().V().hasLabel("Man").toList();
List<Vertex> females = this.sqlgGraph.traversal().V().hasLabel("Female").toList();
LinkedHashMap<String, Object> edgeKeyValues = new LinkedHashMap<>();
LocalTime localTime = LocalTime.now();
edgeKeyValues.put("localTime", localTime);
for (Vertex man : men) {
SqlgVertex female = (SqlgVertex) females.get(count++);
((SqlgVertex) man).streamEdge("married", female, edgeKeyValues);
}
this.sqlgGraph.tx().commit();
testStreamLocalTime_assert(this.sqlgGraph, localTime);
if (this.sqlgGraph1 != null) {
Thread.sleep(SLEEP_TIME);
testStreamLocalTime_assert(this.sqlgGraph1, localTime);
}
}
use of org.umlg.sqlg.structure.SqlgVertex in project sqlg by pietermartin.
the class TestBatchStreamEdge method testCanNotCreateBatchEdgeWhileBatchVertexInProgress.
@Test(expected = IllegalStateException.class)
public void testCanNotCreateBatchEdgeWhileBatchVertexInProgress() {
SqlgVertex v1 = (SqlgVertex) this.sqlgGraph.addVertex(T.label, "Dog");
SqlgVertex v2 = (SqlgVertex) this.sqlgGraph.addVertex(T.label, "House");
this.sqlgGraph.tx().streamingBatchModeOn();
LinkedHashMap<String, Object> keyValues = new LinkedHashMap<>();
keyValues.put("name", "test");
this.sqlgGraph.streamVertex("A", keyValues);
this.sqlgGraph.streamVertex("A", keyValues);
v1.streamEdge("a", v2);
Assert.fail();
}
use of org.umlg.sqlg.structure.SqlgVertex in project sqlg by pietermartin.
the class TestBatchStreamEdge method testStreamJson.
@Test
public void testStreamJson() throws InterruptedException {
this.sqlgGraph.tx().streamingBatchModeOn();
LinkedHashMap<String, Object> keyValues = new LinkedHashMap<>();
keyValues.put("name", "halo");
keyValues.put("surname", "halo");
for (int i = 0; i < 10; i++) {
keyValues.put("age", i);
this.sqlgGraph.streamVertex("Man", keyValues);
}
this.sqlgGraph.tx().flush();
for (int i = 0; i < 10; i++) {
keyValues.put("age", i);
this.sqlgGraph.streamVertex("Female", keyValues);
}
this.sqlgGraph.tx().flush();
int count = 0;
List<Vertex> men = this.sqlgGraph.traversal().V().hasLabel("Man").toList();
List<Vertex> females = this.sqlgGraph.traversal().V().hasLabel("Female").toList();
LinkedHashMap<String, Object> edgeKeyValues = new LinkedHashMap<>();
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode json = new ObjectNode(objectMapper.getNodeFactory());
json.put("username", "john");
edgeKeyValues.put("doc", json);
for (Vertex man : men) {
SqlgVertex female = (SqlgVertex) females.get(count++);
((SqlgVertex) man).streamEdge("married", female, edgeKeyValues);
}
this.sqlgGraph.tx().commit();
testStreamJson_assert(this.sqlgGraph, json);
if (this.sqlgGraph1 != null) {
Thread.sleep(SLEEP_TIME);
testStreamJson_assert(this.sqlgGraph1, json);
}
}
use of org.umlg.sqlg.structure.SqlgVertex in project sqlg by pietermartin.
the class TestBatchStreamEdge method testEdgeLabelRemainsTheSame.
@Test(expected = IllegalStateException.class)
public void testEdgeLabelRemainsTheSame() {
SqlgVertex v1 = (SqlgVertex) this.sqlgGraph.addVertex(T.label, "A");
SqlgVertex v2 = (SqlgVertex) this.sqlgGraph.addVertex(T.label, "A");
this.sqlgGraph.tx().commit();
this.sqlgGraph.tx().streamingBatchModeOn();
v1.streamEdge("a", v2);
v1.streamEdge("b", v2);
Assert.fail();
}
Aggregations