Search in sources :

Example 6 with Person

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

the class TestBatchServerSideEdgeCreation method testBulkEdges2.

@Test
public void testBulkEdges2() throws InterruptedException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    this.sqlgGraph.tx().streamingBatchModeOn();
    List<Pair<String, String>> uids = new ArrayList<>();
    LinkedHashMap properties = new LinkedHashMap();
    String uuid1Cache = null;
    String uuid2Cache = null;
    for (int i = 0; i < 1000; i++) {
        String uuid1 = UUID.randomUUID().toString();
        String uuid2 = UUID.randomUUID().toString();
        if (i == 50) {
            uuid1Cache = uuid1;
            uuid2Cache = uuid2;
        }
        uids.add(Pair.of(uuid1, uuid2));
        properties.put("id", uuid1);
        this.sqlgGraph.streamVertex("Person", properties);
        properties.put("id", uuid2);
        this.sqlgGraph.streamVertex("Person", properties);
    }
    this.sqlgGraph.tx().flush();
    this.sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println(stopWatch.toString());
    stopWatch.reset();
    stopWatch.start();
    this.sqlgGraph.tx().streamingBatchModeOn();
    SchemaTable person = SchemaTable.of(this.sqlgGraph.getSqlDialect().getPublicSchema(), "Person");
    this.sqlgGraph.bulkAddEdges("Person", "Person", "friend", Pair.of("id", "id"), uids);
    this.sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println(stopWatch.toString());
    testBulkEdges2_assert(this.sqlgGraph, uuid1Cache, uuid2Cache);
    if (this.sqlgGraph1 != null) {
        Thread.sleep(SLEEP_TIME);
        testBulkEdges2_assert(this.sqlgGraph1, uuid1Cache, uuid2Cache);
    }
}
Also used : SchemaTable(org.umlg.sqlg.structure.SchemaTable) StopWatch(org.apache.commons.lang3.time.StopWatch) Pair(org.apache.commons.lang3.tuple.Pair) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Example 7 with Person

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

the class TestBatchServerSideEdgeCreation method testBulkEdgesTempTableUnique.

@Test
public void testBulkEdgesTempTableUnique() {
    this.sqlgGraph.tx().streamingBatchModeOn();
    List<Pair<String, String>> uids = new ArrayList<>();
    LinkedHashMap properties = new LinkedHashMap();
    for (int i = 0; i < 1000; i++) {
        String uuid1 = UUID.randomUUID().toString();
        String uuid2 = UUID.randomUUID().toString();
        uids.add(Pair.of(uuid1, uuid2));
        properties.put("id", uuid1);
        this.sqlgGraph.streamVertex("Person", properties);
        properties.put("id", uuid2);
        this.sqlgGraph.streamVertex("Person", properties);
    }
    this.sqlgGraph.tx().flush();
    this.sqlgGraph.tx().streamingBatchModeOn();
    SchemaTable person = SchemaTable.of(this.sqlgGraph.getSqlDialect().getPublicSchema(), "Person");
    this.sqlgGraph.bulkAddEdges("Person", "Person", "friend", Pair.of("id", "id"), uids);
    this.sqlgGraph.tx().commit();
    // and again
    this.sqlgGraph.tx().streamingBatchModeOn();
    uids.clear();
    for (int i = 0; i < 1000; i++) {
        String uuid1 = UUID.randomUUID().toString();
        String uuid2 = UUID.randomUUID().toString();
        uids.add(Pair.of(uuid1, uuid2));
        properties.put("id", uuid1);
        this.sqlgGraph.streamVertex("Person", properties);
        properties.put("id", uuid2);
        this.sqlgGraph.streamVertex("Person", properties);
    }
    this.sqlgGraph.tx().flush();
    this.sqlgGraph.tx().streamingBatchModeOn();
    this.sqlgGraph.bulkAddEdges("Person", "Person", "friend", Pair.of("id", "id"), uids);
    this.sqlgGraph.tx().commit();
}
Also used : SchemaTable(org.umlg.sqlg.structure.SchemaTable) Pair(org.apache.commons.lang3.tuple.Pair) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Example 8 with Person

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

the class TestBatchStreamEdge method createMilPersonVertex.

private ArrayList<SqlgVertex> createMilPersonVertex() {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    ArrayList<SqlgVertex> result = new ArrayList<>();
    this.sqlgGraph.tx().normalBatchModeOn();
    for (int i = 1; i < NUMBER_OF_VERTICES + 1; i++) {
        Map<String, Object> keyValue = new LinkedHashMap<>();
        for (int j = 0; j < 100; j++) {
            keyValue.put("name" + j, "aaaaaaaaaa" + i);
        }
        SqlgVertex person = (SqlgVertex) this.sqlgGraph.addVertex("Person", keyValue);
        result.add(person);
        if (i % (NUMBER_OF_VERTICES / 10) == 0) {
            this.sqlgGraph.tx().commit();
            this.sqlgGraph.tx().normalBatchModeOn();
        }
    }
    this.sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println("createMilPersonVertex took " + stopWatch.toString());
    return result;
}
Also used : SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) ArrayList(java.util.ArrayList) StopWatch(org.apache.commons.lang3.time.StopWatch) LinkedHashMap(java.util.LinkedHashMap)

Example 9 with Person

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

the class TestBatchStreamEdge method testMilCompleteEdges.

@Test
public void testMilCompleteEdges() {
    ArrayList<SqlgVertex> persons = createMilPersonVertex();
    ArrayList<SqlgVertex> cars = createMilCarVertex();
    this.sqlgGraph.tx().commit();
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    this.sqlgGraph.tx().streamingBatchModeOn();
    LinkedHashMap<String, Object> keyValues = new LinkedHashMap<>();
    keyValues.put("name", "halo");
    keyValues.put("name2", "halo");
    for (int i = 0; i < NUMBER_OF_VERTICES; i++) {
        SqlgVertex person = persons.get(0);
        SqlgVertex car = cars.get(i);
        person.streamEdge("person_car", car, keyValues);
    }
    this.sqlgGraph.tx().commit();
    int mb = 1024 * 1024;
    // get Runtime instance
    Runtime instance = Runtime.getRuntime();
    System.out.println("***** Heap utilization statistics [MB] *****\n");
    // available memory
    System.out.println("Total Memory: " + instance.totalMemory() / mb);
    // free memory
    System.out.println("Free Memory: " + instance.freeMemory() / mb);
    // used memory
    System.out.println("Used Memory: " + (instance.totalMemory() - instance.freeMemory()) / mb);
    // Maximum available memory
    System.out.println("Max Memory: " + instance.maxMemory() / mb);
    Assert.assertEquals(NUMBER_OF_VERTICES, this.sqlgGraph.traversal().V(persons.get(0)).out("person_car").toList().size());
    stopWatch.stop();
    System.out.println("testMilCompleteEdges took " + stopWatch.toString());
}
Also used : SqlgVertex(org.umlg.sqlg.structure.SqlgVertex) StopWatch(org.apache.commons.lang3.time.StopWatch) LinkedHashMap(java.util.LinkedHashMap) BaseTest(org.umlg.sqlg.test.BaseTest)

Example 10 with Person

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

the class TestBatch method testEscapingCharacters.

@Test
public void testEscapingCharacters() 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, "test1", "\\", "test2", "\nhalo", "test3", "\rhalo", "test4", "\thalo");
        Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "marko" + i, "test1", "\\", "test2", "\nhalo", "test3", "\rhalo", "test4", "\thalo");
        v1.addEdge("Friend", v2, "name", "xxx");
    }
    this.sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println(stopWatch.toString());
    testEscapingCharacters_assert(this.sqlgGraph);
    if (this.sqlgGraph1 != null) {
        Thread.sleep(1000);
        testEscapingCharacters_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)

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