Search in sources :

Example 1 with RecordId

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

the class TestGremlinCompileWithHas method testHasIdInJoin_assert.

private void testHasIdInJoin_assert(SqlgGraph sqlgGraph, Vertex a1, Vertex a2, Vertex a3, Vertex a4) {
    long start = sqlgGraph.getSqlDialect().getPrimaryKeyStartValue();
    RecordId recordIda1 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "A"), start + 0L);
    RecordId recordIda2 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "A"), start + 1L);
    RecordId recordIda3 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "A"), start + 2L);
    RecordId recordIda4 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "A"), start + 3L);
    RecordId recordIdb1 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "B"), start + 0L);
    RecordId recordIdb2 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "B"), start + 1L);
    RecordId recordIdb3 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "B"), start + 2L);
    RecordId recordIdb4 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "B"), start + 3L);
    RecordId recordIdc1 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "C"), start + 0L);
    RecordId recordIdc2 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "C"), start + 1L);
    RecordId recordIdc3 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "C"), start + 2L);
    RecordId recordIdc4 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "C"), start + 3L);
    DefaultGraphTraversal<Vertex, Vertex> traversal = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1, recordIda2, recordIda3, recordIda4).in().hasId(recordIdb1, recordIdb2, recordIdb3);
    Assert.assertEquals(3, traversal.getSteps().size());
    List<Vertex> vertices = traversal.toList();
    Assert.assertEquals(1, traversal.getSteps().size());
    Assert.assertEquals(3, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal1 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1.toString(), recordIda2.toString(), recordIda3.toString(), recordIda4.toString()).in().hasId(recordIdb1.toString(), recordIdb2.toString(), recordIdb3.toString());
    Assert.assertEquals(3, traversal1.getSteps().size());
    vertices = traversal1.toList();
    Assert.assertEquals(1, traversal1.getSteps().size());
    Assert.assertEquals(3, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal2 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(a1, a2, a3, a4).in().hasId(recordIdb1.toString(), recordIdb2.toString(), recordIdb3.toString());
    Assert.assertEquals(3, traversal2.getSteps().size());
    vertices = traversal2.toList();
    Assert.assertEquals(1, traversal2.getSteps().size());
    Assert.assertEquals(3, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal3 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(a1, a2, a3, a4).in().hasId(recordIdb1.toString(), recordIdb2.toString(), recordIdb3.toString());
    Assert.assertEquals(3, traversal3.getSteps().size());
    vertices = traversal3.toList();
    Assert.assertEquals(1, traversal3.getSteps().size());
    Assert.assertEquals(3, vertices.size());
}
Also used : SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) DefaultGraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal) RecordId(org.umlg.sqlg.structure.RecordId)

Example 2 with RecordId

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

the class TestGremlinCompileWithHas method testHasIdIn_assert.

private void testHasIdIn_assert(SqlgGraph sqlgGraph) {
    long start = sqlgGraph.getSqlDialect().getPrimaryKeyStartValue();
    RecordId recordIda1 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "A"), start + 0L);
    RecordId recordIda2 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "A"), start + 1l);
    RecordId recordIda3 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "A"), start + 2L);
    RecordId recordIda4 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "A"), start + 3L);
    RecordId recordIdb1 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "B"), start + 0L);
    RecordId recordIdb2 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "B"), start + 1L);
    RecordId recordIdb3 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "B"), start + 2L);
    RecordId recordIdb4 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "B"), start + 3L);
    RecordId recordIdc1 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "C"), start + 0L);
    RecordId recordIdc2 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "C"), start + 1L);
    RecordId recordIdc3 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "C"), start + 2L);
    RecordId recordIdc4 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "C"), start + 3L);
    DefaultGraphTraversal<Vertex, Vertex> traversal = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).hasLabel("A");
    Assert.assertEquals(2, traversal.getSteps().size());
    List<Vertex> vertices = traversal.toList();
    Assert.assertEquals(1, traversal.getSteps().size());
    Assert.assertEquals(1, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal1 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).has(T.id, P.within(recordIda2, recordIdb1));
    Assert.assertEquals(2, traversal1.getSteps().size());
    vertices = traversal1.toList();
    Assert.assertEquals(1, traversal1.getSteps().size());
    Assert.assertEquals(0, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal2 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V().has(T.id, P.within(recordIda1, recordIda2, recordIdb1));
    Assert.assertEquals(2, traversal2.getSteps().size());
    vertices = traversal2.toList();
    Assert.assertEquals(1, traversal2.getSteps().size());
    Assert.assertEquals(3, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal3 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1, recordIda2, recordIda3, recordIdb1);
    Assert.assertEquals(1, traversal3.getSteps().size());
    vertices = traversal3.toList();
    Assert.assertEquals(1, traversal3.getSteps().size());
    Assert.assertEquals(4, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal4 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V().has(T.id, P.within(recordIda1));
    Assert.assertEquals(2, traversal4.getSteps().size());
    vertices = traversal4.toList();
    Assert.assertEquals(1, traversal4.getSteps().size());
    Assert.assertEquals(1, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal5 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).in().hasId(recordIdb1);
    Assert.assertEquals(3, traversal5.getSteps().size());
    vertices = traversal5.toList();
    Assert.assertEquals(1, traversal5.getSteps().size());
    Assert.assertEquals(1, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal6 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1, recordIda2, recordIda3).in().hasId(recordIdb1, recordIdb2, recordIdb3);
    Assert.assertEquals(3, traversal6.getSteps().size());
    vertices = traversal6.toList();
    Assert.assertEquals(1, traversal6.getSteps().size());
    Assert.assertEquals(3, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal7 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).in().hasId(recordIda1);
    Assert.assertEquals(3, traversal7.getSteps().size());
    vertices = traversal7.toList();
    Assert.assertEquals(1, traversal7.getSteps().size());
    Assert.assertEquals(0, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal8 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).in().hasId(recordIdb1);
    Assert.assertEquals(3, traversal8.getSteps().size());
    vertices = traversal8.toList();
    Assert.assertEquals(1, traversal8.getSteps().size());
    Assert.assertEquals(1, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal9 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).in().hasId(recordIdb1, recordIdb2);
    Assert.assertEquals(3, traversal9.getSteps().size());
    vertices = traversal9.toList();
    Assert.assertEquals(1, traversal9.getSteps().size());
    Assert.assertEquals(2, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal10 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).in().hasId(recordIdb1.toString());
    Assert.assertEquals(3, traversal10.getSteps().size());
    vertices = traversal10.toList();
    Assert.assertEquals(1, traversal10.getSteps().size());
    Assert.assertEquals(1, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal11 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).in().hasId(recordIdb1.toString(), recordIdb2.toString());
    Assert.assertEquals(3, traversal11.getSteps().size());
    vertices = traversal11.toList();
    Assert.assertEquals(1, traversal11.getSteps().size());
    Assert.assertEquals(2, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal12 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).in().hasId(recordIdb1.toString(), recordIdc2.toString());
    Assert.assertEquals(3, traversal12.getSteps().size());
    vertices = traversal12.toList();
    Assert.assertEquals(1, traversal12.getSteps().size());
    Assert.assertEquals(2, vertices.size());
}
Also used : SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) DefaultGraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal) RecordId(org.umlg.sqlg.structure.RecordId)

Example 3 with RecordId

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

the class TestGremlinCompileWithHas method testHasIdOut_assert.

private void testHasIdOut_assert(SqlgGraph sqlgGraph) {
    long start = sqlgGraph.getSqlDialect().getPrimaryKeyStartValue();
    RecordId recordIda1 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "A"), start + 0L);
    RecordId recordIda2 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "A"), start + 1L);
    RecordId recordIda3 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "A"), start + 2L);
    RecordId recordIda4 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "A"), start + 3L);
    RecordId recordIdb1 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "B"), start + 0L);
    RecordId recordIdb2 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "B"), start + 1L);
    RecordId recordIdb3 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "B"), start + 2L);
    RecordId recordIdb4 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "B"), start + 3L);
    RecordId recordIdc1 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "C"), start + 0L);
    RecordId recordIdc2 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "C"), start + 1L);
    RecordId recordIdc3 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "C"), start + 2L);
    RecordId recordIdc4 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "C"), start + 3L);
    DefaultGraphTraversal<Vertex, Vertex> traversal = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).hasLabel("A");
    Assert.assertEquals(2, traversal.getSteps().size());
    List<Vertex> vertices = traversal.toList();
    Assert.assertEquals(1, traversal.getSteps().size());
    Assert.assertEquals(1, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal1 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).has(T.id, P.within(recordIda2, recordIdb1));
    Assert.assertEquals(2, traversal1.getSteps().size());
    vertices = traversal1.toList();
    Assert.assertEquals(1, traversal1.getSteps().size());
    Assert.assertEquals(0, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal2 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V().has(T.id, P.within(recordIda1, recordIda2, recordIdb1));
    Assert.assertEquals(2, traversal2.getSteps().size());
    vertices = traversal2.toList();
    Assert.assertEquals(1, traversal2.getSteps().size());
    Assert.assertEquals(3, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal3 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1, recordIda2, recordIda3, recordIdb1);
    Assert.assertEquals(1, traversal3.getSteps().size());
    vertices = traversal3.toList();
    Assert.assertEquals(1, traversal3.getSteps().size());
    Assert.assertEquals(4, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal4 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V().has(T.id, P.within(recordIda1));
    Assert.assertEquals(2, traversal4.getSteps().size());
    vertices = traversal4.toList();
    Assert.assertEquals(1, traversal4.getSteps().size());
    Assert.assertEquals(1, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal5 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).out().hasId(recordIdb1);
    Assert.assertEquals(3, traversal5.getSteps().size());
    vertices = traversal5.toList();
    Assert.assertEquals(1, traversal5.getSteps().size());
    Assert.assertEquals(1, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal6 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1, recordIda2, recordIda3).out().hasId(recordIdb1, recordIdb2, recordIdb3);
    Assert.assertEquals(3, traversal6.getSteps().size());
    vertices = traversal6.toList();
    Assert.assertEquals(1, traversal6.getSteps().size());
    Assert.assertEquals(3, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal7 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).out().hasId(recordIda1);
    Assert.assertEquals(3, traversal7.getSteps().size());
    vertices = traversal7.toList();
    Assert.assertEquals(1, traversal7.getSteps().size());
    Assert.assertEquals(0, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal8 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).out().hasId(recordIdb1);
    Assert.assertEquals(3, traversal8.getSteps().size());
    vertices = traversal8.toList();
    Assert.assertEquals(1, traversal8.getSteps().size());
    Assert.assertEquals(1, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal9 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).out().hasId(recordIdb1, recordIdb2);
    Assert.assertEquals(3, traversal9.getSteps().size());
    vertices = traversal9.toList();
    Assert.assertEquals(1, traversal9.getSteps().size());
    Assert.assertEquals(2, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal10 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).out().hasId(recordIdb1.toString());
    Assert.assertEquals(3, traversal10.getSteps().size());
    vertices = traversal10.toList();
    Assert.assertEquals(1, traversal10.getSteps().size());
    Assert.assertEquals(1, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal11 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).out().hasId(recordIdb1.toString(), recordIdb2.toString());
    Assert.assertEquals(3, traversal11.getSteps().size());
    vertices = traversal11.toList();
    Assert.assertEquals(1, traversal11.getSteps().size());
    Assert.assertEquals(2, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal12 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1).out().hasId(recordIdb1.toString(), recordIdc2.toString());
    Assert.assertEquals(3, traversal12.getSteps().size());
    vertices = traversal12.toList();
    Assert.assertEquals(1, traversal12.getSteps().size());
    Assert.assertEquals(2, vertices.size());
}
Also used : SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) DefaultGraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal) RecordId(org.umlg.sqlg.structure.RecordId)

Example 4 with RecordId

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

the class TestGremlinCompileWithHas method testHasIdOutJoin_assert.

private void testHasIdOutJoin_assert(SqlgGraph sqlgGraph, Vertex a1, Vertex a2, Vertex a3, Vertex a4) {
    long start = sqlgGraph.getSqlDialect().getPrimaryKeyStartValue();
    RecordId recordIda1 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "A"), start + 0L);
    RecordId recordIda2 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "A"), start + 1L);
    RecordId recordIda3 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "A"), start + 2L);
    RecordId recordIda4 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "A"), start + 3L);
    RecordId recordIdb1 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "B"), start + 0L);
    RecordId recordIdb2 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "B"), start + 1L);
    RecordId recordIdb3 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "B"), start + 2L);
    RecordId recordIdb4 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "B"), start + 3L);
    RecordId recordIdc1 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "C"), start + 0L);
    RecordId recordIdc2 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "C"), start + 1L);
    RecordId recordIdc3 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "C"), start + 2L);
    RecordId recordIdc4 = RecordId.from(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "C"), start + 3L);
    DefaultGraphTraversal<Vertex, Vertex> traversal = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1, recordIda2, recordIda3, recordIda4).out().hasId(recordIdb1, recordIdb2, recordIdb3);
    Assert.assertEquals(3, traversal.getSteps().size());
    List<Vertex> vertices = traversal.toList();
    Assert.assertEquals(1, traversal.getSteps().size());
    Assert.assertEquals(3, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal1 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(recordIda1.toString(), recordIda2.toString(), recordIda3.toString(), recordIda4.toString()).out().hasId(recordIdb1.toString(), recordIdb2.toString(), recordIdb3.toString());
    Assert.assertEquals(3, traversal1.getSteps().size());
    vertices = traversal1.toList();
    Assert.assertEquals(1, traversal1.getSteps().size());
    Assert.assertEquals(3, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal2 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(a1, a2, a3, a4).out().hasId(recordIdb1.toString(), recordIdb2.toString(), recordIdb3.toString());
    Assert.assertEquals(3, traversal2.getSteps().size());
    vertices = traversal2.toList();
    Assert.assertEquals(1, traversal2.getSteps().size());
    Assert.assertEquals(3, vertices.size());
    DefaultGraphTraversal<Vertex, Vertex> traversal3 = (DefaultGraphTraversal<Vertex, Vertex>) sqlgGraph.traversal().V(a1, a2, a3, a4).out().hasId(recordIdb1.toString(), recordIdb2.toString(), recordIdb3.toString());
    Assert.assertEquals(3, traversal3.getSteps().size());
    vertices = traversal3.toList();
    Assert.assertEquals(1, traversal3.getSteps().size());
    Assert.assertEquals(3, vertices.size());
}
Also used : SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) DefaultGraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal) RecordId(org.umlg.sqlg.structure.RecordId)

Example 5 with RecordId

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

the class TestBatchServerSideEdgeCreation method testOnIds.

@Test
public void testOnIds() throws InterruptedException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    Vertex virtualGroup = sqlgGraph.addVertex(T.label, "VirtualGroup", "name", "halo");
    sqlgGraph.tx().commit();
    List<Pair<Long, Long>> ids = new ArrayList<>();
    sqlgGraph.tx().streamingWithLockBatchModeOn();
    Map<String, Object> properties = new HashMap<>();
    properties.put("cm_uid", UUID.randomUUID().toString());
    for (int i = 0; i < 1_000; i++) {
        Vertex v = sqlgGraph.addVertex("RealWorkspaceElement", properties);
        RecordId recordId = (RecordId) v.id();
        Pair<Long, Long> idPair = Pair.of(recordId.getId(), ((RecordId) virtualGroup.id()).getId());
        ids.add(idPair);
    }
    sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println("Time to insert: " + stopWatch.toString());
    stopWatch.reset();
    stopWatch.start();
    this.sqlgGraph.tx().streamingBatchModeOn();
    sqlgGraph.bulkAddEdges("RealWorkspaceElement", "VirtualGroup", "realWorkspaceElement_virtualGroup", Pair.of("ID", "ID"), ids);
    sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println("Time to insert: " + stopWatch.toString());
    assertEquals(1_000, this.sqlgGraph.traversal().V(virtualGroup).in("realWorkspaceElement_virtualGroup").count().next().intValue());
    if (this.sqlgGraph1 != null) {
        Thread.sleep(SLEEP_TIME);
        assertEquals(1_000, this.sqlgGraph1.traversal().V(virtualGroup).in("realWorkspaceElement_virtualGroup").count().next().intValue());
    }
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) StopWatch(org.apache.commons.lang3.time.StopWatch) RecordId(org.umlg.sqlg.structure.RecordId) Pair(org.apache.commons.lang3.tuple.Pair) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

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