org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal Java Examples
The following examples show how to use
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal.
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 Project: timbuctoo Author: HuygensING File: DerivedPropertyValueGetterTest.java License: GNU General Public License v3.0 | 6 votes |
@Test public void getValuesReturnsEmptyListIfThePropertyIsNotPresent() { DerivedPropertyValueGetter instance = new DerivedPropertyValueGetter(RELATIONS, RELATION_NAME); GraphTraversal<Vertex, Vertex> traversal = newGraph() .withVertex("finalTarget1", v -> v.withProperty(PROPERTY_NOT_PRESENT, "value1")) .withVertex("finalTarget2", v -> v.withProperty(PROPERTY_NOT_PRESENT, "value2")) .withVertex("target1", v -> v.withOutgoingRelation(RELATION_NAME, "finalTarget1")) .withVertex("target2", v -> v.withOutgoingRelation(RELATION_NAME, "finalTarget2")) .withVertex(v -> v.withOutgoingRelation(RELATIONS[0], "target1")) .withVertex(v -> v.withOutgoingRelation(RELATIONS[0], "target2")) .build().traversal().V(); List<List<String>> results = traversal.toList().stream() .map(v -> instance.getValues(v, PROPERTY)) .filter(r -> r.size() > 0).collect(toList()); assertThat(results, equalTo(Lists.newArrayList())); }
Example #2
Source Project: timbuctoo Author: HuygensING File: RelatedListFacetDescriptionTest.java License: GNU General Public License v3.0 | 6 votes |
@Test public void filterAddsAFilterToTheGraphTraversal() { RelatedListFacetDescription instance = new RelatedListFacetDescription(FACET_NAME, PROPERTY, parser, RELATION); List<FacetValue> facets = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList(VALUE1))); GraphTraversal<Vertex, Vertex> traversal = newGraph() .withVertex("v1", v -> v.withTimId("id1").withProperty(PROPERTY, VALUE1)) .withVertex("v2", v -> v.withTimId("id2").withProperty(PROPERTY, VALUE2)) .withVertex("v3", v -> v.withTimId("id3").withOutgoingRelation(RELATION, "v1")) .withVertex("v4", v -> v.withTimId("id4").withOutgoingRelation(RELATION, "v2")) .build().traversal().V(); instance.filter(traversal, facets); List<Vertex> vertices = traversal.toList(); assertThat(vertices, contains(likeVertex().withTimId("id3"))); }
Example #3
Source Project: sqlg Author: pietermartin File: TestGremlinOptional.java License: MIT License | 6 votes |
@Test public void testOptionalWithNestedOptionalAndRepeat() { Vertex a1 = this.sqlgGraph.addVertex(T.label, "A"); Vertex b1 = this.sqlgGraph.addVertex(T.label, "B"); Vertex c1 = this.sqlgGraph.addVertex(T.label, "C", "name", "halo"); a1.addEdge("ab", b1); b1.addEdge("bc", c1); this.sqlgGraph.tx().commit(); GraphTraversal<Vertex, Path> gt = this.sqlgGraph.traversal().V().hasLabel("A") .out("ab").as("b") .optional( __.outE("bc").otherV().as("c") .optional( __.repeat(__.out("cd")).times(3) ) ) .path(); List<Path> paths = gt.toList(); Assert.assertEquals(1, paths.size()); }
Example #4
Source Project: gremlin-ogm Author: karthicks File: AddV.java License: Apache License 2.0 | 6 votes |
@Override @SneakyThrows public GraphTraversal<Element, Element> apply(GraphTraversalSource g) { GraphTraversal traversal = g.addV(element.label()); if (element.id() != null && HasFeature.Verifier.of(g) .verify(supportsUserSuppliedIds(element))) { traversal.property(T.id, element.id()); } for (Field field : keyFields(element)) { String key = propertyKey(field); Object value = propertyValue(field, element); if (isMissing(value)) { throw org.apache.tinkerpop.gremlin.object.structure.Element.Exceptions.requiredKeysMissing( element.getClass(), key); } traversal.property(key, value); } return traversal; }
Example #5
Source Project: windup Author: windup File: GraphTypeManager.java License: Eclipse Public License 1.0 | 6 votes |
@Override public <P extends Element, T extends Element> GraphTraversal<P, T> hasNotType(GraphTraversal<P, T> traverser, Class<?> type) { String typeValue = getTypeValue((Class<? extends WindupFrame>) type); return traverser.filter(new Predicate<Traverser<T>>() { @Override public boolean test(final Traverser<T> toCheck) { final Property<String> property = toCheck.get().property(WindupFrame.TYPE_PROP); if (!property.isPresent()) return true; final String resolvedType = property.value(); if (typeValue.contains(resolvedType)) return false; else return true; } }); }
Example #6
Source Project: timbuctoo Author: HuygensING File: MultiValueListFacetDescriptionTest.java License: GNU General Public License v3.0 | 6 votes |
@Test public void filterDoesNotAddAFilterWhenTheFacetValueIsNotAListFacetValue() { GraphTraversal<Vertex, Vertex> traversal = newGraph() .withVertex(v -> v.withTimId("id1").withProperty(PROPERTY_NAME, serializedListOf("value1", "value2"))) .withVertex(v -> v.withTimId("id2").withProperty(PROPERTY_NAME, serializedListOf("value2", "value3"))) .withVertex(v -> v.withTimId("id3").withProperty(PROPERTY_NAME, serializedListOf("value1", "value3", "value4"))) .build().traversal().V(); List<FacetValue> facetValues = Lists.newArrayList((FacetValue) () -> FACET_NAME); instance.filter(traversal, facetValues); assertThat(traversal.toList(), containsInAnyOrder( likeVertex().withTimId("id1"), likeVertex().withTimId("id2"), likeVertex().withTimId("id3"))); }
Example #7
Source Project: Ferma Author: Syncleus File: PolymorphicTypeResolver.java License: Apache License 2.0 | 6 votes |
@Override public <P extends Element, T extends Element> GraphTraversal<P, T> hasNotType(final GraphTraversal<P, T> traverser, final Class<?> type) { final Set<? extends String> allAllowedValues = this.reflectionCache.getSubTypeNames(type.getName()); return traverser.filter(new Predicate<Traverser<T>>() { @Override public boolean test(final Traverser<T> toCheck) { final Property<String> property = toCheck.get().property(typeResolutionKey); if( !property.isPresent() ) return true; final String resolvedType = property.value(); if( allAllowedValues.contains(resolvedType) ) return false; else return true; } }); }
Example #8
Source Project: sql-gremlin Author: twilmes File: TraversalBuilder.java License: Apache License 2.0 | 6 votes |
public static GraphTraversal toTraversal(List<RelNode> relList) { final GraphTraversal traversal = __.identity(); TableDef tableDef = null; for(RelNode rel : relList) { if(rel instanceof GremlinTableScan) { GremlinTableScan tableScan = (GremlinTableScan) rel; tableDef = tableScan.getGremlinTable().getTableDef(); traversal.hasLabel(tableDef.label); } if(rel instanceof GremlinFilter) { GremlinFilter filter = (GremlinFilter) rel; RexNode condition = filter.getCondition(); FilterTranslator translator = new FilterTranslator(tableDef, filter.getRowType().getFieldNames()); GraphTraversal predicates = translator.translateMatch(condition); for(Step step : (List<Step>)predicates.asAdmin().getSteps()) { traversal.asAdmin().addStep(step); } } } return traversal; }
Example #9
Source Project: timbuctoo Author: HuygensING File: RelatedDatableRangeFacetDescriptionTest.java License: GNU General Public License v3.0 | 6 votes |
@Test public void filterIncludesTheVerticesWhereOnlyTheStartFallsInTheRange() { GraphTraversal<Vertex, Vertex> traversal = newGraph() .withVertex("target1", v -> v.withTimId("id4").withProperty(PROPERTY_NAME, asSerializedDatable("2015/2020"))) .withVertex("target2", v -> v.withTimId("id5").withProperty(PROPERTY_NAME, asSerializedDatable("0015-01"))) .withVertex("target3", v -> v.withTimId("id6").withProperty(PROPERTY_NAME, asSerializedDatable("0190-01"))) .withVertex("source1", v -> v.withTimId("id1").withOutgoingRelation(RELATION, "target1")) .withVertex("source2", v -> v.withTimId("id2").withOutgoingRelation(RELATION, "target2")) .withVertex("source3", v -> v.withTimId("id3").withOutgoingRelation(RELATION, "target3")) .build().traversal().V(); List<FacetValue> facetValues = Lists.newArrayList(new DateRangeFacetValue(FACET_NAME, 20140101L, 20160101L)); instance.filter(traversal, facetValues); assertThat(traversal.toList(), contains(likeVertex().withTimId("id1"))); }
Example #10
Source Project: hugegraph Author: hugegraph File: HugeTraverser.java License: Apache License 2.0 | 6 votes |
protected Iterator<Edge> edgesOfVertex(Id source, Directions dir, Map<Id, String> labels, Map<String, Object> properties, long limit) { if (properties == null || properties.isEmpty()) { return edgesOfVertex(source, dir, labels.keySet(), limit); } // Use traversal format if has properties filter String[] els = labels.values().toArray(new String[labels.size()]); GraphTraversal<Vertex, Edge> g; g = this.graph().traversal().V(source).toE(dir.direction(), els); for (Map.Entry<String, Object> entry : properties.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (value instanceof List) { g = g.has(key, P.within((Collection<?>) value)); } else { g = g.has(key, value); } } return g.limit(limit); }
Example #11
Source Project: hugegraph Author: hugegraph File: TraversalUtil.java License: Apache License 2.0 | 6 votes |
public static String page(GraphTraversal<?, ?> traversal) { QueryHolder holder = firstPageStep(traversal); E.checkState(holder != null, "Invalid paging traversal: %s", traversal.getClass()); Object page = holder.metadata(PageInfo.PAGE); if (page == null) { return null; } /* * Page is instance of PageInfo if traversal with condition like: * g.V().has("x", 1).has("~page", ""). * Page is instance of PageState if traversal without condition like: * g.V().has("~page", "") */ assert page instanceof PageInfo || page instanceof PageState; return page.toString(); }
Example #12
Source Project: sqlg Author: pietermartin File: TestHasLabelAndId.java License: 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 #13
Source Project: windup Author: windup File: TechnologyTagService.java License: Eclipse Public License 1.0 | 6 votes |
/** * Return an {@link Iterable} containing all {@link TechnologyTagModel}s that are directly associated with the provided {@link FileModel}. */ public Iterable<TechnologyTagModel> findTechnologyTagsForFile(FileModel fileModel) { GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(getGraphContext().getGraph()).V(fileModel.getElement()); pipeline.in(TechnologyTagModel.TECH_TAG_TO_FILE_MODEL).has(WindupVertexFrame.TYPE_PROP, TechnologyTagModel.TYPE); Comparator<TechnologyTagModel> comparator = new DefaultTechnologyTagComparator(); pipeline.order().by((a, b) -> { TechnologyTagModel aModel = getGraphContext().getFramed().frameElement(a, TechnologyTagModel.class); TechnologyTagModel bModel = getGraphContext().getFramed().frameElement(b, TechnologyTagModel.class); return comparator.compare(aModel, bModel); }); return new FramedVertexIterable<>(getGraphContext().getFramed(), pipeline.toList(), TechnologyTagModel.class); }
Example #14
Source Project: timbuctoo Author: HuygensING File: MultiValueListFacetDescriptionTest.java License: GNU General Public License v3.0 | 6 votes |
@Test public void filterDoesNotFilterWhenFacetValuesDoesNotContainTheFacet() { GraphTraversal<Vertex, Vertex> traversal = newGraph() .withVertex(v -> v.withTimId("id1").withProperty(PROPERTY_NAME, serializedListOf("value1", "value2"))) .withVertex(v -> v.withTimId("id2").withProperty(PROPERTY_NAME, serializedListOf("value2", "value3"))) .withVertex(v -> v.withTimId("id3").withProperty(PROPERTY_NAME, serializedListOf("value1", "value3", "value4"))) .build().traversal().V(); List<FacetValue> facetValues = Lists.newArrayList(); instance.filter(traversal, facetValues); assertThat(traversal.toList(), containsInAnyOrder( likeVertex().withTimId("id1"), likeVertex().withTimId("id2"), likeVertex().withTimId("id3"))); }
Example #15
Source Project: timbuctoo Author: HuygensING File: EdgeListFacetDescription.java License: GNU General Public License v3.0 | 6 votes |
@Override public void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facets) { Optional<FacetValue> facetValue = facets.stream().filter(facet -> Objects.equals(facet.getName(), facetName)).findFirst(); if (facetValue.isPresent()) { FacetValue value = facetValue.get(); if (value instanceof ListFacetValue) { List<String> values = ((ListFacetValue) value).getValues(); if (!values.isEmpty()) { graphTraversal.where(__.inE(values.toArray(new String[values.size()]))); } } } }
Example #16
Source Project: graph-examples Author: datastax File: KillrVideoTraversalDsl.java License: Apache License 2.0 | 6 votes |
/** * A simple recommendation algorithm that starts from a "user" and examines movies the user has seen filtered by * the {@code minRating} which removes movies that hold a rating lower than the value specified. It then samples * the actors in the movies the user has seen and uses that to find other movies those actors have been in that * the user has not yet seen. Those movies are grouped, counted and sorted based on that count to produce the * recommendation. * * @param recommendations the number of recommended movies to return * @param minRating the minimum rating to allow for * @param recommender a configuration to supply to the recommendation algorithm to provide control over how * sampling occurs when selecting the initial set of movies to consider * @param include an anonymous traversal that must be "true" for the incoming "movie" vertex to be included in the * recommendation results */ public default GraphTraversal<S, Vertex> recommend(int recommendations, int minRating, Recommender recommender, Traversal include) { if (recommendations <= 0) throw new IllegalArgumentException("recommendations must be greater than zero"); return rated(minRating, 0). aggregate("seen"). local(recommender.getTraversal()). unfold().in(EDGE_ACTOR). where(without("seen")). where(include). groupCount(). order(local). by(values, decr). limit(local,recommendations). select(keys). unfold(); }
Example #17
Source Project: timbuctoo Author: HuygensING File: RelatedMultiValueListFacetDescriptionTest.java License: GNU General Public License v3.0 | 6 votes |
@Test public void filterAddsAFilterToTheGraphTraversal() { RelatedMultiValueListFacetDescription instance = new RelatedMultiValueListFacetDescription(FACET_NAME, PROPERTY, RELATION); List<FacetValue> facets = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList(FACET_VALUE))); GraphTraversal<Vertex, Vertex> traversal = newGraph() .withVertex("v1", v -> v.withTimId("id1").withProperty(PROPERTY, VALUE1)) .withVertex("v2", v -> v.withTimId("id2").withProperty(PROPERTY, VALUE2)) .withVertex("v3", v -> v.withTimId("id3").withOutgoingRelation(RELATION, "v1")) .withVertex("v4", v -> v.withTimId("id4").withOutgoingRelation(RELATION, "v2")) .build().traversal().V(); instance.filter(traversal, facets); List<Vertex> vertices = traversal.toList(); assertThat(vertices, contains(likeVertex().withTimId("id3"))); }
Example #18
Source Project: timbuctoo Author: HuygensING File: EdgeListFacetDescriptionTest.java License: GNU General Public License v3.0 | 6 votes |
@Test public void filterAddsNoFilterIfTheFacetValuesIsEmpty() { List<FacetValue> facetValues = Lists.newArrayList( new ListFacetValue(FACET_NAME, Lists.newArrayList())); SearchRequestV2_1 searchRequest = new SearchRequestV2_1(); searchRequest.setFacetValues(facetValues); GraphTraversal<Vertex, Vertex> traversal = newGraph() .withVertex(v -> v.withTimId("1")) .withVertex(v -> v.withTimId("2")) .build().traversal().V(); instance.filter(traversal, facetValues); assertThat(traversal.toList(), containsInAnyOrder(VertexMatcher.likeVertex().withTimId("1"), VertexMatcher.likeVertex().withTimId("2"))); }
Example #19
Source Project: tinkerpop Author: apache File: GremlinEnabledScriptEngineTest.java License: Apache License 2.0 | 6 votes |
@Test(expected = IllegalArgumentException.class) public void shouldNotAllowBytecodeEvalWithAliasInBindings() throws Exception { final GremlinScriptEngine scriptEngine = manager.getEngineByName(ENGINE_TO_TEST); final Graph graph = EmptyGraph.instance(); final GraphTraversalSource g = graph.traversal(); // purposefully use "x" to match the name of the traversal source binding for "x" below and // thus tests the alias added for "x" final GraphTraversal t = getTraversalWithLambda(g); final Bindings bindings = new SimpleBindings(); bindings.put("x", g); bindings.put(GremlinScriptEngine.HIDDEN_G, g); scriptEngine.eval(t.asAdmin().getBytecode(), bindings, "x"); }
Example #20
Source Project: sqlg Author: pietermartin File: TestTraversalFilterStepBarrier.java License: 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 #21
Source Project: tinkerpop Author: apache File: GremlinEnabledScriptEngineTest.java License: Apache License 2.0 | 6 votes |
@Test(expected = IllegalArgumentException.class) public void shouldNotAllowBytecodeEvalWithInvalidBinding() throws Exception { final GremlinScriptEngine scriptEngine = manager.getEngineByName(ENGINE_TO_TEST); final Graph graph = EmptyGraph.instance(); final GraphTraversalSource g = graph.traversal(); // purposefully use "x" to match the name of the traversal source binding for "x" below and // thus tests the alias added for "x" final GraphTraversal t = getTraversalWithLambda(g); final Bindings bindings = new SimpleBindings(); bindings.put("z", g); bindings.put("x", "invalid-binding-for-x-given-x-should-be-traversal-source"); scriptEngine.eval(t.asAdmin().getBytecode(), bindings, "x"); }
Example #22
Source Project: gremlin-ogm Author: karthicks File: Page.java License: Apache License 2.0 | 5 votes |
@Override @SneakyThrows public GraphTraversal<Element, Element> apply(GraphTraversal<Element, Element> traversal) { return traversal .hasLabel(org.apache.tinkerpop.gremlin.object.reflect.Label.of(elementType)) .range(low, high); }
Example #23
Source Project: tinkerpop Author: apache File: WhereTraversalBuilder.java License: Apache License 2.0 | 5 votes |
private static GraphTraversal<?, ?> transform(final E_Exists expression) { final OpBGP opBGP = (OpBGP) expression.getGraphPattern(); final List<Triple> triples = opBGP.getPattern().getList(); if (triples.size() != 1) throw new IllegalStateException("Unhandled EXISTS pattern"); final GraphTraversal<?, ?> traversal = TraversalBuilder.transform(triples.get(0)); final Step endStep = traversal.asAdmin().getEndStep(); final String label = (String) endStep.getLabels().iterator().next(); endStep.removeLabel(label); return traversal; }
Example #24
Source Project: timbuctoo Author: HuygensING File: CollectionHasEntityRelationChangeListener.java License: GNU General Public License v3.0 | 5 votes |
@Override public void onRemoveFromCollection(Collection collection, Optional<Vertex> oldVertex, Vertex newVertex) { String type = collection.getEntityTypeName(); final GraphTraversal<Vertex, Vertex> hasEntityNode = findEntityNodeForEntityTypeName(type); final GraphTraversal<Vertex, Edge> edgeToRemove = hasEntityNode.outE(Collection.HAS_ENTITY_RELATION_NAME) .where(__.inV().is(newVertex)); if (edgeToRemove.hasNext()) { edgeToRemove.next().remove(); } }
Example #25
Source Project: tinkerpop Author: apache File: JavaTranslatorBenchmark.java License: Apache License 2.0 | 5 votes |
@Benchmark public GraphTraversal.Admin<Vertex,Vertex> testTranslationLong() { return translator.translate(g.V().match( as("a").has("song", "name", "HERE COMES SUNSHINE"), as("a").map(inE("followedBy").values("weight").mean()).as("b"), as("a").inE("followedBy").as("c"), as("c").filter(values("weight").where(P.gte("b"))).outV().as("d")). <String>select("d").by("name").asAdmin().getBytecode()); }
Example #26
Source Project: sqlg Author: pietermartin File: TestBatchNormalPrimitive.java License: MIT License | 5 votes |
private void testShortPrimitiveEdge_assert(SqlgGraph sqlgGraph, short[] edgeNameArray) { GraphTraversal<Edge, Edge> traversal = sqlgGraph.traversal().E(); int count = 0; short[] edgeNameArrayToTest = new short[10]; while (traversal.hasNext()) { Array.set(edgeNameArrayToTest, count++, traversal.next().value("name")); } assertArrayEquals(edgeNameArray, edgeNameArrayToTest); }
Example #27
Source Project: grakn Author: graknlabs File: InAttributeFragment.java License: GNU Affero General Public License v3.0 | 5 votes |
@Override GraphTraversal<Vertex, ? extends Element> applyTraversalInner(GraphTraversal<Vertex, ? extends Element> traversal, ConceptManager conceptManager, Collection<Variable> vars) { // (start) ATTR <-[edge] - OWNER return Fragments.union( Fragments.isVertex(traversal), ImmutableSet.of(attributeToOwners()) ); }
Example #28
Source Project: sqlg Author: pietermartin File: TestHasLabelAndId.java License: MIT License | 5 votes |
@Test public void testGraphStepHasLabelWithin() { this.sqlgGraph.addVertex(T.label, "A"); this.sqlgGraph.addVertex(T.label, "B"); this.sqlgGraph.addVertex(T.label, "C"); 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()); }
Example #29
Source Project: grakn Author: graknlabs File: OutPlaysFragment.java License: GNU Affero General Public License v3.0 | 5 votes |
@Override public GraphTraversal<Vertex, ? extends Element> applyTraversalInner( GraphTraversal<Vertex, ? extends Element> traversal, ConceptManager conceptManager, Collection<Variable> vars) { GraphTraversal<Vertex, Vertex> vertexTraversal = Fragments.outSubs(Fragments.isVertex(traversal)); if (required()) { return vertexTraversal.outE(PLAYS.getLabel()).has(Schema.EdgeProperty.REQUIRED.name()).otherV(); } else { return vertexTraversal.out(PLAYS.getLabel()); } }
Example #30
Source Project: tinkerpop Author: apache File: TraversalConstructionBenchmark.java License: Apache License 2.0 | 5 votes |
@Benchmark public GraphTraversal constructLong() throws Exception { return g.V(). match(as("a").has("song", "name", "HERE COMES SUNSHINE"), as("a").map(inE("followedBy").values("weight").mean()).as("b"), as("a").inE("followedBy").as("c"), as("c").filter(values("weight").where(P.gte("b"))).outV().as("d")). select("d").by("name"); }