Search in sources :

Example 21 with SqlgVertex

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);
    }
}
Also used : SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) BaseTest(org.umlg.sqlg.test.BaseTest)

Example 22 with SqlgVertex

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);
    }
}
Also used : SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) StopWatch(org.apache.commons.lang3.time.StopWatch) BaseTest(org.umlg.sqlg.test.BaseTest)

Example 23 with SqlgVertex

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();
}
Also used : SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) BaseTest(org.umlg.sqlg.test.BaseTest)

Example 24 with SqlgVertex

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);
    }
}
Also used : SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) LinkedHashMap(java.util.LinkedHashMap) BaseTest(org.umlg.sqlg.test.BaseTest)

Example 25 with SqlgVertex

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);
    }
}
Also used : SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) LinkedHashMap(java.util.LinkedHashMap) BaseTest(org.umlg.sqlg.test.BaseTest)

Aggregations

SqlgVertex (org.umlg.sqlg.structure.SqlgVertex)27 BaseTest (org.umlg.sqlg.test.BaseTest)22 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)17 LinkedHashMap (java.util.LinkedHashMap)16 StopWatch (org.apache.commons.lang3.time.StopWatch)5 Test (org.junit.Test)5 HashMap (java.util.HashMap)3 DefaultGraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal)3 ArrayList (java.util.ArrayList)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 Edge (org.apache.tinkerpop.gremlin.structure.Edge)1 PropertyType (org.umlg.sqlg.structure.PropertyType)1 SchemaTable (org.umlg.sqlg.structure.SchemaTable)1 VertexLabel (org.umlg.sqlg.structure.topology.VertexLabel)1