use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLoadArrayProperties method testLoadSchemaWithArraysWithoutFloat.
@Test
public void testLoadSchemaWithArraysWithoutFloat() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsBooleanArrayValues() && this.sqlgGraph.getSqlDialect().supportsLongArrayValues() && this.sqlgGraph.getSqlDialect().supportsIntegerArrayValues() && this.sqlgGraph.getSqlDialect().supportsDoubleArrayValues() && this.sqlgGraph.getSqlDialect().supportsStringArrayValues());
this.sqlgGraph.addVertex(T.label, "Person", "aBoolean", new boolean[] { true }, "aShort", new short[] { (short) 1 }, "aInteger", new int[] { 1 }, "aLong", new long[] { 1L }, "aDouble", new double[] { 1D }, "aString", new String[] { "aaaaaaaaaaaaa" });
this.sqlgGraph.tx().commit();
this.sqlgGraph.close();
try (SqlgGraph sqlgGraph = SqlgGraph.open(configuration)) {
Iterator<Vertex> iter = sqlgGraph.traversal().V().has(T.label, "Person");
Assert.assertTrue(iter.hasNext());
Vertex v = iter.next();
Assert.assertTrue(Arrays.equals(new boolean[] { true }, (boolean[]) v.property("aBoolean").value()));
Assert.assertTrue(Arrays.equals(new short[] { (short) 1 }, (short[]) v.property("aShort").value()));
Assert.assertTrue(Arrays.equals(new int[] { 1 }, (int[]) v.property("aInteger").value()));
Assert.assertTrue(Arrays.equals(new long[] { 1L }, (long[]) v.property("aLong").value()));
Assert.assertTrue(Arrays.equals(new double[] { 1d }, (double[]) v.property("aDouble").value()));
Assert.assertTrue(Arrays.equals(new String[] { "aaaaaaaaaaaaa" }, (String[]) v.property("aString").value()));
}
try (SqlgGraph sqlgGraph = SqlgGraph.open(configuration)) {
Iterator<Vertex> iter = sqlgGraph.traversal().V().has(T.label, "Person");
Assert.assertTrue(iter.hasNext());
Vertex v = iter.next();
Assert.assertTrue(Arrays.equals(new boolean[] { true }, (boolean[]) v.property("aBoolean").value()));
Assert.assertTrue(Arrays.equals(new short[] { (short) 1 }, (short[]) v.property("aShort").value()));
Assert.assertTrue(Arrays.equals(new int[] { 1 }, (int[]) v.property("aInteger").value()));
Assert.assertTrue(Arrays.equals(new long[] { 1L }, (long[]) v.property("aLong").value()));
Assert.assertTrue(Arrays.equals(new double[] { 1d }, (double[]) v.property("aDouble").value()));
Assert.assertTrue(Arrays.equals(new String[] { "aaaaaaaaaaaaa" }, (String[]) v.property("aString").value()));
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestTopologyMultipleGraphs method testDeepEqualsPublicSchema.
@Test
public void testDeepEqualsPublicSchema() throws InterruptedException {
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
Vertex a1 = this.sqlgGraph.addVertex(T.label, "A");
this.sqlgGraph.tx().commit();
Thread.sleep(1_000);
assertTrue(this.sqlgGraph.getTopology().equals(sqlgGraph1.getTopology()));
a1.property("test", "asdasd");
this.sqlgGraph.tx().commit();
Thread.sleep(1_000);
assertTrue(this.sqlgGraph.getTopology().equals(sqlgGraph1.getTopology()));
Vertex b1 = this.sqlgGraph.addVertex(T.label, "B", "name", "b1");
this.sqlgGraph.tx().commit();
Thread.sleep(1_000);
assertTrue(this.sqlgGraph.getTopology().equals(sqlgGraph1.getTopology()));
a1.addEdge("ab", b1);
this.sqlgGraph.tx().commit();
Thread.sleep(1_000);
assertTrue(this.sqlgGraph.getTopology().equals(sqlgGraph1.getTopology()));
Vertex bb1 = this.sqlgGraph.addVertex(T.label, "BB", "name", "bb1");
a1.addEdge("ab", bb1);
this.sqlgGraph.tx().commit();
Thread.sleep(1_000);
assertTrue(this.sqlgGraph.getTopology().equals(sqlgGraph1.getTopology()));
Vertex aa1 = this.sqlgGraph.addVertex(T.label, "AA", "name", "aa1");
Edge ab = aa1.addEdge("ab", bb1);
this.sqlgGraph.tx().commit();
Thread.sleep(1_000);
assertTrue(this.sqlgGraph.getTopology().equals(sqlgGraph1.getTopology()));
ab.property("test", "asdasd");
this.sqlgGraph.tx().commit();
Thread.sleep(1_000);
assertTrue(this.sqlgGraph.getTopology().equals(sqlgGraph1.getTopology()));
assertTrue(this.sqlgGraph.getTopology().equals(sqlgGraph1.getTopology()));
} catch (Exception e) {
fail(e.getMessage());
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestTopologyMultipleGraphs method testModernAcrossGraphs.
@Test
public void testModernAcrossGraphs() {
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
loadModern();
Thread.sleep(1000);
assertTrue(this.sqlgGraph.getTopology().equals(sqlgGraph1.getTopology()));
} catch (Exception e) {
fail(e.getMessage());
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestTopologyMultipleGraphs method testDeepEqualsAcrossSchema.
@Test
public void testDeepEqualsAcrossSchema() throws InterruptedException, IOException {
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
Vertex a1 = this.sqlgGraph.addVertex(T.label, "A.A");
this.sqlgGraph.tx().commit();
Thread.sleep(1_000);
assertTrue(this.sqlgGraph.getTopology().equals(sqlgGraph1.getTopology()));
a1.property("test", "asdasd");
this.sqlgGraph.tx().commit();
Thread.sleep(1_000);
assertTrue(this.sqlgGraph.getTopology().equals(sqlgGraph1.getTopology()));
Vertex b1 = this.sqlgGraph.addVertex(T.label, "B.B", "name", "b1");
this.sqlgGraph.tx().commit();
Thread.sleep(1_000);
assertTrue(this.sqlgGraph.getTopology().equals(sqlgGraph1.getTopology()));
a1.addEdge("ab", b1);
this.sqlgGraph.tx().commit();
Thread.sleep(1_000);
assertTrue(this.sqlgGraph.getTopology().equals(sqlgGraph1.getTopology()));
Vertex bb1 = this.sqlgGraph.addVertex(T.label, "BB.BB", "name", "bb1");
a1.addEdge("ab", bb1);
this.sqlgGraph.tx().commit();
Thread.sleep(1_000);
assertTrue(this.sqlgGraph.getTopology().equals(sqlgGraph1.getTopology()));
Vertex aa1 = this.sqlgGraph.addVertex(T.label, "AA.AA", "name", "aa1");
Edge ab = aa1.addEdge("ab", bb1);
this.sqlgGraph.tx().commit();
Thread.sleep(1_000);
assertTrue(this.sqlgGraph.getTopology().equals(sqlgGraph1.getTopology()));
ab.property("test", "asdasd");
this.sqlgGraph.tx().commit();
Thread.sleep(1_000);
assertTrue(this.sqlgGraph.getTopology().equals(sqlgGraph1.getTopology()));
assertEquals(4, this.sqlgGraph.traversal().V().count().next(), 0);
assertEquals(4, sqlgGraph1.traversal().V().count().next(), 0);
assertEquals(3, this.sqlgGraph.traversal().E().count().next(), 0);
assertEquals(3, sqlgGraph1.traversal().E().count().next(), 0);
assertEquals(2, this.sqlgGraph.traversal().V(a1.id()).out("ab").count().next(), 0);
assertEquals(2, sqlgGraph1.traversal().V(a1.id()).out("ab").count().next(), 0);
assertEquals(1, this.sqlgGraph.traversal().V(aa1.id()).out("ab").count().next(), 0);
assertEquals(1, sqlgGraph1.traversal().V(aa1.id()).out("ab").count().next(), 0);
} catch (Exception e) {
fail(e.getMessage());
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestTopologyUpgrade method testUpgrade.
@Test
public void testUpgrade() throws Exception {
// with topology
Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "name", "john");
Object idA1 = a1.id();
Vertex b1 = this.sqlgGraph.addVertex(T.label, "B", "name", "joe");
Object idB1 = b1.id();
a1.addEdge("knows", b1, "name", "hithere");
this.sqlgGraph.tx().commit();
// Delete the topology
dropSqlgSchema(this.sqlgGraph);
this.sqlgGraph.tx().commit();
this.sqlgGraph.close();
// topology will be recreated
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
Assert.assertEquals(2, sqlgGraph1.traversal().V().count().next().intValue());
Assert.assertEquals(1, sqlgGraph1.traversal().E().count().next().intValue());
Assert.assertTrue(sqlgGraph1.traversal().V().hasLabel("A").hasNext());
Assert.assertTrue(sqlgGraph1.traversal().V().hasLabel("B").hasNext());
Assert.assertEquals(1, sqlgGraph1.traversal().V().hasLabel("A").count().next().intValue());
Assert.assertEquals(1, sqlgGraph1.traversal().V().hasLabel("B").count().next().intValue());
Vertex a = sqlgGraph1.traversal().V().hasLabel("A").next();
Assert.assertEquals(idA1, a.id());
Vertex b = sqlgGraph1.traversal().V().hasLabel("B").next();
Assert.assertEquals(idB1, b.id());
Assert.assertEquals(1, sqlgGraph1.traversal().V(a).out("knows").count().next().intValue());
Assert.assertEquals(b, sqlgGraph1.traversal().V(a).out("knows").next());
Assert.assertEquals(1, sqlgGraph1.traversal().V(b).in("knows").count().next().intValue());
Assert.assertEquals(a, sqlgGraph1.traversal().V(b).in("knows").next());
Assert.assertEquals(1, sqlgGraph1.traversal().V(a).properties("name").count().next().intValue());
Assert.assertTrue(sqlgGraph1.traversal().V(a).properties("name").next().isPresent());
Assert.assertEquals("john", sqlgGraph1.traversal().V(a).properties("name").next().value());
Assert.assertEquals(1, sqlgGraph1.traversal().V(a).outE("knows").properties("name").count().next().intValue());
Assert.assertTrue(sqlgGraph1.traversal().V(a).outE("knows").properties("name").next().isPresent());
Assert.assertEquals("hithere", sqlgGraph1.traversal().V(a).outE("knows").properties("name").next().value());
}
// from topology
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
Assert.assertEquals(2, sqlgGraph1.traversal().V().count().next().intValue());
Assert.assertEquals(1, sqlgGraph1.traversal().E().count().next().intValue());
Assert.assertTrue(sqlgGraph1.traversal().V().hasLabel("A").hasNext());
Assert.assertTrue(sqlgGraph1.traversal().V().hasLabel("B").hasNext());
Assert.assertEquals(1, sqlgGraph1.traversal().V().hasLabel("A").count().next().intValue());
Assert.assertEquals(1, sqlgGraph1.traversal().V().hasLabel("B").count().next().intValue());
Vertex a = sqlgGraph1.traversal().V().hasLabel("A").next();
Assert.assertEquals(idA1, a.id());
Vertex b = sqlgGraph1.traversal().V().hasLabel("B").next();
Assert.assertEquals(idB1, b.id());
Assert.assertEquals(1, sqlgGraph1.traversal().V(a).out("knows").count().next().intValue());
Assert.assertEquals(b, sqlgGraph1.traversal().V(a).out("knows").next());
Assert.assertEquals(1, sqlgGraph1.traversal().V(b).in("knows").count().next().intValue());
Assert.assertEquals(a, sqlgGraph1.traversal().V(b).in("knows").next());
Assert.assertEquals(1, sqlgGraph1.traversal().V(a).properties("name").count().next().intValue());
Assert.assertTrue(sqlgGraph1.traversal().V(a).properties("name").next().isPresent());
Assert.assertEquals("john", sqlgGraph1.traversal().V(a).properties("name").next().value());
Assert.assertEquals(1, sqlgGraph1.traversal().V(a).outE("knows").properties("name").count().next().intValue());
Assert.assertTrue(sqlgGraph1.traversal().V(a).outE("knows").properties("name").next().isPresent());
Assert.assertEquals("hithere", sqlgGraph1.traversal().V(a).outE("knows").properties("name").next().value());
}
}
Aggregations