use of org.umlg.sqlg.structure.SqlgVertex in project sqlg by pietermartin.
the class TestBatchStreamEdge method testEdgeFlushAndCloseStream.
@Test
public void testEdgeFlushAndCloseStream() throws InterruptedException {
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);
this.sqlgGraph.tx().flush();
this.sqlgGraph.tx().streamingBatchModeOn();
v1.streamEdge("b", v2);
this.sqlgGraph.tx().commit();
testEdgeFlushCloseStream_assert(this.sqlgGraph);
if (this.sqlgGraph1 != null) {
Thread.sleep(SLEEP_TIME);
testEdgeFlushCloseStream_assert(this.sqlgGraph1);
}
}
use of org.umlg.sqlg.structure.SqlgVertex in project sqlg by pietermartin.
the class TestBatch method testDeletePerformance.
@Test
public void testDeletePerformance() throws InterruptedException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
this.sqlgGraph.tx().normalBatchModeOn();
// 32767
int j = 1;
// createVertexLabel 280 foreign keys
for (int i = 0; i < 2810; i++) {
Vertex v1 = this.sqlgGraph.addVertex(T.label, this.sqlgGraph.getSqlDialect().getPublicSchema() + ".WorkspaceElement", "name", "workspaceElement" + i);
if (j == 281) {
j = 1;
}
Vertex v2 = this.sqlgGraph.addVertex(T.label, "huawei.NetworkElement", "name", "networkElement" + i + "_" + j);
v2.addEdge("WorkspaceElement_NetworkElement" + j, v1);
j++;
}
this.sqlgGraph.tx().commit();
this.sqlgGraph.tx().normalBatchModeOn();
stopWatch.stop();
System.out.println(stopWatch.toString());
stopWatch.reset();
stopWatch.start();
List<Vertex> vertexes = this.sqlgGraph.traversal().V().has(T.label, this.sqlgGraph.getSqlDialect().getPublicSchema() + ".WorkspaceElement").toList();
for (Vertex sqlgVertex : vertexes) {
sqlgVertex.remove();
}
this.sqlgGraph.tx().commit();
this.sqlgGraph.tx().normalBatchModeOn();
Assert.assertEquals(0, this.sqlgGraph.traversal().E().count().next().intValue());
vertexes = this.sqlgGraph.traversal().V().<SqlgVertex>has(T.label, "huawei.NetworkElement").toList();
for (Vertex sqlgVertex : vertexes) {
sqlgVertex.remove();
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println(stopWatch.toString());
testDeletePerformance_assert(this.sqlgGraph);
if (this.sqlgGraph1 != null) {
Thread.sleep(1000);
testDeletePerformance_assert(this.sqlgGraph1);
}
}
use of org.umlg.sqlg.structure.SqlgVertex in project sqlg by pietermartin.
the class TestBatch method testDropForeignKeys.
@Test
public void testDropForeignKeys() {
this.sqlgGraph.tx().commit();
this.sqlgGraph.tx().normalBatchModeOn();
Vertex workspaceElementBsc = this.sqlgGraph.addVertex(T.label, "WorkspaceElement", "name", "bsc1");
Vertex networkElementBsc = this.sqlgGraph.addVertex(T.label, "bsc", "name", "bsc1");
Vertex workspaceElementCell1 = this.sqlgGraph.addVertex(T.label, "WorkspaceElement", "name", "cell1");
Vertex networkElementCell1 = this.sqlgGraph.addVertex(T.label, "cell", "name", "cell1");
Vertex workspaceElementCell2 = this.sqlgGraph.addVertex(T.label, "WorkspaceElement", "name", "cell2");
Vertex networkElementCell2 = this.sqlgGraph.addVertex(T.label, "cell", "name", "cell2");
Vertex workspaceElementBsctmr1 = this.sqlgGraph.addVertex(T.label, "WorkspaceElement", "name", "bsctmr1");
Vertex networkElementBsctmr1 = this.sqlgGraph.addVertex(T.label, "bsctmr", "name", "bsctms1");
// add edges to workspaceelement
networkElementBsc.addEdge("bsc_workspaceElement", workspaceElementBsc);
networkElementCell1.addEdge("cell_workspaceElement", workspaceElementCell1);
networkElementCell2.addEdge("cell_workspaceElement", workspaceElementCell2);
networkElementBsctmr1.addEdge("bsctmr_workspaceElement", workspaceElementBsctmr1);
// add edges to between elements
networkElementBsc.addEdge("bsc_cell", networkElementCell1);
networkElementBsc.addEdge("bsc_cell", networkElementCell2);
networkElementBsc.addEdge("bsc_bsctmr", networkElementBsctmr1);
this.sqlgGraph.tx().commit();
this.sqlgGraph.tx().normalBatchModeOn();
List<Vertex> vertexes = this.sqlgGraph.traversal().V().<SqlgVertex>has(T.label, "WorkspaceElement").toList();
for (Vertex sqlgVertex : vertexes) {
sqlgVertex.remove();
}
vertexes = this.sqlgGraph.traversal().V().<SqlgVertex>has(T.label, "bsc").toList();
for (Vertex sqlgVertex : vertexes) {
sqlgVertex.remove();
}
vertexes = this.sqlgGraph.traversal().V().<SqlgVertex>has(T.label, "cell").toList();
for (Vertex sqlgVertex : vertexes) {
sqlgVertex.remove();
}
vertexes = this.sqlgGraph.traversal().V().<SqlgVertex>has(T.label, "bsctmr").toList();
for (Vertex sqlgVertex : vertexes) {
sqlgVertex.remove();
}
this.sqlgGraph.tx().commit();
}
use of org.umlg.sqlg.structure.SqlgVertex in project sqlg by pietermartin.
the class TestBatchStreamEdge method testEdgeWithProperties.
@Test
public void testEdgeWithProperties() 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 < 1000; i++) {
keyValues.put("age", i);
this.sqlgGraph.streamVertex("Man", keyValues);
}
this.sqlgGraph.tx().flush();
for (int i = 0; i < 1000; 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<>();
edgeKeyValues.put("name", "halo");
edgeKeyValues.put("surname", "halo");
for (Vertex man : men) {
SqlgVertex female = (SqlgVertex) females.get(count++);
((SqlgVertex) man).streamEdge("married", female, edgeKeyValues);
}
this.sqlgGraph.tx().commit();
testEdgeWithProperties_assert(this.sqlgGraph);
if (this.sqlgGraph1 != null) {
Thread.sleep(SLEEP_TIME);
testEdgeWithProperties_assert(this.sqlgGraph1);
}
}
use of org.umlg.sqlg.structure.SqlgVertex in project sqlg by pietermartin.
the class TestBatchStreamEdge method testStreamZonedDateTime.
@Test
public void testStreamZonedDateTime() 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<>();
ZonedDateTime zonedDateTime = ZonedDateTime.now();
edgeKeyValues.put("zonedDateTime", zonedDateTime);
for (Vertex man : men) {
SqlgVertex female = (SqlgVertex) females.get(count++);
((SqlgVertex) man).streamEdge("married", female, edgeKeyValues);
}
this.sqlgGraph.tx().commit();
testStreamZonedDateTime_assert(this.sqlgGraph, zonedDateTime);
if (this.sqlgGraph1 != null) {
Thread.sleep(SLEEP_TIME);
testStreamZonedDateTime_assert(this.sqlgGraph1, zonedDateTime);
}
}
Aggregations