Search in sources :

Example 56 with Person

use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.

the class TestCaptureSchemaTableEdges method testLoadTableLabels.

@Test
public void testLoadTableLabels() throws Exception {
    Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "pieter");
    Vertex car1 = this.sqlgGraph.addVertex(T.label, "Car", "name", "bmw");
    person1.addEdge("drives", car1);
    Vertex car2 = this.sqlgGraph.addVertex(T.label, "Car", "name", "toyota");
    person1.addEdge("drives", car2);
    Vertex bmw = this.sqlgGraph.addVertex(T.label, "Model", "name", "bmw");
    car1.addEdge("model", bmw);
    Vertex toyota = this.sqlgGraph.addVertex(T.label, "Model", "name", "toyota");
    car2.addEdge("model", toyota);
    this.sqlgGraph.tx().commit();
    this.sqlgGraph.close();
    try (SqlgGraph sqlgGraph = SqlgGraph.open(configuration)) {
        Map<SchemaTable, Pair<Set<SchemaTable>, Set<SchemaTable>>> localTabels = sqlgGraph.getTopology().getTableLabels();
        assertTrue(localTabels.containsKey(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "V_Person")));
        assertTrue(localTabels.containsKey(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "V_Car")));
        assertTrue(localTabels.containsKey(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "V_Model")));
        Pair<Set<SchemaTable>, Set<SchemaTable>> person = localTabels.get(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "V_Person"));
        assertEquals(0, person.getLeft().size());
        assertEquals(1, person.getRight().size());
        assertEquals(sqlgGraph.getSqlDialect().getPublicSchema() + ".E_drives", person.getRight().iterator().next().toString());
        Pair<Set<SchemaTable>, Set<SchemaTable>> car = localTabels.get(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "V_Car"));
        assertEquals(1, car.getLeft().size());
        assertEquals(1, car.getRight().size());
        assertEquals(sqlgGraph.getSqlDialect().getPublicSchema() + ".E_drives", car.getLeft().iterator().next().toString());
        Pair<Set<SchemaTable>, Set<SchemaTable>> model = localTabels.get(SchemaTable.of(sqlgGraph.getSqlDialect().getPublicSchema(), "V_Model"));
        assertEquals(1, model.getLeft().size());
        assertEquals(0, model.getRight().size());
        assertEquals(sqlgGraph.getSqlDialect().getPublicSchema() + ".E_model", model.getLeft().iterator().next().toString());
    }
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) SqlgGraph(org.umlg.sqlg.structure.SqlgGraph) Set(java.util.Set) SchemaTable(org.umlg.sqlg.structure.SchemaTable) Pair(org.apache.commons.lang3.tuple.Pair) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Example 57 with Person

use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.

the class TestCaptureSchemaTableEdges method testCaptureSchemaTableLabels.

@Test
public void testCaptureSchemaTableLabels() {
    Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "pieter");
    Vertex car1 = this.sqlgGraph.addVertex(T.label, "Car", "name", "bmw");
    person1.addEdge("drives", car1);
    Vertex car2 = this.sqlgGraph.addVertex(T.label, "Car", "name", "toyota");
    person1.addEdge("drives", car2);
    Vertex bmw = this.sqlgGraph.addVertex(T.label, "Model", "name", "bmw");
    car1.addEdge("model", bmw);
    Vertex toyota = this.sqlgGraph.addVertex(T.label, "Model", "name", "toyota");
    car2.addEdge("model", toyota);
    this.sqlgGraph.tx().commit();
    Map<SchemaTable, Pair<Set<SchemaTable>, Set<SchemaTable>>> localTabels = this.sqlgGraph.getTopology().getTableLabels();
    assertTrue(localTabels.containsKey(SchemaTable.of(this.sqlgGraph.getSqlDialect().getPublicSchema(), "V_Person")));
    assertTrue(localTabels.containsKey(SchemaTable.of(this.sqlgGraph.getSqlDialect().getPublicSchema(), "V_Car")));
    assertTrue(localTabels.containsKey(SchemaTable.of(this.sqlgGraph.getSqlDialect().getPublicSchema(), "V_Model")));
    Pair<Set<SchemaTable>, Set<SchemaTable>> person = localTabels.get(SchemaTable.of(this.sqlgGraph.getSqlDialect().getPublicSchema(), "V_Person"));
    assertEquals(0, person.getLeft().size());
    assertEquals(1, person.getRight().size());
    assertEquals(this.sqlgGraph.getSqlDialect().getPublicSchema() + ".E_drives", person.getRight().iterator().next().toString());
    Pair<Set<SchemaTable>, Set<SchemaTable>> car = localTabels.get(SchemaTable.of(this.sqlgGraph.getSqlDialect().getPublicSchema(), "V_Car"));
    assertEquals(1, car.getLeft().size());
    assertEquals(1, car.getRight().size());
    assertEquals(this.sqlgGraph.getSqlDialect().getPublicSchema() + ".E_drives", car.getLeft().iterator().next().toString());
    Pair<Set<SchemaTable>, Set<SchemaTable>> model = localTabels.get(SchemaTable.of(this.sqlgGraph.getSqlDialect().getPublicSchema(), "V_Model"));
    assertEquals(1, model.getLeft().size());
    assertEquals(0, model.getRight().size());
    assertEquals(this.sqlgGraph.getSqlDialect().getPublicSchema() + ".E_model", model.getLeft().iterator().next().toString());
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Set(java.util.Set) SchemaTable(org.umlg.sqlg.structure.SchemaTable) Pair(org.apache.commons.lang3.tuple.Pair) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Example 58 with Person

use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.

the class TestBatch method testVerticesBatchOn.

@Test
public void testVerticesBatchOn() throws InterruptedException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    this.sqlgGraph.tx().normalBatchModeOn();
    for (int i = 0; i < 10000; i++) {
        Vertex v1 = this.sqlgGraph.addVertex(T.label, "MO1", "name", "marko" + i);
        Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "marko" + i);
        v1.addEdge("Friend", v2, "name", "xxx");
    }
    this.sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println(stopWatch.toString());
    testVerticesBatchOn_assert(this.sqlgGraph);
    if (this.sqlgGraph1 != null) {
        Thread.sleep(1000);
        testVerticesBatchOn_assert(this.sqlgGraph1);
    }
}
Also used : SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) StopWatch(org.apache.commons.lang3.time.StopWatch) BaseTest(org.umlg.sqlg.test.BaseTest)

Example 59 with Person

use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.

the class TestBatch method testPerformance.

@Test
public void testPerformance() throws InterruptedException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    this.sqlgGraph.tx().normalBatchModeOn();
    for (int i = 0; i < 10000; i++) {
        Vertex person = this.sqlgGraph.addVertex(T.label, "Person", "name", "marko" + i);
        Vertex spaceTime = this.sqlgGraph.addVertex(T.label, "SpaceTime", "name", "marko" + i);
        Vertex space = this.sqlgGraph.addVertex(T.label, "Space", "name", "marko" + i);
        Vertex time = this.sqlgGraph.addVertex(T.label, "Time", "name", "marko" + i);
        person.addEdge("spaceTime", spaceTime, "context", 1);
        spaceTime.addEdge("space", space, "dimension", 3);
        spaceTime.addEdge("time", time, "dimension", 1);
        if (i != 0 && i % 10000 == 0) {
            this.sqlgGraph.tx().commit();
            this.sqlgGraph.tx().normalBatchModeOn();
        }
    }
    this.sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println(stopWatch.toString());
    stopWatch.reset();
    stopWatch.start();
    testPerformance_assert(this.sqlgGraph);
    if (this.sqlgGraph1 != null) {
        Thread.sleep(1000);
        testPerformance_assert(this.sqlgGraph1);
    }
    stopWatch.stop();
    System.out.println(stopWatch.toString());
}
Also used : SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) StopWatch(org.apache.commons.lang3.time.StopWatch) BaseTest(org.umlg.sqlg.test.BaseTest)

Example 60 with Person

use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.

the class TestBatchStreamVertex method testMilCompleteVertex.

@Test
public void testMilCompleteVertex() throws InterruptedException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    this.sqlgGraph.tx().streamingBatchModeOn();
    for (int i = 1; i < 100_001; i++) {
        LinkedHashMap<String, Object> keyValue = new LinkedHashMap<>();
        for (int j = 0; j < 2; j++) {
            keyValue.put("name" + j, "a" + i);
        }
        this.sqlgGraph.streamVertex("Person", keyValue);
        if (i % 25_000 == 0) {
            this.sqlgGraph.tx().commit();
            this.sqlgGraph.tx().streamingBatchModeOn();
            System.out.println(i);
        }
    }
    this.sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println(stopWatch.toString());
    stopWatch.reset();
    stopWatch.start();
    Assert.assertEquals(100_000L, this.sqlgGraph.traversal().V().has(T.label, "Person").count().next().longValue());
    stopWatch.stop();
    System.out.println(stopWatch.toString());
    if (this.sqlgGraph1 != null) {
        Thread.sleep(SLEEP_TIME);
        Assert.assertEquals(100_000L, this.sqlgGraph1.traversal().V().has(T.label, "Person").count().next().longValue());
    }
}
Also used : StopWatch(org.apache.commons.lang3.time.StopWatch) LinkedHashMap(java.util.LinkedHashMap) BaseTest(org.umlg.sqlg.test.BaseTest)

Aggregations

Test (org.junit.Test)43 BaseTest (org.umlg.sqlg.test.BaseTest)24 StopWatch (org.apache.commons.lang3.time.StopWatch)23 StringUtils (org.apache.commons.lang3.StringUtils)21 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)20 HashMap (java.util.HashMap)18 Map (java.util.Map)17 Optional (java.util.Optional)16 BigDecimal (java.math.BigDecimal)15 Assert (org.junit.Assert)15 Locale (java.util.Locale)14 HasValue (com.vaadin.flow.component.HasValue)13 UI (com.vaadin.flow.component.UI)13 Binding (com.vaadin.flow.data.binder.Binder.Binding)13 BindingBuilder (com.vaadin.flow.data.binder.Binder.BindingBuilder)13 TestTextField (com.vaadin.flow.data.binder.testcomponents.TestTextField)13 Converter (com.vaadin.flow.data.converter.Converter)13 StringToBigDecimalConverter (com.vaadin.flow.data.converter.StringToBigDecimalConverter)13 StringToDoubleConverter (com.vaadin.flow.data.converter.StringToDoubleConverter)13 StringToIntegerConverter (com.vaadin.flow.data.converter.StringToIntegerConverter)13