You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/05/28 16:19:29 UTC
incubator-tinkerpop git commit: added a choose(predicate,
trueTraversal, falseTraversal) test and fixed a bug. Removed MapTraversal,
MapTraverserTraversal, FilterTraversal,
and FilterTraverserTraversal as these are simply __.map(function) and
__.filter(pre
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master f1b142748 -> 19bc34985
added a choose(predicate,trueTraversal,falseTraversal) test and fixed a bug. Removed MapTraversal, MapTraverserTraversal, FilterTraversal, and FilterTraverserTraversal as these are simply __.map(function) and __.filter(predicate). Tweaked up GraphTraversal to use this new pattern. Compressed by()-methods to always call the most general method as opposed to all by()-methods implementing the addLocalChild() logic.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/19bc3498
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/19bc3498
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/19bc3498
Branch: refs/heads/master
Commit: 19bc3498588ec3cd8a39131a986904d5236eb1da
Parents: f1b1427
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu May 28 08:19:40 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu May 28 08:19:40 2015 -0600
----------------------------------------------------------------------
CHANGELOG.asciidoc | 4 +-
.../traversal/dsl/graph/GraphTraversal.java | 183 ++++++++++++++-----
.../traversal/lambda/FilterTraversal.java | 52 ------
.../lambda/FilterTraverserTraversal.java | 52 ------
.../process/traversal/lambda/MapTraversal.java | 52 ------
.../traversal/lambda/MapTraverserTraversal.java | 52 ------
.../step/branch/GroovyChooseTest.groovy | 9 +-
.../traversal/step/branch/ChooseTest.java | 18 +-
8 files changed, 166 insertions(+), 256 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/19bc3498/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index dfafb33..62e22d5 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -25,12 +25,14 @@ image::http://www.tinkerpop.com/docs/current/images/gremlin-hindu.png[width=225]
TinkerPop 3.0.0.GA (NOT OFFICIALLY RELEASED YET)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+* Fixed a bug in `GraphTraversal.choose(predicate,trueTraversal,falseTraversal)`.
+* Removed `MapTraversal`, `MapTraverserTraversal`, `FilterTraversal`, and `FilterTraverserTraversal` as these are simply `__.map(function)` and `__.filter(predicate)`.
* Include `hadoop-gremlin` Hadoop configuration sample files in Gremlin Console distribution.
* Iteration of results in Gremlin Server occur in the same thread as evaluation and prior to transaction close.
* TinkerGraphComputer now supports every `ResultGraph`/`Persist` combination.
* `GraphComputerTest` extended with validation of the semantics of all `ResultGraph`/`Persist` combinations.
* GiraphGraphComputer no longer requires an extra iteration and MapReduce job to derive the full `Memory` result.
-* SparkGraphComputer now supports `InputRDD` to allow vendors/users to use a `SparkContext` to generate the adjacency list representation.
+* SparkGraphComputer now supports `InputRDD` and `OutputRDD` to allow vendors/users to use a `SparkContext` to read/write the graph adjacency list.
* Added `Scope.getScopeValueByKey()` static method so all "selecting" steps use the same pattern for map, path, and sideEffect data retrieval.
TinkerPop 3.0.0.M9 (Release Date: May 26, 2015)
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/19bc3498/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index 3fdb5ba..83f19a1 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
@@ -18,23 +18,125 @@
*/
package org.apache.tinkerpop.gremlin.process.traversal.dsl.graph;
-import org.apache.tinkerpop.gremlin.process.traversal.*;
-import org.apache.tinkerpop.gremlin.process.traversal.lambda.*;
+import org.apache.tinkerpop.gremlin.process.traversal.Order;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.Path;
+import org.apache.tinkerpop.gremlin.process.traversal.Scope;
+import org.apache.tinkerpop.gremlin.process.traversal.Step;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.lambda.ElementValueTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.lambda.IdentityTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.lambda.LoopTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.lambda.TokenTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.lambda.TrueTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.step.ComparatorHolder;
import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalOptionParent;
import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import org.apache.tinkerpop.gremlin.process.traversal.step.branch.*;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.*;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.*;
+import org.apache.tinkerpop.gremlin.process.traversal.step.branch.BranchStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.branch.ChooseStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.branch.LocalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.branch.UnionStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.AndStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.CoinStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.CyclicPathStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DedupGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DropStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.IsStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.LambdaFilterStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.SampleGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.SimplePathStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.TailGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.TimeLimitStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.WhereStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.AddEdgeByPathStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.AddEdgeStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.AddVertexStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.CoalesceStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.CountGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.CountLocalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.DedupLocalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.EdgeOtherVertexStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.EdgeVertexStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.FoldStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroupCountStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroupStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.IdStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.KeyStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.LabelStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.LambdaFlatMapStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.LambdaMapStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.MaxGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.MaxLocalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.MeanGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.MeanLocalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.MinGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.MinLocalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderLocalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.PathStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertyMapStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertyValueStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.RangeLocalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.SackStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.SampleLocalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.SelectOneStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.SelectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.SumGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.SumLocalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.TailLocalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.TreeStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.UnfoldStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.match.MatchStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.*;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.*;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.AddPropertyStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.AggregateStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupCountSideEffectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupSideEffectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IdentityStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.LambdaSideEffectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ProfileStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SackElementValueStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SackObjectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectCapStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StartStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StoreStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SubgraphStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.TreeSideEffectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.ElementFunctionComparator;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.ElementValueComparator;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.NoOpBarrierStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.TraversalComparator;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalP;
-import org.apache.tinkerpop.gremlin.structure.*;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.PropertyType;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.apache.tinkerpop.gremlin.util.function.ConstantSupplier;
-import java.util.*;
-import java.util.function.*;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.BiFunction;
+import java.util.function.BinaryOperator;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.Predicate;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -176,7 +278,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
return this.asAdmin().addStep(new PathStep<>(this.asAdmin()));
}
- public default <E2> GraphTraversal<S, Map<String, E2>> match(final String startLabel, final Traversal<?,?>... traversals) {
+ public default <E2> GraphTraversal<S, Map<String, E2>> match(final String startLabel, final Traversal<?, ?>... traversals) {
return (GraphTraversal) this.asAdmin().addStep(new MatchStep<E, Map<String, E2>>(this.asAdmin(), startLabel, traversals));
}
@@ -342,7 +444,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
return this.where(scope, null, predicate);
}
- public default GraphTraversal<S, E> where(final Scope scope, final Traversal<?,?> whereTraversal) {
+ public default GraphTraversal<S, E> where(final Scope scope, final Traversal<?, ?> whereTraversal) {
return this.where(scope, P.traversal(whereTraversal));
}
@@ -354,7 +456,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
return this.where(Scope.global, null, predicate);
}
- public default GraphTraversal<S, E> where(final Traversal<?,?> whereTraversal) {
+ public default GraphTraversal<S, E> where(final Traversal<?, ?> whereTraversal) {
return this.where(Scope.global, whereTraversal);
}
@@ -382,7 +484,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
return this.has(T.label, label).has(key, value);
}
- public default GraphTraversal<S, E> has(final String key, final Traversal<?,?> propertyTraversal) {
+ public default GraphTraversal<S, E> has(final String key, final Traversal<?, ?> propertyTraversal) {
return this.has(key, P.traversal(propertyTraversal));
}
@@ -547,7 +649,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
}
public default <M, E2> GraphTraversal<S, E2> branch(final Function<Traverser<E>, M> function) {
- return this.branch(new MapTraverserTraversal<>(function));
+ return this.branch(__.map(function));
}
public default <M, E2> GraphTraversal<S, E2> choose(final Traversal<?, M> choiceTraversal) {
@@ -559,11 +661,11 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
}
public default <M, E2> GraphTraversal<S, E2> choose(final Function<E, M> choiceFunction) {
- return this.choose(new MapTraversal<>(choiceFunction));
+ return this.choose(__.<E, M>map(e -> choiceFunction.apply(e.get())));
}
public default <E2> GraphTraversal<S, E2> choose(final Predicate<E> choosePredicate, final Traversal<?, E2> trueChoice, final Traversal<?, E2> falseChoice) {
- return this.choose(new FilterTraversal<>(choosePredicate), trueChoice, falseChoice);
+ return this.choose(__.<E>filter(e -> choosePredicate.test(e.get())), trueChoice, falseChoice);
}
public default <E2> GraphTraversal<S, E2> union(final Traversal<?, E2>... unionTraversals) {
@@ -583,7 +685,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
}
public default GraphTraversal<S, E> emit(final Predicate<Traverser<E>> emitPredicate) {
- return this.emit(new FilterTraverserTraversal<>(emitPredicate));
+ return this.emit(__.filter(emitPredicate));
}
public default GraphTraversal<S, E> emit() {
@@ -595,7 +697,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
}
public default GraphTraversal<S, E> until(final Predicate<Traverser<E>> untilPredicate) {
- return this.until(new FilterTraverserTraversal<>(untilPredicate));
+ return this.until(__.filter(untilPredicate));
}
public default GraphTraversal<S, E> times(final int maxLoops) {
@@ -624,56 +726,48 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
////
- public default GraphTraversal<S, E> by() {
- ((TraversalParent) this.asAdmin().getEndStep()).addLocalChild(new IdentityTraversal<>());
+ public default GraphTraversal<S, E> by(final Traversal<?, ?> byTraversal) {
+ ((TraversalParent) this.asAdmin().getEndStep()).addLocalChild(byTraversal.asAdmin());
return this;
}
+ public default GraphTraversal<S, E> by() {
+ return this.by(new IdentityTraversal<>());
+ }
+
public default <V> GraphTraversal<S, E> by(final Function<V, Object> functionProjection) {
- ((TraversalParent) this.asAdmin().getEndStep()).addLocalChild(new MapTraversal<>(functionProjection));
- return this;
+ return this.by(__.<V, Object>map(v -> functionProjection.apply(v.get())));
}
public default GraphTraversal<S, E> by(final T tokenProjection) {
- ((TraversalParent) this.asAdmin().getEndStep()).addLocalChild(new TokenTraversal<>(tokenProjection));
- return this;
+ return this.by(new TokenTraversal<>(tokenProjection));
}
public default GraphTraversal<S, E> by(final String elementPropertyKey) {
- ((TraversalParent) this.asAdmin().getEndStep()).addLocalChild(new ElementValueTraversal<>(elementPropertyKey));
- return this;
- }
-
- public default GraphTraversal<S, E> by(final Traversal<?, ?> byTraversal) {
- ((TraversalParent) this.asAdmin().getEndStep()).addLocalChild(byTraversal.asAdmin());
- return this;
+ return this.by(new ElementValueTraversal<>(elementPropertyKey));
}
////
- public default GraphTraversal<S, E> by(final Order order) {
- ((ComparatorHolder) this.asAdmin().getEndStep()).addComparator(order);
- return this;
- }
-
public default GraphTraversal<S, E> by(final Comparator<E> comparator) {
((ComparatorHolder<E>) this.asAdmin().getEndStep()).addComparator(comparator);
return this;
}
+ public default GraphTraversal<S, E> by(final Order order) {
+ return this.by((Comparator) order);
+ }
+
public default <V> GraphTraversal<S, E> by(final Function<Element, V> elementFunctionProjection, final Comparator<V> elementFunctionValueComparator) {
- ((ComparatorHolder<Element>) this.asAdmin().getEndStep()).addComparator(new ElementFunctionComparator<>(elementFunctionProjection, elementFunctionValueComparator));
- return this;
+ return this.by((Comparator) new ElementFunctionComparator<>(elementFunctionProjection, elementFunctionValueComparator));
}
public default <V> GraphTraversal<S, E> by(final String elementPropertyProjection, final Comparator<V> propertyValueComparator) {
- ((ComparatorHolder<Element>) this.asAdmin().getEndStep()).addComparator(new ElementValueComparator<>(elementPropertyProjection, propertyValueComparator));
- return this;
+ return this.by((Comparator) new ElementValueComparator<>(elementPropertyProjection, propertyValueComparator));
}
public default <V> GraphTraversal<S, E> by(final Traversal<?, ?> traversal, final Comparator<V> endComparator) {
- ((ComparatorHolder<E>) this.asAdmin().getEndStep()).addComparator(new TraversalComparator(traversal.asAdmin(), endComparator));
- return this;
+ return this.by(new TraversalComparator(traversal.asAdmin(), endComparator));
}
////
@@ -684,8 +778,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
}
public default <E2> GraphTraversal<S, E> option(final Traversal<E, E2> traversalOption) {
- ((TraversalOptionParent<TraversalOptionParent.Pick, E, E2>) this.asAdmin().getEndStep()).addGlobalChildOption(TraversalOptionParent.Pick.any, traversalOption.asAdmin());
- return this;
+ return this.option(TraversalOptionParent.Pick.any, traversalOption.asAdmin());
}
////
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/19bc3498/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/FilterTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/FilterTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/FilterTraversal.java
deleted file mode 100644
index 0e1aba0..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/FilterTraversal.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.traversal.lambda;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.step.LambdaHolder;
-
-import java.util.function.Predicate;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class FilterTraversal<S, E> extends AbstractLambdaTraversal<S, E> implements LambdaHolder {
-
- private boolean filter = true;
- private final Predicate<S> predicate;
-
- public FilterTraversal(final Predicate<S> predicate) {
- this.predicate = predicate;
- }
-
- @Override
- public boolean hasNext() {
- return this.filter;
- }
-
- @Override
- public void addStart(final Traverser<S> start) {
- this.filter = this.predicate.test(start.get());
- }
-
- @Override
- public String toString() {
- return this.predicate.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/19bc3498/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/FilterTraverserTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/FilterTraverserTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/FilterTraverserTraversal.java
deleted file mode 100644
index e50395c..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/FilterTraverserTraversal.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.traversal.lambda;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.step.LambdaHolder;
-
-import java.util.function.Predicate;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class FilterTraverserTraversal<S, E> extends AbstractLambdaTraversal<S, E> implements LambdaHolder {
-
- private boolean filter = true;
- private final Predicate<Traverser<S>> predicate;
-
- public FilterTraverserTraversal(final Predicate<Traverser<S>> predicate) {
- this.predicate = predicate;
- }
-
- @Override
- public boolean hasNext() {
- return this.filter;
- }
-
- @Override
- public void addStart(final Traverser<S> start) {
- this.filter = this.predicate.test(start);
- }
-
- @Override
- public String toString() {
- return this.predicate.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/19bc3498/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/MapTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/MapTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/MapTraversal.java
deleted file mode 100644
index 2fab4ec..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/MapTraversal.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.traversal.lambda;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.step.LambdaHolder;
-
-import java.util.function.Function;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class MapTraversal<S, E> extends AbstractLambdaTraversal<S, E> implements LambdaHolder {
-
- private E e;
- private final Function<S, E> function;
-
- public MapTraversal(final Function<S, E> function) {
- this.function = function;
- }
-
- @Override
- public E next() {
- return this.e;
- }
-
- @Override
- public void addStart(final Traverser<S> start) {
- this.e = this.function.apply(start.get());
- }
-
- @Override
- public String toString() {
- return this.function.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/19bc3498/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/MapTraverserTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/MapTraverserTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/MapTraverserTraversal.java
deleted file mode 100644
index fc1131e..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/MapTraverserTraversal.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.traversal.lambda;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.step.LambdaHolder;
-
-import java.util.function.Function;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class MapTraverserTraversal<S, E> extends AbstractLambdaTraversal<S, E> implements LambdaHolder {
-
- private E e;
- private final Function<Traverser<S>, E> function;
-
- public MapTraverserTraversal(final Function<Traverser<S>, E> function) {
- this.function = function;
- }
-
- @Override
- public E next() {
- return this.e;
- }
-
- @Override
- public void addStart(final Traverser<S> start) {
- this.e = this.function.apply(start);
- }
-
- @Override
- public String toString() {
- return this.function.toString();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/19bc3498/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyChooseTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyChooseTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyChooseTest.groovy
index 6fea6b0..cb3bb3e 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyChooseTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyChooseTest.groovy
@@ -22,6 +22,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalScriptHelper
import org.apache.tinkerpop.gremlin.process.traversal.Traversal
import org.apache.tinkerpop.gremlin.structure.Vertex
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.out
+
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
* @author Joshua Shinavier (http://fortytwo.net)
@@ -31,7 +33,12 @@ public abstract class GroovyChooseTest {
public static class Traversals extends ChooseTest {
@Override
public Traversal<Vertex, Object> get_g_V_chooseXout_countX_optionX2L__nameX_optionX3L__valueMapX() {
- TraversalScriptHelper.compute("g.V.choose(__.out.count).option(2L, __.values('name')).option(3L, __.valueMap())", g);
+ TraversalScriptHelper.compute("g.V.choose(__.out.count).option(2L, __.values('name')).option(3L, __.valueMap())", g)
+ }
+
+ @Override
+ public Traversal<Vertex, String> get_g_V_chooseXlabel_eqXpersonX__outXknowsX__inXcreatedXX_name() {
+ TraversalScriptHelper.compute("g.V.choose({it.label() == 'person'}, out('knows'), __.in('created')).name",g)
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/19bc3498/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/ChooseTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/ChooseTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/ChooseTest.java
index bad2d77..26bd466 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/ChooseTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/ChooseTest.java
@@ -22,12 +22,12 @@ import org.apache.tinkerpop.gremlin.LoadGraphWith;
import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
import org.apache.tinkerpop.gremlin.process.GremlinProcessRunner;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.MapHelper;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@@ -45,6 +45,9 @@ public abstract class ChooseTest extends AbstractGremlinProcessTest {
public abstract Traversal<Vertex, Object> get_g_V_chooseXout_countX_optionX2L__nameX_optionX3L__valueMapX();
+ public abstract Traversal<Vertex, String> get_g_V_chooseXlabel_eqXpersonX__outXknowsX__inXcreatedXX_name();
+
+
@Test
@LoadGraphWith(MODERN)
public void g_V_chooseXout_countX_optionX2L__nameX_optionX3L__valueMapX() {
@@ -63,6 +66,14 @@ public abstract class ChooseTest extends AbstractGremlinProcessTest {
assertEquals(Long.valueOf(1), counts.get("josh"));
}
+ @Test
+ @LoadGraphWith(MODERN)
+ public void g_V_chooseXlabel_eqXpersonX__outXknowsX__inXcreatedXX_name() {
+ final Traversal<Vertex, String> traversal = get_g_V_chooseXlabel_eqXpersonX__outXknowsX__inXcreatedXX_name();
+ printTraversalForm(traversal);
+ checkResults(Arrays.asList("josh", "vadas", "josh", "josh", "marko", "peter"), traversal);
+ }
+
public static class Traversals extends ChooseTest {
@Override
@@ -71,5 +82,10 @@ public abstract class ChooseTest extends AbstractGremlinProcessTest {
.option(2L, values("name"))
.option(3L, valueMap());
}
+
+ @Override
+ public Traversal<Vertex, String> get_g_V_chooseXlabel_eqXpersonX__outXknowsX__inXcreatedXX_name() {
+ return g.V().choose(v -> v.label().equals("person"), out("knows"), in("created")).values("name");
+ }
}
}
\ No newline at end of file