Search in sources :

Example 26 with SqlgVertex

use of org.umlg.sqlg.structure.SqlgVertex in project sqlg by pietermartin.

the class TestBatchStreamEdge method testStreamingVerticesAndEdges.

@Test
public void testStreamingVerticesAndEdges() 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();
    this.sqlgGraph.tx().streamingBatchModeOn();
    for (int i = 0; i < 1000; i++) {
        keyValues.put("age", i);
        this.sqlgGraph.streamVertex("Female", keyValues);
    }
    this.sqlgGraph.tx().flush();
    this.sqlgGraph.tx().streamingBatchModeOn();
    int count = 0;
    List<Vertex> men = this.sqlgGraph.traversal().V().hasLabel("Man").toList();
    List<Vertex> females = this.sqlgGraph.traversal().V().hasLabel("Female").toList();
    for (Vertex man : men) {
        SqlgVertex female = (SqlgVertex) females.get(count++);
        ((SqlgVertex) man).streamEdge("married", female);
    }
    this.sqlgGraph.tx().commit();
    testStreamingVerticesAndEdges_assert(this.sqlgGraph);
    if (this.sqlgGraph1 != null) {
        Thread.sleep(SLEEP_TIME);
        testStreamingVerticesAndEdges_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 27 with SqlgVertex

use of org.umlg.sqlg.structure.SqlgVertex in project sqlg by pietermartin.

the class TestBatchStreamEdge method testStreamLocalDate.

@Test
public void testStreamLocalDate() 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<>();
    LocalDate localDate = LocalDate.now();
    edgeKeyValues.put("localDate", localDate);
    for (Vertex man : men) {
        SqlgVertex female = (SqlgVertex) females.get(count++);
        ((SqlgVertex) man).streamEdge("married", female, edgeKeyValues);
    }
    this.sqlgGraph.tx().commit();
    testStreamLocalDate_assert(this.sqlgGraph, localDate);
    if (this.sqlgGraph1 != null) {
        Thread.sleep(SLEEP_TIME);
        testStreamLocalDate_assert(this.sqlgGraph1, localDate);
    }
}
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