use of org.umlg.sqlg.structure.SqlgVertex in project sqlg by pietermartin.
the class TestGremlinCompileWithHas method testHasLabelOut.
@Test
public void testHasLabelOut() {
SqlgVertex a1 = (SqlgVertex) this.sqlgGraph.addVertex(T.label, "A");
SqlgVertex b1 = (SqlgVertex) this.sqlgGraph.addVertex(T.label, "B", "name", "b1");
a1.addEdge("outB", b1);
this.sqlgGraph.tx().commit();
DefaultGraphTraversal<Vertex, Vertex> traversal = (DefaultGraphTraversal) this.sqlgGraph.traversal().V().both().has(T.label, "B");
Assert.assertEquals(3, traversal.getSteps().size());
printTraversalForm(traversal);
Assert.assertEquals(1, traversal.getSteps().size());
List<Vertex> softwares = traversal.toList();
Assert.assertEquals(1, softwares.size());
for (Vertex software : softwares) {
if (!software.label().equals("B")) {
Assert.fail("expected label B found " + software.label());
}
}
}
use of org.umlg.sqlg.structure.SqlgVertex in project sqlg by pietermartin.
the class TestBatchStreamEdge method testEdgePropertiesRemainsTheSame.
@Test(expected = IllegalStateException.class)
public void testEdgePropertiesRemainsTheSame() {
SqlgVertex v1 = (SqlgVertex) this.sqlgGraph.addVertex(T.label, "A");
SqlgVertex v2 = (SqlgVertex) this.sqlgGraph.addVertex(T.label, "A");
this.sqlgGraph.tx().commit();
this.sqlgGraph.tx().streamingBatchModeOn();
LinkedHashMap<String, Object> keyValues = new LinkedHashMap<>();
keyValues.put("name", "halo");
v1.streamEdge("a", v2, keyValues);
keyValues.clear();
keyValues.put("namea", "halo");
v1.streamEdge("a", v2, keyValues);
Assert.fail();
}
use of org.umlg.sqlg.structure.SqlgVertex 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;
}
use of org.umlg.sqlg.structure.SqlgVertex in project sqlg by pietermartin.
the class TestBatchStreamEdge method testStreamLocalDateTime.
@Test
public void testStreamLocalDateTime() throws InterruptedException {
this.sqlgGraph.tx().streamingBatchModeOn();
LinkedHashMap<String, Object> keyValues = new LinkedHashMap<>();
keyValues.put("name", "halo");
keyValues.put("surname", "halo");
for (int i = 0; i < 10; i++) {
keyValues.put("age", i);
this.sqlgGraph.streamVertex("Man", keyValues);
}
this.sqlgGraph.tx().flush();
for (int i = 0; i < 10; i++) {
keyValues.put("age", i);
this.sqlgGraph.streamVertex("Female", keyValues);
}
this.sqlgGraph.tx().flush();
int count = 0;
List<Vertex> men = this.sqlgGraph.traversal().V().hasLabel("Man").toList();
List<Vertex> females = this.sqlgGraph.traversal().V().hasLabel("Female").toList();
LinkedHashMap<String, Object> edgeKeyValues = new LinkedHashMap<>();
LocalDateTime now = LocalDateTime.now();
edgeKeyValues.put("localDateTime", now);
for (Vertex man : men) {
SqlgVertex female = (SqlgVertex) females.get(count++);
((SqlgVertex) man).streamEdge("married", female, edgeKeyValues);
}
this.sqlgGraph.tx().commit();
testStreamLocalDateTime_assert(this.sqlgGraph, now);
if (this.sqlgGraph1 != null) {
Thread.sleep(SLEEP_TIME);
testStreamLocalDateTime_assert(this.sqlgGraph1, now);
}
}
use of org.umlg.sqlg.structure.SqlgVertex in project sqlg by pietermartin.
the class TestBatchStreamEdge method testEdgePropertiesSameOrder.
@Test(expected = IllegalStateException.class)
public void testEdgePropertiesSameOrder() {
SqlgVertex v1 = (SqlgVertex) this.sqlgGraph.addVertex(T.label, "A");
SqlgVertex v2 = (SqlgVertex) this.sqlgGraph.addVertex(T.label, "A");
this.sqlgGraph.tx().commit();
this.sqlgGraph.tx().streamingBatchModeOn();
LinkedHashMap<String, Object> keyValues = new LinkedHashMap<>();
keyValues.put("name", "halo");
keyValues.put("surname", "test");
v1.streamEdge("a", v2, keyValues);
keyValues.clear();
keyValues.put("surname", "test");
keyValues.put("name", "halo");
v1.streamEdge("a", v2, keyValues);
Assert.fail();
}
Aggregations