Search in sources :

Example 51 with Person

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

the class TestBulkWithout method testBulkWithinMultipleHasContainers.

@Test
public void testBulkWithinMultipleHasContainers() throws InterruptedException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    Vertex god = this.sqlgGraph.addVertex(T.label, "God");
    Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 1, "name", "pete");
    god.addEdge("creator", person1);
    Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 2, "name", "pete");
    god.addEdge("creator", person2);
    Vertex person3 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 3, "name", "john");
    god.addEdge("creator", person3);
    Vertex person4 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 4, "name", "pete");
    god.addEdge("creator", person4);
    Vertex person5 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 5, "name", "pete");
    god.addEdge("creator", person5);
    Vertex person6 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 6, "name", "pete");
    god.addEdge("creator", person6);
    Vertex person7 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 7, "name", "pete");
    god.addEdge("creator", person7);
    Vertex person8 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 8, "name", "pete");
    god.addEdge("creator", person8);
    Vertex person9 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 9, "name", "pete");
    god.addEdge("creator", person9);
    Vertex person10 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 10, "name", "pete");
    god.addEdge("creator", person10);
    this.sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println(stopWatch.toString());
    stopWatch.reset();
    stopWatch.start();
    testBulkWithinMultipleHasContainers_assert(this.sqlgGraph);
    if (this.sqlgGraph1 != null) {
        Thread.sleep(SLEEP_TIME);
        testBulkWithinMultipleHasContainers_assert(this.sqlgGraph1);
    }
    stopWatch.stop();
    System.out.println(stopWatch.toString());
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) StopWatch(org.apache.commons.lang3.time.StopWatch) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Example 52 with Person

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

the class TestBulkWithout method testBulkWithout.

@Test
public void testBulkWithout() throws InterruptedException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    if (this.sqlgGraph.getSqlDialect().supportsBatchMode()) {
        this.sqlgGraph.tx().normalBatchModeOn();
    }
    Vertex god = this.sqlgGraph.addVertex(T.label, "God");
    List<String> uuids = new ArrayList<>();
    for (int i = 0; i < 100; i++) {
        String uuid = UUID.randomUUID().toString();
        uuids.add(uuid);
        Vertex person = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", uuid);
        god.addEdge("creator", person);
    }
    this.sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println(stopWatch.toString());
    stopWatch.reset();
    stopWatch.start();
    testBulkWithout_assert(this.sqlgGraph, uuids);
    if (this.sqlgGraph1 != null) {
        Thread.sleep(SLEEP_TIME);
        testBulkWithout_assert(this.sqlgGraph1, uuids);
    }
    stopWatch.stop();
    System.out.println(stopWatch.toString());
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) ArrayList(java.util.ArrayList) StopWatch(org.apache.commons.lang3.time.StopWatch) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Example 53 with Person

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

the class TestBulkWithout method testBulkWithinVertexCompileStep.

@Test
public void testBulkWithinVertexCompileStep() throws InterruptedException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    if (this.sqlgGraph.getSqlDialect().supportsBatchMode()) {
        this.sqlgGraph.tx().normalBatchModeOn();
    }
    Vertex god = this.sqlgGraph.addVertex(T.label, "God");
    List<String> uuids = new ArrayList<>();
    for (int i = 0; i < 100; i++) {
        String uuid = UUID.randomUUID().toString();
        uuids.add(uuid);
        Vertex person = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", uuid);
        god.addEdge("creator", person);
    }
    this.sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println(stopWatch.toString());
    stopWatch.reset();
    stopWatch.start();
    testBulkWithinVertexCompileStep_assert(this.sqlgGraph, god, uuids);
    if (this.sqlgGraph1 != null) {
        Thread.sleep(SLEEP_TIME);
        testBulkWithinVertexCompileStep_assert(this.sqlgGraph1, god, uuids);
    }
    stopWatch.stop();
    System.out.println(stopWatch.toString());
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) ArrayList(java.util.ArrayList) StopWatch(org.apache.commons.lang3.time.StopWatch) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Example 54 with Person

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

the class TestTraversalPerformance method testSpeedWithLargeSchemaFastQuery1.

@Test
public void testSpeedWithLargeSchemaFastQuery1() {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    Map<String, PropertyType> columns = new HashMap<>();
    for (int i = 0; i < 100; i++) {
        columns.put("property_" + i, PropertyType.STRING);
    }
    // Create a large schema, it slows the maps  down
    int NUMBER_OF_SCHEMA_ELEMENTS = 1_000;
    for (int i = 0; i < NUMBER_OF_SCHEMA_ELEMENTS; i++) {
        VertexLabel person = this.sqlgGraph.getTopology().ensureVertexLabelExist("Person_" + i, columns);
        VertexLabel dog = this.sqlgGraph.getTopology().ensureVertexLabelExist("Dog_" + i, columns);
        person.ensureEdgeLabelExist("pet_" + i, dog, columns);
        if (i % 100 == 0) {
            this.sqlgGraph.tx().commit();
        }
    }
    this.sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println("done creating schema time taken " + stopWatch.toString());
    stopWatch.reset();
    stopWatch.start();
    Map<String, Object> columnValues = new HashMap<>();
    for (int i = 0; i < 100; i++) {
        columnValues.put("property_" + i, "asdasdasd");
    }
    for (int i = 0; i < NUMBER_OF_SCHEMA_ELEMENTS; i++) {
        SqlgVertex person = (SqlgVertex) this.sqlgGraph.addVertex("Person_" + i, columnValues);
        SqlgVertex dog = (SqlgVertex) this.sqlgGraph.addVertex("Dog_" + i, columnValues);
        person.addEdgeWithMap("pet_" + i, dog, columnValues);
    }
    this.sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println("done inserting data time taken " + stopWatch.toString());
    stopWatch.reset();
    stopWatch.start();
    for (int i = 0; i < 10_000; i++) {
        Assert.assertEquals(1, this.sqlgGraph.traversal().V().hasLabel("Person_0").out("pet_0").toList().size());
    }
    stopWatch.stop();
    System.out.println("total query time " + stopWatch.toString());
}
Also used : HashMap(java.util.HashMap) VertexLabel(org.umlg.sqlg.structure.topology.VertexLabel) SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) PropertyType(org.umlg.sqlg.structure.PropertyType) StopWatch(org.apache.commons.lang3.time.StopWatch) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Example 55 with Person

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

the class TestForDocs method testHsqldbLargeLoad.

// //Create a 10000 objects, each with 2 properties
// @Test
// public void testAddPersons() {
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// for (int i = 0; i < 10000; i++) {
// this.sqlgGraph.addVertex(T.label, "Person", "prop1", "property1", "prop2", "property2");
// }
// this.sqlgGraph.tx().commit();
// stopWatch.stop();
// System.out.println("Time to insert: " + stopWatch.toString());
// stopWatch.reset();
// stopWatch.start();
// Assert.assertEquals(Long.valueOf(10000), this.sqlgGraph.traversal().V().existVertexLabel(T.label, "Person").count().next());
// stopWatch.stop();
// System.out.println("Time to read: " + stopWatch.toString());
// }
// 
// //Create a 10001 Persons, each with 2 properties and one friend
// @Test
// public void testAddPersonAndFriends() {
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// Vertex previous = this.sqlgGraph.addVertex(T.label, "Person", "name", "first");
// 
// for (int i = 0; i < 10000; i++) {
// Vertex current = this.sqlgGraph.addVertex(T.label, "Person", "name", "current" + i);
// previous.addEdge("friend", current);
// }
// this.sqlgGraph.tx().commit();
// stopWatch.stop();
// System.out.println("Time to insert: " + stopWatch.toString());
// stopWatch.reset();
// stopWatch.start();
// List<Vertex> persons = this.sqlgGraph.traversal().V().<Vertex>existVertexLabel(T.label, "Person").toList();
// Map<Vertex, List<Vertex>> friendMap = new HashMap<>();
// persons.forEach(
// p -> friendMap.put(p, p.in("friend").toList())
// );
// Assert.assertEquals(10001, friendMap.size());
// stopWatch.stop();
// System.out.println("Time to read all vertices: " + stopWatch.toString());
// }
// 
// @Test
// public void testPostgresBatchMode() {
// this.sqlgGraph.tx().normalBatchModeOn();
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// for (int i = 1; i < 1000001; i++) {
// Vertex person = this.sqlgGraph.addVertex(T.label, "Person", "name", "John" + i);
// Vertex dog = this.sqlgGraph.addVertex(T.label, "Dog", "name", "snowy" + i);
// person.addEdge("pet", dog);
// if (i % 100000 == 0) {
// this.sqlgGraph.tx().commit();
// this.sqlgGraph.tx().normalBatchModeOn();
// }
// }
// this.sqlgGraph.tx().commit();
// stopWatch.stop();
// System.out.println("Time to insert: " + stopWatch.toString());
// stopWatch.reset();
// stopWatch.start();
// 
// Assert.assertEquals(1000000, this.sqlgGraph.traversal().V().<Vertex>existVertexLabel(T.label, "Person").count().next().intValue());
// Assert.assertEquals(1000000, this.sqlgGraph.traversal().V().<Vertex>existVertexLabel(T.label, "Dog").count().next().intValue());
// 
// stopWatch.stop();
// System.out.println("Time to read all vertices: " + stopWatch.toString());
// }
@Test
public void testHsqldbLargeLoad() {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    for (int i = 1; i < 1000001; i++) {
        Vertex person = this.sqlgGraph.addVertex(T.label, "Person", "name", "John" + i);
        Vertex dog = this.sqlgGraph.addVertex(T.label, "Dog", "name", "snowy" + i);
        person.addEdge("pet", dog);
        if (i % 100000 == 0) {
            this.sqlgGraph.tx().commit();
        }
    }
    this.sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println("Time to insert: " + stopWatch.toString());
    stopWatch.reset();
    stopWatch.start();
    Assert.assertEquals(1000000, this.sqlgGraph.traversal().V().<Vertex>has(T.label, "Person").count().next().intValue());
    Assert.assertEquals(1000000, this.sqlgGraph.traversal().V().<Vertex>has(T.label, "Dog").count().next().intValue());
    stopWatch.stop();
    System.out.println("Time to read all vertices: " + stopWatch.toString());
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) StopWatch(org.apache.commons.lang3.time.StopWatch) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

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