Search in sources :

Example 6 with RecordId

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

the class TestBatchStreamVertex method testAccessPropertyFromVertexWhileStreaming.

@Test(expected = IllegalStateException.class)
public void testAccessPropertyFromVertexWhileStreaming() {
    Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a1");
    Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a2");
    v1.addEdge("friend", v2);
    this.sqlgGraph.tx().commit();
    this.sqlgGraph.tx().streamingBatchModeOn();
    LinkedHashMap<String, Object> properties = new LinkedHashMap<>();
    for (int i = 0; i < 100; i++) {
        properties.put("name", "aa" + i);
        this.sqlgGraph.streamVertex("Person", properties);
        properties.clear();
    }
    RecordId recordId = (RecordId) v1.id();
    Assert.assertEquals("a1", SqlgVertex.of(this.sqlgGraph, recordId.getId(), recordId.getSchemaTable().getSchema(), recordId.getSchemaTable().getTable()).value("name"));
    this.sqlgGraph.tx().commit();
}
Also used : SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) RecordId(org.umlg.sqlg.structure.RecordId) LinkedHashMap(java.util.LinkedHashMap) BaseTest(org.umlg.sqlg.test.BaseTest)

Example 7 with RecordId

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

the class TestBatchStreamVertex method testAccessPropertyFromEdgeWhileStreaming.

@Test(expected = IllegalStateException.class)
public void testAccessPropertyFromEdgeWhileStreaming() {
    Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a1");
    Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a2");
    Edge e1 = v1.addEdge("friend", v2);
    this.sqlgGraph.tx().commit();
    this.sqlgGraph.tx().streamingBatchModeOn();
    LinkedHashMap<String, Object> properties = new LinkedHashMap<>();
    for (int i = 0; i < 100; i++) {
        properties.put("name", "aa" + i);
        this.sqlgGraph.streamVertex("Person", properties);
        properties.clear();
    }
    RecordId recordId = (RecordId) e1.id();
    // Assert.assertEquals("a1", SqlgEdge.of(this.sqlgGraph, recordId.getId(), recordId.getSchemaTable().getSchema(), recordId.getSchemaTable().getTable()).value("name"));
    Assert.assertEquals("a1", this.sqlgGraph.traversal().E(recordId).next().value("name"));
    this.sqlgGraph.tx().commit();
}
Also used : SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) RecordId(org.umlg.sqlg.structure.RecordId) Edge(org.apache.tinkerpop.gremlin.structure.Edge) LinkedHashMap(java.util.LinkedHashMap) BaseTest(org.umlg.sqlg.test.BaseTest)

Aggregations

Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)7 RecordId (org.umlg.sqlg.structure.RecordId)7 SqlgVertex (org.umlg.sqlg.structure.SqlgVertex)6 DefaultGraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal)4 BaseTest (org.umlg.sqlg.test.BaseTest)3 LinkedHashMap (java.util.LinkedHashMap)2 StopWatch (org.apache.commons.lang3.time.StopWatch)1 Pair (org.apache.commons.lang3.tuple.Pair)1 Edge (org.apache.tinkerpop.gremlin.structure.Edge)1 Test (org.junit.Test)1