org.apache.tinkerpop.gremlin.structure.T Java Examples
The following examples show how to use
org.apache.tinkerpop.gremlin.structure.T.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestTraversalFilterStepBarrier.java From sqlg with MIT License | 6 votes |
@Test public void testWhereVertexStepTraversalStep1() { Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "name", "a1"); Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "name", "a2"); Vertex b1 = this.sqlgGraph.addVertex(T.label, "B", "name", "b1"); Vertex b2 = this.sqlgGraph.addVertex(T.label, "B", "name", "b2"); Vertex b3 = this.sqlgGraph.addVertex(T.label, "B", "name", "b3"); a1.addEdge("ab", b1); a1.addEdge("ab", b2); a1.addEdge("ab", b3); a2.addEdge("ab", b1); this.sqlgGraph.tx().commit(); GraphTraversal<Vertex, Vertex> traversal = this.sqlgGraph.traversal().V().hasLabel("A").where(__.out()); List<Vertex> vertices = traversal.toList(); Assert.assertEquals(2, vertices.size()); }
Example #2
Source File: OrderTest.java From tinkerpop with Apache License 2.0 | 6 votes |
@Test @LoadGraphWith(MODERN) public void g_VX1X_elementMap_orderXlocalX_byXkeys_descXunfold() { final Traversal<Vertex, ?> traversal = get_g_VX1X_elementMap_orderXlocalX_byXkeys_descXunfold(convertToVertexId(graph, "marko")); printTraversalForm(traversal); final Object name = traversal.next(); assertEquals("name", getKey(name)); final Object label = traversal.next(); assertEquals(T.label, getKey(label)); final Object id = traversal.next(); assertEquals(T.id, getKey(id)); final Object age = traversal.next(); assertEquals("age", getKey(age)); assertThat(traversal.hasNext(), is(false)); }
Example #3
Source File: TestBatchStreamVertex.java From sqlg with MIT License | 6 votes |
@Test public void testStreamJson() throws InterruptedException { ObjectMapper objectMapper = new ObjectMapper(); ObjectNode json = new ObjectNode(objectMapper.getNodeFactory()); json.put("username", "john"); this.sqlgGraph.tx().streamingBatchModeOn(); for (int i = 0; i < 10; i++) { this.sqlgGraph.streamVertex(T.label, "Person", "doc", json); } this.sqlgGraph.tx().commit(); testStreamJson_assert(this.sqlgGraph, json); if (this.sqlgGraph1 != null) { Thread.sleep(SLEEP_TIME); testStreamJson_assert(this.sqlgGraph1, json); } }
Example #4
Source File: TestWhereWithSelect.java From sqlg with MIT License | 6 votes |
@Test public void g_V_asXaX_out_asXbX_whereXin_count_isXeqX3XX_or_whereXoutXcreatedX_and_hasXlabel_personXXX_selectXa_bX() { loadModern(); final Traversal<Vertex, Map<String, Object>> traversal = this.sqlgGraph.traversal() .V().as("a").out().as("b") .where( __.as("b").in().count().is(P.eq(3)) .or() .where( __.as("b").out("created").and().as("b").has(T.label, "person")) ) .select("a", "b"); printTraversalForm(traversal); // while (traversal.hasNext()) { // System.out.println(traversal.next()); // } checkResults(makeMapList(2, "a", convertToVertex(this.sqlgGraph, "marko"), "b", convertToVertex(this.sqlgGraph, "josh"), "a", convertToVertex(this.sqlgGraph, "marko"), "b", convertToVertex(this.sqlgGraph, "lop"), "a", convertToVertex(this.sqlgGraph, "peter"), "b", convertToVertex(this.sqlgGraph, "lop"), "a", convertToVertex(this.sqlgGraph, "josh"), "b", convertToVertex(this.sqlgGraph, "lop")), traversal); }
Example #5
Source File: HugeElement.java From hugegraph with Apache License 2.0 | 6 votes |
@Watched(prefix = "element") public static final Object getLabelValue(Object... keyValues) { Object labelValue = null; for (int i = 0; i < keyValues.length; i = i + 2) { if (keyValues[i].equals(T.label)) { labelValue = keyValues[i + 1]; E.checkArgument(labelValue instanceof String || labelValue instanceof VertexLabel, "Expect a string or a VertexLabel object " + "as the vertex label argument, but got: '%s'", labelValue); if (labelValue instanceof String) { ElementHelper.validateLabel((String) labelValue); } break; } } return labelValue; }
Example #6
Source File: TestGremlinCompileWhereLocalDate.java From sqlg with MIT License | 6 votes |
@Test public void testEqualsZonedDateTime2() throws InterruptedException { ZoneId zoneId1 = ZoneId.of("Africa/Harare"); ZonedDateTime born1 = ZonedDateTime.of(1999, 1, 1, 1, 1, 1, 0, zoneId1); ZoneId zoneId2 = ZoneId.of("Asia/Tokyo"); ZonedDateTime born2 = ZonedDateTime.of(1999, 1, 1, 1, 1, 1, 0, zoneId2); System.out.println(born1.isAfter(born2)); Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "johnny", "born", born1); Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "pietie", "born", born2); this.sqlgGraph.tx().commit(); testEqualsZonedDateTime2_assert(this.sqlgGraph, born2); if (this.sqlgGraph1 != null) { Thread.sleep(SLEEP_TIME); testEqualsZonedDateTime2_assert(this.sqlgGraph1, born2); } }
Example #7
Source File: TestBatchNormalUpdatePrimitiveArrays.java From sqlg with MIT License | 6 votes |
@Test public void testBatchUpdateArrayshort() throws InterruptedException { Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsShortArrayValues()); this.sqlgGraph.tx().normalBatchModeOn(); Vertex god = this.sqlgGraph.addVertex(T.label, "GOD", "array", new short[]{2, 1}); this.sqlgGraph.tx().commit(); this.sqlgGraph.tx().normalBatchModeOn(); god = this.sqlgGraph.traversal().V(god.id()).next(); god.property("array", new short[]{4, 5}); this.sqlgGraph.tx().commit(); testBatchUpdateArrayshort_assert(this.sqlgGraph, god); if (this.sqlgGraph1 != null){ sleep(SLEEP_TIME); testBatchUpdateArrayshort_assert(this.sqlgGraph1, god); } }
Example #8
Source File: PerfExample3.java From hugegraph with Apache License 2.0 | 6 votes |
@Override protected void testInsert(GraphManager graph, int times, int multiple) { final int TIMES = times * multiple; final int BATCH = 100; long total = 0; // Insert in order for (int i = 0; i < TIMES; i++) { for (int j = 0; j < BATCH; j++) { String name = String.format("p-%08d", total++); Vertex v = graph.addVertex(T.label, "person", "name", name, "city", "Hongkong", "age", 3); this.vertices.add(v.id()); } graph.tx().commit(); } }
Example #9
Source File: NativeNeo4jIndexCheck.java From tinkerpop with Apache License 2.0 | 6 votes |
@Test public void shouldDoLabelsNamespaceBehavior() { graph.tx().readWrite(); this.getBaseGraph().execute("CREATE INDEX ON :Person(name)", null); this.getBaseGraph().execute("CREATE INDEX ON :Product(name)", null); this.getBaseGraph().execute("CREATE INDEX ON :Corporate(name)", null); this.graph.tx().commit(); this.graph.addVertex(T.label, "Person", "name", "marko"); this.graph.addVertex(T.label, "Person", "name", "john"); this.graph.addVertex(T.label, "Person", "name", "pete"); this.graph.addVertex(T.label, "Product", "name", "marko"); this.graph.addVertex(T.label, "Product", "name", "john"); this.graph.addVertex(T.label, "Product", "name", "pete"); this.graph.addVertex(T.label, "Corporate", "name", "marko"); this.graph.addVertex(T.label, "Corporate", "name", "john"); this.graph.addVertex(T.label, "Corporate", "name", "pete"); this.graph.tx().commit(); assertEquals(1, this.g.V().has(T.label, "Person").has("name", "marko").has(T.label, "Person").count().next(), 0); assertEquals(1, this.g.V().has(T.label, "Product").has("name", "marko").has(T.label, "Product").count().next(), 0); assertEquals(1, this.g.V().has(T.label, "Corporate").has("name", "marko").has(T.label, "Corporate").count().next(), 0); assertEquals(0, this.g.V().has(T.label, "Person").has("name", "marko").has(T.label, "Product").count().next(), 0); assertEquals(0, this.g.V().has(T.label, "Product").has("name", "marko").has(T.label, "Person").count().next(), 0); assertEquals(0, this.g.V().has(T.label, "Corporate").has("name", "marko").has(T.label, "Person").count().next(), 0); }
Example #10
Source File: TestGraphStepWithIds.java From sqlg with MIT License | 6 votes |
@Test public void testGraphWithIdsGroupingOfIdsAccordingToLabel() { Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "name", "a1"); Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "name", "a2"); Vertex b1 = this.sqlgGraph.addVertex(T.label, "B", "name", "b1"); Vertex b2 = this.sqlgGraph.addVertex(T.label, "B", "name", "b2"); Vertex b3 = this.sqlgGraph.addVertex(T.label, "B", "name", "b3"); Vertex c1 = this.sqlgGraph.addVertex(T.label, "C", "name", "c1"); Edge e1 = b3.addEdge("bc", c1); this.sqlgGraph.tx().commit(); List<Vertex> vertices = this.sqlgGraph.traversal().V(new Object[]{a1, a2, b1, b2, b3}).toList(); Assert.assertEquals(5, vertices.size()); vertices = this.sqlgGraph.traversal().V(new Object[]{a1, a2, b1, b2, b3}).outE().outV().toList(); Assert.assertEquals(1, vertices.size()); List<Object> values =this.sqlgGraph.traversal().E(e1.id()).inV().values("name").toList(); Assert.assertEquals(1, values.size()); }
Example #11
Source File: TestGremlinCompileWhereLocalDate.java From sqlg with MIT License | 6 votes |
@Test public void testEqualsZonedDateTime() throws InterruptedException { ZoneId zoneId = ZoneId.of("Africa/Harare"); ZonedDateTime born1 = ZonedDateTime.of(1999, 1, 1, 1, 1, 1, 0, zoneId); ZonedDateTime born2 = ZonedDateTime.of(1999, 1, 1, 1, 1, 2, 0, zoneId); ZonedDateTime born3 = ZonedDateTime.of(1999, 1, 1, 1, 1, 3, 0, zoneId); Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "johnny", "born", born1); Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "pietie", "born", born2); Vertex v3 = this.sqlgGraph.addVertex(T.label, "Person", "name", "koosie", "born", born3); this.sqlgGraph.tx().commit(); testEqualsZonedDateTime_assert(this.sqlgGraph, born1, born2, born3, v1, v2, v3); if (this.sqlgGraph1 != null) { Thread.sleep(SLEEP_TIME); testEqualsZonedDateTime_assert(this.sqlgGraph1, born1, born2, born3, v1, v2, v3); } }
Example #12
Source File: TestLocalDateArray.java From sqlg with MIT License | 6 votes |
@Test public void testPeriodArrayOnEdge() { Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsIntegerArrayValues()); Period[] periods = new Period[]{Period.of(2016, 5, 5), Period.of(2015, 4, 4)}; Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "periods", periods); Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "periods", periods); a1.addEdge("aa", a2, "periods", periods); this.sqlgGraph.tx().commit(); //Create a new sqlgGraph try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) { List<? extends Property<Period[]>> properties = sqlgGraph1.traversal().E().hasLabel("aa").<Period[]>properties("periods").toList(); Assert.assertEquals(1, properties.size()); Assert.assertTrue(properties.get(0).isPresent()); Period[] periodsFromDb = properties.get(0).value(); Assert.assertArrayEquals(periods, periodsFromDb); } }
Example #13
Source File: TestBatchNormalPrimitive.java From sqlg with MIT License | 6 votes |
@Test public void testShort() throws InterruptedException { this.sqlgGraph.tx().normalBatchModeOn(); Set<Vertex> vertexSet = new HashSet<>(); Set<Short> vertexNameSet = new HashSet<>(); for (Short i = 0; i < 10; i++) { vertexSet.add(this.sqlgGraph.addVertex(T.label, "A", "name", i)); vertexNameSet.add(i); } this.sqlgGraph.tx().commit(); testShort_assert(this.sqlgGraph, vertexSet, vertexNameSet); if (this.sqlgGraph1 != null) { Thread.sleep(SLEEP_TIME); testShort_assert(this.sqlgGraph1, vertexSet, vertexNameSet); } }
Example #14
Source File: TestBatchNormalUpdateDateTime.java From sqlg with MIT License | 6 votes |
@Test public void testLocalDateTimeUpdateNull() throws InterruptedException { this.sqlgGraph.tx().normalBatchModeOn(); LocalDateTime localDateTime = LocalDateTime.now(); Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "localDateTime1", localDateTime); Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "localDateTime2", localDateTime); Vertex a3 = this.sqlgGraph.addVertex(T.label, "A", "localDateTime3", localDateTime); this.sqlgGraph.tx().commit(); this.sqlgGraph.tx().normalBatchModeOn(); LocalDateTime localDateTimeAgain = LocalDateTime.now().plusDays(1); a1.property("localDateTime1", localDateTimeAgain); a2.property("localDateTime2", localDateTimeAgain); a3.property("localDateTime3", localDateTimeAgain); this.sqlgGraph.tx().commit(); testLocalDateTimeUpdateNull_assert(this.sqlgGraph, a1, a2, a3, localDateTimeAgain); if (this.sqlgGraph1 != null) { Thread.sleep(SLEEP_TIME); testLocalDateTimeUpdateNull_assert(this.sqlgGraph1, a1, a2, a3, localDateTimeAgain); } }
Example #15
Source File: TestEdgeCache.java From sqlg with MIT License | 6 votes |
@Test public void testMultipleEdgesFromSameVertex() { Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "mike"); Vertex v2 = this.sqlgGraph.addVertex(T.label, "Car", "name", "bmw"); Vertex v3 = this.sqlgGraph.addVertex(T.label, "Car", "name", "bmw"); Vertex v4 = this.sqlgGraph.addVertex(T.label, "Bike", "name", "ktm"); v1.addEdge("bts_aaaaaa", v2); v1.addEdge("bts_btsalmtos", v4); v1.addEdge("bts_btsalm", v3); this.sqlgGraph.tx().commit(); this.sqlgGraph.close(); try (SqlgGraph sqlgGraph = SqlgGraph.open(configuration)) { v1 = sqlgGraph.traversal().V(v1.id()).next(); assertEquals(1, sqlgGraph.traversal().V(v1.id()).out("bts_btsalm").count().next().intValue()); assertEquals(1, sqlgGraph.traversal().V(v1.id()).out("bts_btsalmtos").count().next().intValue()); } }
Example #16
Source File: FramedGraphTest.java From Ferma with Apache License 2.0 | 6 votes |
@Test public void testKeyValuesByClass() { final Graph g = TinkerGraph.open(); final FramedGraph fg = new DelegatingFramedGraph(g, true, false); final Person p1 = fg.addFramedVertex(Programmer.class, "key", "value"); p1.setName("Bryn"); final Person p2 = fg.addFramedVertex(Person.class, T.label, "label"); p2.setName("Julia"); final Person bryn = fg.traverse( input -> input.V().has("key", "value")).next(Person.class); final Person julia = fg.traverse( input -> input.V().hasLabel("label")).next(Person.class); Assert.assertEquals(Programmer.class, bryn.getClass()); Assert.assertEquals(Person.class, julia.getClass()); Assert.assertNotNull(bryn.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).value()); Assert.assertNotNull(julia.getElement().property(PolymorphicTypeResolver.TYPE_RESOLUTION_KEY).value()); }
Example #17
Source File: TestGraphStepOrderBy.java From sqlg with MIT License | 6 votes |
@SuppressWarnings("Duplicates") @Test public void testSelectBeforeOrder() { Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "name", "a1"); Vertex b1 = this.sqlgGraph.addVertex(T.label, "B", "name", "b1"); Vertex b2 = this.sqlgGraph.addVertex(T.label, "B", "name", "b2"); Vertex b3 = this.sqlgGraph.addVertex(T.label, "B", "name", "b3"); a1.addEdge("ab", b1, "weight", 3); a1.addEdge("ab", b2, "weight", 2); a1.addEdge("ab", b3, "weight", 1); this.sqlgGraph.tx().commit(); List<String> names = this.sqlgGraph.traversal() .V() .outE().as("e") .inV().as("v") .select("e") .order().by("weight", Order.incr) .select("v") .<String>values("name") .dedup() .toList(); Assert.assertEquals(3, names.size()); Assert.assertEquals("b3", names.get(0)); Assert.assertEquals("b2", names.get(1)); Assert.assertEquals("b1", names.get(2)); }
Example #18
Source File: TestAndandOrStep.java From sqlg with MIT License | 6 votes |
@Test public void testAndOrNestedWithHasAndHasNot() { Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "name", "a1"); Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "name", "a2", "surname", "s2"); this.sqlgGraph.tx().commit(); DefaultGraphTraversal<Vertex, Vertex> traversal = (DefaultGraphTraversal<Vertex, Vertex>) this.sqlgGraph.traversal().V().hasLabel("A") .or( __.and( __.hasNot("surname"), __.has("name", "a1") ), __.and( __.has("surname"), __.has("name", "a2") ) ); List<Vertex> vertices = traversal.toList(); Assert.assertEquals(1, traversal.getSteps().size()); Assert.assertEquals(2, vertices.size()); Assert.assertTrue(vertices.containsAll(Arrays.asList(a1, a2))); }
Example #19
Source File: TestReadOnlyRole.java From sqlg with MIT License | 6 votes |
@Test public void testReadOnlyRoleOnSchema() throws ConfigurationException { TopologyGrantListener topologyGrantListener = new TopologyGrantListener(); this.sqlgGraph.getTopology().registerListener(topologyGrantListener); this.sqlgGraph.addVertex(T.label, "A.A", "name", "a1"); this.sqlgGraph.addVertex(T.label, "A.A", "name", "a2"); this.sqlgGraph.tx().commit(); Configuration readOnlyConfiguration = new PropertiesConfiguration("sqlg.readonly.properties"); try (SqlgGraph readOnlyGraph = SqlgGraph.open(readOnlyConfiguration)) { List<Vertex> vertices = readOnlyGraph.traversal().V().hasLabel("A.A").toList(); Assert.assertEquals(2, vertices.size()); try { readOnlyGraph.addVertex(T.label, "A.A", "name", "a3"); Assert.fail("Graph is suppose to be readOnly"); } catch (Exception ignore) { } } }
Example #20
Source File: TestHasLabelAndId.java From sqlg with MIT License | 6 votes |
@Test public void testGraphStepHasLabelWithinCollection() { Vertex a = this.sqlgGraph.addVertex(T.label, "A"); Vertex b = this.sqlgGraph.addVertex(T.label, "B"); Vertex c = this.sqlgGraph.addVertex(T.label, "C"); Vertex d = this.sqlgGraph.addVertex(T.label, "D"); this.sqlgGraph.tx().commit(); GraphTraversal<Vertex, Vertex> traversal = this.sqlgGraph.traversal().V().hasLabel("A", "B"); printTraversalForm(traversal); Assert.assertEquals(2, traversal.toList().size()); traversal = this.sqlgGraph.traversal().V().hasLabel(P.within("A", "B")); Assert.assertEquals(2, traversal.toList().size()); traversal = this.sqlgGraph.traversal().V().hasLabel(P.within(new HashSet<>(Arrays.asList("A", "B")))); Assert.assertEquals(2, traversal.toList().size()); Assert.assertEquals(0, this.sqlgGraph.traversal().V(a, b).hasLabel(P.within("C")).toList().size()); List<Vertex> vertices = this.sqlgGraph.traversal().V(a, b).hasLabel(P.within(new HashSet<>(Arrays.asList("A", "B", "D")))).toList(); Assert.assertEquals(2, vertices.size()); }
Example #21
Source File: TestBatch.java From sqlg with MIT License | 6 votes |
@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); } }
Example #22
Source File: TestTopology.java From sqlg with MIT License | 6 votes |
@Test public void testTopologyTraversal() { Vertex gis = this.sqlgGraph.addVertex(T.label, "Gis", "name", "HaloGis1"); Vertex something = this.sqlgGraph.addVertex(T.label, "Something", "name", "Something1"); gis.addEdge("testEdge", something, "edgeProperty", "asdasd"); this.sqlgGraph.tx().commit(); Assert.assertEquals(2, this.sqlgGraph.topology().V().hasLabel("sqlg_schema.schema").out("schema_vertex").count().next().intValue()); Assert.assertEquals(2, this.sqlgGraph.topology().V().hasLabel("sqlg_schema.vertex").in("schema_vertex").count().next().intValue()); Assert.assertEquals(2, this.sqlgGraph.topology().V().hasLabel("sqlg_schema.vertex").out("vertex_property").count().next().intValue()); Assert.assertEquals(2, this.sqlgGraph.topology().V().hasLabel("sqlg_schema.property").in("vertex_property").count().next().intValue()); Assert.assertEquals(1, this.sqlgGraph.topology().V().hasLabel("sqlg_schema.property").in("edge_property").count().next().intValue()); Vertex v = this.sqlgGraph.topology().V().hasLabel("sqlg_schema.schema").has("name", "public").next(); Assert.assertTrue(v.edges(Direction.OUT, "schema_vertex").hasNext()); Assert.assertEquals(2, this.sqlgGraph.topology().V().hasLabel("sqlg_schema.schema").as("schema").select("schema").out("schema_vertex").count().next().intValue()); Assert.assertEquals(2, this.sqlgGraph.topology().V().hasLabel("sqlg_schema.schema").as("schema").values("name").as("schemaName").select("schema").out("schema_vertex").count().next().intValue()); Assert.assertTrue(this.sqlgGraph.topology().V().hasLabel("sqlg_schema.schema").as("schema").values("name").as("schemaName").select("schema").out("schema_vertex").hasNext()); Assert.assertEquals("testEdge", this.sqlgGraph.topology().V().hasLabel("sqlg_schema.property").in("edge_property").values("name").next()); }
Example #23
Source File: TestBatchNormalUpdatePrimitiveArrays.java From sqlg with MIT License | 6 votes |
@Test public void testShortArrayUpdateNull() throws InterruptedException { this.sqlgGraph.tx().normalBatchModeOn(); Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsShortArrayValues()); Short[] shortArray = new Short[]{1, 2}; Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "shortArray1", shortArray); Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "shortArray2", shortArray); Vertex a3 = this.sqlgGraph.addVertex(T.label, "A", "shortArray3", shortArray); this.sqlgGraph.tx().commit(); this.sqlgGraph.tx().normalBatchModeOn(); Short[] shortArrayAgain = new Short[]{3, 4}; a1.property("shortArray1", shortArrayAgain); a2.property("shortArray2", shortArrayAgain); a3.property("shortArray3", shortArrayAgain); this.sqlgGraph.tx().commit(); testShortArrayUpdateNull_assert(this.sqlgGraph, a1, a2, a3, shortArrayAgain); if (this.sqlgGraph1 != null) { sleep(SLEEP_TIME); testShortArrayUpdateNull_assert(this.sqlgGraph1, a1, a2, a3, shortArrayAgain); } }
Example #24
Source File: TestGisBulkWithin.java From sqlg with MIT License | 5 votes |
@Test public void testBulkWithinGeographyPoint() { GeographyPoint point1 = new GeographyPoint(26.2044, 28.0456); GeographyPoint point2 = new GeographyPoint(26.2045, 28.0457); GeographyPoint point3 = new GeographyPoint(26.2046, 28.0458); GeographyPoint point4 = new GeographyPoint(26.2047, 28.0459); Vertex v1 = this.sqlgGraph.addVertex(T.label, "Gis", "point", point1); Vertex v2 = this.sqlgGraph.addVertex(T.label, "Gis", "point", point2); Vertex v3 = this.sqlgGraph.addVertex(T.label, "Gis", "point", point3); Vertex v4 = this.sqlgGraph.addVertex(T.label, "Gis", "point", point4); this.sqlgGraph.tx().commit(); List<Vertex> vertices = this.sqlgGraph.traversal().V().hasLabel("Gis").has("point", P.within(point1, point3, point4)).toList(); Assert.assertEquals(3, vertices.size()); Assert.assertTrue(Arrays.asList(v1, v3, v4).containsAll(vertices)); }
Example #25
Source File: TestPropertyValues.java From sqlg with MIT License | 5 votes |
@Test public void testOptimizePastSelect() { Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "name", "a1"); Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "name", "a2"); Vertex b1 = this.sqlgGraph.addVertex(T.label, "B", "name", "b1"); Vertex b2 = this.sqlgGraph.addVertex(T.label, "B", "name", "b2"); Vertex c1 = this.sqlgGraph.addVertex(T.label, "C", "name", "c1"); Vertex c2 = this.sqlgGraph.addVertex(T.label, "C", "name", "c2"); Vertex d1 = this.sqlgGraph.addVertex(T.label, "D", "name", "d1", "surname", "s1"); Vertex d2 = this.sqlgGraph.addVertex(T.label, "D", "name", "d2", "surname", "s2"); a1.addEdge("ab", b1); a2.addEdge("ab", b2); b1.addEdge("bc", c1); b2.addEdge("bc", c2); c1.addEdge("cd", d1); c2.addEdge("cd", d2); this.sqlgGraph.tx().commit(); Traversal<Vertex, String> traversal = this.sqlgGraph.traversal() .V().hasLabel("C") .has("name", "c2") .as("c") .in("bc") .in("ab") .has("name", "a2") .select("c") .out("cd") .has("name", "d2") .values("surname"); printTraversalForm(traversal); List<String> surnames = traversal.toList(); Assert.assertEquals(1, surnames.size()); Assert.assertEquals("s2", surnames.get(0)); checkRestrictedProperties(SqlgVertexStep.class, traversal, 0, "surname"); }
Example #26
Source File: TestGetById.java From sqlg with MIT License | 5 votes |
@Test public void testGetEdgeById() { Vertex marko = this.sqlgGraph.addVertex(T.label, "Person", "name", "marko"); Vertex john = this.sqlgGraph.addVertex(T.label, "Person", "name", "john"); Edge friendEdge = marko.addEdge("friend", john); Edge familyEdge = marko.addEdge("family", john); this.sqlgGraph.tx().commit(); Assert.assertEquals(friendEdge, this.sqlgGraph.traversal().E(friendEdge.id()).next()); Assert.assertEquals(familyEdge, this.sqlgGraph.traversal().E(familyEdge.id()).next()); }
Example #27
Source File: TinkerGraphIdManagerTest.java From tinkergraph-gremlin with Apache License 2.0 | 5 votes |
@Test public void shouldUseLongIdManagerToCoerceTypes() { final Graph graph = TinkerGraph.open(longIdManagerConfig); final Vertex v = graph.addVertex(T.id, vertexIdValue); final VertexProperty vp = v.property(VertexProperty.Cardinality.single, "test", "id", T.id, vertexPropertyIdValue); final Edge e = v.addEdge("self", v, T.id, edgeIdValue); assertEquals(100l, v.id()); assertEquals(200l, e.id()); assertEquals(300l, vp.id()); }
Example #28
Source File: TestBatchStreamVertex.java From sqlg with MIT License | 5 votes |
@Test(expected = IllegalStateException.class) public void testCanNotQueryFromGraphEdgesWhileStreaming() { Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person"); Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person"); v1.addEdge("friend", v2); this.sqlgGraph.tx().commit(); this.sqlgGraph.tx().streamingBatchModeOn(); for (int i = 0; i < 100; i++) { this.sqlgGraph.streamVertex("Person"); } Assert.assertEquals(102, IteratorUtils.count(this.sqlgGraph.edges()), 1); this.sqlgGraph.tx().commit(); }
Example #29
Source File: TestGremlinCompileGraphStep.java From sqlg with MIT License | 5 votes |
@Test public void testE() throws InterruptedException { Vertex a1 = this.sqlgGraph.addVertex(T.label, "A"); Vertex b1 = this.sqlgGraph.addVertex(T.label, "B"); Vertex b2 = this.sqlgGraph.addVertex(T.label, "B"); Edge e1 = a1.addEdge("ab", b1); Edge e2 = a1.addEdge("ab", b2); this.sqlgGraph.tx().commit(); testE_assert(this.sqlgGraph, e1, e2); if (this.sqlgGraph1 != null) { Thread.sleep(SLEEP_TIME); testE_assert(this.sqlgGraph1, e1, e2); } }
Example #30
Source File: TestOutE.java From sqlg with MIT License | 5 votes |
@Test public void testOutEWithLabels() { Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "p"); Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person"); Vertex v3 = this.sqlgGraph.addVertex(T.label, "Person"); v1.addEdge("aaa", v2); v1.addEdge("bbb", v3); this.sqlgGraph.tx().commit(); Assert.assertEquals(1, vertexTraversal(this.sqlgGraph, v1).outE("aaa").count().next().intValue()); Assert.assertEquals(1, this.sqlgGraph.traversal().V().has("name", "p").outE("aaa").count().next().intValue()); }