This is an automated email from the ASF dual-hosted git repository. spmallette pushed a commit to branch backport-discard in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 84a63415eed27ae82243cd5ca9233f58e029a3ea Author: Stephen Mallette <stepm...@amazon.com> AuthorDate: Sat Aug 2 11:11:42 2025 -0400 Backported 62a3935152354eea54f2cfadc39edf10ebe2005d from 4.x Renames none() to discard() --- CHANGELOG.asciidoc | 3 +- docs/src/reference/the-traversal.asciidoc | 43 +++++++++++++--------- docs/src/upgrade/release-3.3.x.asciidoc | 2 +- docs/src/upgrade/release-3.8.x.asciidoc | 13 +++++++ .../grammar/DefaultGremlinBaseVisitor.java | 2 +- .../language/grammar/TraversalMethodVisitor.java | 4 +- .../gremlin/process/traversal/Traversal.java | 14 +++---- .../traversal/dsl/graph/GraphTraversal.java | 8 ++-- .../gremlin/process/traversal/dsl/graph/__.java | 6 +-- .../filter/{NoneStep.java => DiscardStep.java} | 4 +- .../strategy/optimization/EarlyLimitStrategy.java | 22 +++++------ .../strategy/optimization/LazyBarrierStrategy.java | 4 +- .../optimization/PathRetractionStrategy.java | 8 +--- .../verification/StandardVerificationStrategy.java | 9 ++--- .../process/traversal/util/BytecodeHelper.java | 4 +- .../grammar/TraversalMethodVisitorTest.java | 8 ++-- .../language/grammar/TraversalRootVisitorTest.java | 4 +- .../traversal/dsl/graph/GraphTraversalTest.java | 2 +- .../optimization/EarlyLimitStrategyTest.java | 16 ++++---- .../StandardVerificationStrategyTest.java | 2 +- .../traversal/translator/PythonTranslatorTest.java | 6 +-- .../Process/Traversal/DefaultTraversal.cs | 2 +- .../Process/Traversal/GraphTraversal.cs | 18 ++++----- .../src/Gremlin.Net/Process/Traversal/__.cs | 16 ++++---- .../Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs | 12 +++--- gremlin-go/driver/anonymousTraversal.go | 14 +++---- gremlin-go/driver/cucumber/gremlin.go | 12 +++--- gremlin-go/driver/graphTraversal.go | 12 +++--- gremlin-go/driver/traversal.go | 2 +- .../lib/process/graph-traversal.js | 22 +++++------ .../gremlin-javascript/lib/process/traversal.js | 2 +- .../gremlin-javascript/test/cucumber/gremlin.js | 12 +++--- gremlin-language/src/main/antlr4/Gremlin.g4 | 12 +++--- .../gremlin_python/process/graph_traversal.py | 28 +++++++------- .../python/gremlin_python/process/traversal.py | 2 +- gremlin-python/src/main/python/radish/gremlin.py | 12 +++--- .../process/traversal/CoreTraversalTest.java | 6 +-- .../filter/{None.feature => Discard.feature} | 28 +++++++------- 38 files changed, 206 insertions(+), 190 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 355bf27d67..dbbcf07024 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima This release also includes changes from <<release-3-7-XXX, 3.7.XXX>>. * Removed Vertex/ReferenceVertex from grammar. Use vertex id in traversals now instead. +* Renamed the traversal discarding `none()` step to `discard()`. * Modified mathematical operators to prevent overflows in steps such as `sum()` and 'sack()' to prefer promotion to the next highest number type. * Added `DateTime` ontop of the existing 'datetime' grammar. * Added `UUID()` and `UUID(value)` to grammar. @@ -3017,7 +3018,7 @@ This release also includes changes from <<release-3-2-8, 3.2.8>>. This release also includes changes from <<release-3-2-7, 3.2.7>>. -* Added `NoneStep` and `Traversal.none()` for full filtering integration with `iterate()`. +* Added `DiscardStep` and `Traversal.none()` for full filtering integration with `iterate()`. * Fixed bug in serialization of `Path` for GraphSON 3.0 in `gremlin-python`. * Added support for GraphSON 3.0 in Gremlin.Net. * Added `math()`-step which supports scientific calculator capabilities for numbers within a traversal. diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc index bbc2f106f3..edd28510cb 100644 --- a/docs/src/reference/the-traversal.asciidoc +++ b/docs/src/reference/the-traversal.asciidoc @@ -1508,6 +1508,32 @@ g.V().values("name").fold().difference(__.V().limit(2).values("name").fold()) link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.html#difference(java.lang.Object)++[`difference(Object)`] link:++https://tinkerpop.apache.org/docs/x.y.z/dev/provider/#difference-step++[`Semantics`] +[[discard-step]] +=== Discard Step + +The `discard()`-step (*filter*) filters all objects from a traversal stream. It is helpful with <<branch-step>> types +of steps where a particular branch of code should "throw away" traversers. In the following example, traversers that +don't match are filtered out of the traversal stream. + +[gremlin-groovy,modern] +---- +g.V().choose(T.label). + option("person", __.out("knows").values("name")). + option("bleep", __.out("created").values("name")). + option(none, discard()) +---- + +It is also useful for traversals that are executed remotely where returning results is not useful and the traversal is +only meant to generate side-effects. Choosing not to return results saves in serialization and network costs as the +objects are filtered on the remote end and not returned to the client side. Typically, this step does not need to be +used directly and is quietly used by the `iterate()` terminal step which appends `discard()` to the traversal before +actually cycling through results. + +*Additional References* + +link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/Traversal.html#discard()++[`discard()`] +link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/Traversal.html#iterate()++[`iterate()`] + [[disjunct-step]] === Disjunct Step @@ -3229,23 +3255,6 @@ link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gre link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.html#min(org.apache.tinkerpop.gremlin.process.traversal.Scope)++[`min(Scope)`], link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/Scope.html++[`Scope`] -[[none-step]] -=== None Step - -The `none()`-step (*filter*) filters all objects from a traversal stream. It is especially useful for traversals -that are executed remotely where returning results is not useful and the traversal is only meant to generate -side-effects. Choosing not to return results saves in serialization and network costs as the objects are filtered on -the remote end and not returned to the client side. Typically, this step does not need to be used directly and is -quietly used by the `iterate()` terminal step which appends `none()` to the traversal before actually cycling through -results. - -NOTE: As of release 4.0.0, `none()` will be renamed to `discard()`. - -*Additional References* - -link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/Traversal.html#none()++[`none()`] -link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/Traversal.html#iterate()++[`iterate()`] - [[not-step]] === Not Step diff --git a/docs/src/upgrade/release-3.3.x.asciidoc b/docs/src/upgrade/release-3.3.x.asciidoc index d361cf4ce7..1efe2a0c8b 100644 --- a/docs/src/upgrade/release-3.3.x.asciidoc +++ b/docs/src/upgrade/release-3.3.x.asciidoc @@ -480,7 +480,7 @@ A new strategy named `EarlyLimitStrategy` was added. The strategy will try to fi which is as early as possible in the traversal. If possible it will also merge multiple `RangeStep`s into a single one by recalculating the range for the first step and removing the second. If it turns out that the merge of two steps won't produce a valid range (an empty result), then the `EarlyLimitStrategy` will remove the `RangeStep` instances and -insert a `NoneStep` instead. +insert a `DiscardStep` instead. This strategy is particularly useful when a provider implementation generates the queries to the underlying database. By making sure that the ranges are applied as early as possible, we can ensure that the underlying database is only asked diff --git a/docs/src/upgrade/release-3.8.x.asciidoc b/docs/src/upgrade/release-3.8.x.asciidoc index 85c8b495d4..0363f70bb7 100644 --- a/docs/src/upgrade/release-3.8.x.asciidoc +++ b/docs/src/upgrade/release-3.8.x.asciidoc @@ -58,6 +58,13 @@ gremlin> g.V().sack(assign).by(__.hasLabel('person').count().asBool()).sack(and) See: link:https://tinkerpop.apache.org/docs/3.8.0/reference/#asBool-step[asBool()-step] See: link:https://issues.apache.org/jira/browse/TINKERPOP-3175[TINKERPOP-3175] +==== none() and discard() + +There is a complicated relationship with the `none()` and `discard()` steps that begs some discussion. Prior to this +version, the `none()` step was used to "throw away" all traversers that passed into it. In 3.8.0, that step has been +renamed to `discard()`. The `discard()` step with its verb tone arguably makes for a better name for that feature, but +it also helped make room for `none()` to be repurposed as `none(P)` which is a complement to `any(P)` and `all(P) steps. + ==== Set minimum Java version to 11 TinkerPop 3.8 requires a minimum of Java 11 for building and running. Support for Java 1.8 has been dropped. @@ -438,6 +445,12 @@ link:https://issues.apache.org/jira/browse/TINKERPOP-2974[TINKERPOP-2974] ==== Graph System Providers +===== NoneStep Renaming + +The `DiscardStep` is now renamed to `DiscardStep`. Providers who developed strategies or other optimizations around +`DiscardStep` should switch to `DiscardStep`. Note that `DiscardStep` has been repurposed as `none(P)` for filtering +collections as a complement to `any(P)` and `all(P)`. + ==== Set minimum Java version to 11 TinkerPop 3.8 requires a minimum of Java 11 for building and running. Support for Java 1.8 has been dropped. diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/DefaultGremlinBaseVisitor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/DefaultGremlinBaseVisitor.java index 4b64161115..6a7382c144 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/DefaultGremlinBaseVisitor.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/DefaultGremlinBaseVisitor.java @@ -614,7 +614,7 @@ public class DefaultGremlinBaseVisitor<T> extends AbstractParseTreeVisitor<T> im /** * {@inheritDoc} */ - @Override public T visitTraversalMethod_none(final GremlinParser.TraversalMethod_noneContext ctx) { notImplemented(ctx); return null; } + @Override public T visitTraversalMethod_discard(final GremlinParser.TraversalMethod_discardContext ctx) { notImplemented(ctx); return null; } /** * {@inheritDoc} */ diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java index 6b1578fb1e..9ff820393b 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java @@ -1111,8 +1111,8 @@ public class TraversalMethodVisitor extends TraversalRootVisitor<GraphTraversal> * {@inheritDoc} */ @Override - public GraphTraversal visitTraversalMethod_none(final GremlinParser.TraversalMethod_noneContext ctx) { - return this.graphTraversal.none(); + public GraphTraversal visitTraversalMethod_discard(final GremlinParser.TraversalMethod_discardContext ctx) { + return this.graphTraversal.discard(); } /** diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java index 494ba58f60..d2b3cb2966 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java @@ -23,7 +23,7 @@ import org.apache.tinkerpop.gremlin.process.computer.GraphComputer; import org.apache.tinkerpop.gremlin.process.remote.traversal.step.map.RemoteStep; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep; import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectStep; import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ProfileSideEffectStep; import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectCapStep; @@ -75,7 +75,7 @@ public interface Traversal<S, E> extends Iterator<E>, Serializable, Cloneable, A } public static final String profile = "profile"; - public static final String none = "none"; + public static final String discard = "discard"; } /** @@ -201,7 +201,7 @@ public interface Traversal<S, E> extends Iterator<E>, Serializable, Cloneable, A public default <A, B> Traversal<A, B> iterate() { try { if (!this.asAdmin().isLocked()) { - this.none(); + this.discard(); this.asAdmin().applyStrategies(); } // use the end step so the results are bulked @@ -221,11 +221,11 @@ public interface Traversal<S, E> extends Iterator<E>, Serializable, Cloneable, A * signal to remote servers that {@link #iterate()} was called. While it may be directly used, it is often a sign * that a traversal should be re-written in another form. * - * @return the updated traversal with respective {@link NoneStep}. + * @return the updated traversal with respective {@link DiscardStep}. */ - public default Traversal<S, E> none() { - this.asAdmin().getBytecode().addStep(Symbols.none); - return this.asAdmin().addStep(new NoneStep<>(this.asAdmin())); + public default Traversal<S, E> discard() { + this.asAdmin().getBytecode().addStep(Symbols.discard); + return this.asAdmin().addStep(new DiscardStep<>(this.asAdmin())); } /** 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 8470cb289a..b91e8f5950 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 @@ -67,7 +67,7 @@ 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.NoneStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep; import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NotStep; import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep; import org.apache.tinkerpop.gremlin.process.traversal.step.filter.PathFilterStep; @@ -2047,11 +2047,11 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> { * signal to remote servers that {@link #iterate()} was called. While it may be directly used, it is often a sign * that a traversal should be re-written in another form. * - * @return the updated traversal with respective {@link NoneStep}. + * @return the updated traversal with respective {@link DiscardStep}. */ @Override - default GraphTraversal<S, E> none() { - return (GraphTraversal<S, E>) Traversal.super.none(); + default GraphTraversal<S, E> discard() { + return (GraphTraversal<S, E>) Traversal.super.discard(); } /** diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/__.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/__.java index 22bb3b1be0..068a200e9d 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/__.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/__.java @@ -1078,10 +1078,10 @@ public class __ { } /** - * @see GraphTraversal#none() + * @see GraphTraversal#discard() */ - public static <A> GraphTraversal<A, A> none() { - return __.<A>start().none(); + public static <A> GraphTraversal<A, A> discard() { + return __.<A>start().discard(); } /** diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/NoneStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/DiscardStep.java similarity index 92% rename from gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/NoneStep.java rename to gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/DiscardStep.java index 1d43444bd5..45baf81fd7 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/NoneStep.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/DiscardStep.java @@ -26,9 +26,9 @@ import org.apache.tinkerpop.gremlin.structure.util.StringFactory; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public final class NoneStep<S> extends FilterStep<S> { +public final class DiscardStep<S> extends FilterStep<S> { - public NoneStep(final Traversal.Admin traversal) { + public DiscardStep(final Traversal.Admin traversal) { super(traversal); } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/EarlyLimitStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/EarlyLimitStrategy.java index cffff8c9ad..b56d65a79c 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/EarlyLimitStrategy.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/EarlyLimitStrategy.java @@ -23,7 +23,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Step; import org.apache.tinkerpop.gremlin.process.traversal.Traversal; import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; import org.apache.tinkerpop.gremlin.process.traversal.step.SideEffectCapable; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep; import org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeGlobalStep; import org.apache.tinkerpop.gremlin.process.traversal.step.map.MapStep; import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ProfileSideEffectStep; @@ -39,15 +39,15 @@ import java.util.List; * This strategy looks for {@link RangeGlobalStep}s that can be moved further left in the traversal and thus be applied * earlier. It will also try to merge multiple {@link RangeGlobalStep}s into one. * If the logical consequence of one or multiple {@link RangeGlobalStep}s is an empty result, the strategy will remove - * as many steps as possible and add a {@link NoneStep} instead. + * as many steps as possible and add a {@link DiscardStep} instead. * * @author Daniel Kuppitz (http://gremlin.guru) * @example <pre> * __.out().valueMap().limit(5) // becomes __.out().limit(5).valueMap() * __.outE().range(2, 10).valueMap().limit(5) // becomes __.outE().range(2, 7).valueMap() * __.outE().limit(5).valueMap().range(2, -1) // becomes __.outE().range(2, 5).valueMap() - * __.outE().limit(5).valueMap().range(5, 10) // becomes __.outE().none() - * __.outE().limit(5).valueMap().range(5, 10).cap("a") // becomes __.outE().none().cap("a") + * __.outE().limit(5).valueMap().range(5, 10) // becomes __.outE().discard() + * __.outE().limit(5).valueMap().range(5, 10).cap("a") // becomes __.outE().discard().cap("a") * </pre> */ public final class EarlyLimitStrategy @@ -74,10 +74,10 @@ public final class EarlyLimitStrategy // previous RangeStep; keep the RangeStep's labels at its preceding step TraversalHelper.copyLabels(step, step.getPreviousStep(), true); insertAfter = moveRangeStep((RangeGlobalStep) step, insertAfter, traversal, merge); - if (insertAfter instanceof NoneStep) { - // any step besides a SideEffectCapStep after a NoneStep would be pointless - final int noneStepIndex = TraversalHelper.stepIndex(insertAfter, traversal); - for (i = j - 2; i > noneStepIndex; i--) { + if (insertAfter instanceof DiscardStep) { + // any step besides a SideEffectCapStep after a DiscardStep would be pointless + final int discardStepIndex = TraversalHelper.stepIndex(insertAfter, traversal); + for (i = j - 2; i > discardStepIndex; i--) { if (!(steps.get(i) instanceof SideEffectCapStep) && !(steps.get(i) instanceof ProfileSideEffectStep)) { traversal.removeStep(i); } @@ -110,7 +110,7 @@ public final class EarlyLimitStrategy if (insertAfter instanceof RangeGlobalStep) { // there's a previous RangeStep which might affect the effective range of the current RangeStep // recompute this step's low and high; if the result is still a valid range, create a new RangeStep, - // otherwise a NoneStep + // otherwise a DiscardStep final RangeGlobalStep other = (RangeGlobalStep) insertAfter; final long low = other.getLowRange() + step.getLowRange(); if (other.getHighRange() == -1L) { @@ -120,11 +120,11 @@ public final class EarlyLimitStrategy if (low < high) { rangeStep = new RangeGlobalStep(traversal, low, high); } else { - rangeStep = new NoneStep<>(traversal); + rangeStep = new DiscardStep<>(traversal); } } else { final long high = Math.min(other.getLowRange() + step.getHighRange(), other.getHighRange()); - rangeStep = high > low ? new RangeGlobalStep(traversal, low, high) : new NoneStep<>(traversal); + rangeStep = high > low ? new RangeGlobalStep(traversal, low, high) : new DiscardStep<>(traversal); } remove = merge; TraversalHelper.replaceStep(merge ? insertAfter : step, rangeStep, traversal); diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java index adb7b40460..aa46b59a4e 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java @@ -25,7 +25,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier; import org.apache.tinkerpop.gremlin.process.traversal.step.PathProcessor; 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.NoneStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep; import org.apache.tinkerpop.gremlin.process.traversal.step.map.ElementStep; import org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep; import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; @@ -120,7 +120,7 @@ public final class LazyBarrierStrategy extends AbstractTraversalStrategy<Travers // so additionally injected ProfileSideEffectStep instances should not have effect here. if (foundFlatMap && !labeledPath && !(step.getNextStep() instanceof Barrier) && - !(step.getNextStep() instanceof NoneStep) && + !(step.getNextStep() instanceof DiscardStep) && !(step.getNextStep() instanceof EmptyStep) && !(step.getNextStep() instanceof ProfileSideEffectStep)) { final Step noOpBarrierStep = new NoOpBarrierStep<>(traversal, MAX_BARRIER_SIZE); diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategy.java index fc4e845797..4a007c910a 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategy.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategy.java @@ -27,13 +27,9 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.LambdaHolder; import org.apache.tinkerpop.gremlin.process.traversal.step.PathProcessor; import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent; import org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DedupGlobalStep; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep; import org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchStep; import org.apache.tinkerpop.gremlin.process.traversal.step.map.NoOpBarrierStep; -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.util.EmptyStep; import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy; import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement; @@ -140,7 +136,7 @@ public final class PathRetractionStrategy extends AbstractTraversalStrategy<Trav !(currentStep instanceof Barrier) && !(currentStep.getNextStep() instanceof Barrier) && !(currentStep.getTraversal().getParent() instanceof MatchStep) && - !(currentStep.getNextStep() instanceof NoneStep) && + !(currentStep.getNextStep() instanceof DiscardStep) && !(currentStep.getNextStep() instanceof EmptyStep)) TraversalHelper.insertAfterStep(new NoOpBarrierStep<>(traversal, this.standardBarrierSize), currentStep, traversal); } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java index 33bf519252..99e015d957 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java @@ -23,9 +23,8 @@ import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.finaliza import org.apache.tinkerpop.gremlin.process.traversal.Step; import org.apache.tinkerpop.gremlin.process.traversal.Traversal; import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; -import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting; import org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep; import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ProfileSideEffectStep; import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectCapStep; import org.apache.tinkerpop.gremlin.process.traversal.step.util.ReducingBarrierStep; @@ -73,15 +72,15 @@ public final class StandardVerificationStrategy extends AbstractTraversalStrateg // The ProfileSideEffectStep must be one of the following // (1) the last step - // (2) 2nd last step when accompanied by the cap step or none step (i.e. iterate() to nothing) + // (2) 2nd last step when accompanied by the cap step or discard step (i.e. iterate() to nothing) // (3) 3rd to last when the traversal ends with a RequirementsStep. final Step<?, ?> endStep = traversal.asAdmin().getEndStep(); if (TraversalHelper.hasStepOfClass(ProfileSideEffectStep.class, traversal) && !(endStep instanceof ProfileSideEffectStep || (endStep instanceof SideEffectCapStep && endStep.getPreviousStep() instanceof ProfileSideEffectStep) || - (endStep instanceof NoneStep && endStep.getPreviousStep() instanceof SideEffectCapStep && endStep.getPreviousStep().getPreviousStep() instanceof ProfileSideEffectStep) || + (endStep instanceof DiscardStep && endStep.getPreviousStep() instanceof SideEffectCapStep && endStep.getPreviousStep().getPreviousStep() instanceof ProfileSideEffectStep) || (endStep instanceof RequirementsStep && endStep.getPreviousStep() instanceof SideEffectCapStep && endStep.getPreviousStep().getPreviousStep() instanceof ProfileSideEffectStep) || - (endStep instanceof RequirementsStep && endStep.getPreviousStep() instanceof NoneStep && endStep.getPreviousStep().getPreviousStep() instanceof SideEffectCapStep && endStep.getPreviousStep().getPreviousStep().getPreviousStep() instanceof ProfileSideEffectStep))) { + (endStep instanceof RequirementsStep && endStep.getPreviousStep() instanceof DiscardStep && endStep.getPreviousStep().getPreviousStep() instanceof SideEffectCapStep && endStep.getPreviousStep().getPreviousStep().getPreviousStep() instanceof ProfileSideEffectStep))) { throw new VerificationException("When specified, the profile()-Step must be the last step or followed only by the cap()-step.", traversal); } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/BytecodeHelper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/BytecodeHelper.java index 0ad7c53764..5eb5ef252b 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/BytecodeHelper.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/BytecodeHelper.java @@ -51,7 +51,7 @@ 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.NoneStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep; import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NotStep; import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep; import org.apache.tinkerpop.gremlin.process.traversal.step.filter.PathFilterStep; @@ -325,7 +325,7 @@ public final class BytecodeHelper { put(GraphTraversal.Symbols.as, Collections.emptyList()); put(GraphTraversal.Symbols.option, Collections.emptyList()); put(Traversal.Symbols.profile, Collections.singletonList(ProfileStep.class)); - put(Traversal.Symbols.none, Collections.singletonList(NoneStep.class)); + put(Traversal.Symbols.discard, Collections.singletonList(DiscardStep.class)); put(TraversalSource.Symbols.withSack, Collections.emptyList()); put(TraversalSource.Symbols.withoutStrategies, Collections.emptyList()); put(TraversalSource.Symbols.withStrategies, Collections.emptyList()); diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitorTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitorTest.java index 6e4a26f5ab..e8866f18df 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitorTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitorTest.java @@ -1300,9 +1300,9 @@ public class TraversalMethodVisitorTest { } @Test - public void shouldParseTraversalMethod_none_somethingAfter() throws Exception { - compare(g.V().none().path(), eval("g.V().none().path()")); - compare(g.V().none().E(), eval("g.V().none().E()")); - compare(g.V().none().none(), eval("g.V().none().none()")); + public void shouldParseTraversalMethod_discard_somethingAfter() throws Exception { + compare(g.V().discard().path(), eval("g.V().discard().path()")); + compare(g.V().discard().E(), eval("g.V().discard().E()")); + compare(g.V().discard().discard(), eval("g.V().discard().discard()")); } } diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalRootVisitorTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalRootVisitorTest.java index a6bc04f0e6..c153b091bf 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalRootVisitorTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalRootVisitorTest.java @@ -42,8 +42,8 @@ public class TraversalRootVisitorTest { @Test public void shouldParseTraversalMethod_none() { - compare(g.V().none(), eval("g.V().none()")); - compare(g.V().union(__.identity().none()), eval("g.V().union(__.identity().none())")); + compare(g.V().discard(), eval("g.V().discard()")); + compare(g.V().union(__.identity().discard()), eval("g.V().union(__.identity().discard())")); } private void compare(Object expected, Object actual) { diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java index 32c81f4fc8..7f58f0b748 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java @@ -53,7 +53,7 @@ public class GraphTraversalTest { private static final Logger logger = LoggerFactory.getLogger(GraphTraversalTest.class); private static final GraphTraversalSource g = traversal().withEmbedded(EmptyGraph.instance()); - private static Set<String> NO_GRAPH = new HashSet<>(Arrays.asList("asAdmin", "by", "read", "write", "with", "option", "iterate", "to", "from", "profile", "pageRank", "connectedComponent", "peerPressure", "shortestPath", "program", "none")); + private static Set<String> NO_GRAPH = new HashSet<>(Arrays.asList("asAdmin", "by", "read", "write", "with", "option", "iterate", "to", "from", "profile", "pageRank", "connectedComponent", "peerPressure", "shortestPath", "program", "discard")); private static Set<String> NO_ANONYMOUS = new HashSet<>(Arrays.asList("start", "__")); private static Set<String> IGNORES_BYTECODE = new HashSet<>(Arrays.asList("asAdmin", "read", "write", "iterate")); diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/EarlyLimitStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/EarlyLimitStrategyTest.java index d6578dda24..55bd397f63 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/EarlyLimitStrategyTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/EarlyLimitStrategyTest.java @@ -77,8 +77,8 @@ public class EarlyLimitStrategyTest { public static Iterable<Object[]> generateTestParameters() { return Arrays.asList(new Object[][]{ {__.out().valueMap().limit(1), __.out().limit(1).valueMap(), Collections.emptyList()}, - {__.out().limit(5).valueMap().range(5, 10), __.start().out().none(), Collections.emptyList()}, - {__.out().limit(5).valueMap().range(6, 10), __.start().out().none(), Collections.emptyList()}, + {__.out().limit(5).valueMap().range(5, 10), __.start().out().discard(), Collections.emptyList()}, + {__.out().limit(5).valueMap().range(6, 10), __.start().out().discard(), Collections.emptyList()}, {__.V().out().valueMap().limit(1), __.V().out().limit(1).valueMap(), Collections.singleton(LazyBarrierStrategy.instance())}, {__.out().out().limit(1).in().in(), __.out().out().limit(1).in().barrier(LazyBarrierStrategy.MAX_BARRIER_SIZE).in(), Collections.singleton(LazyBarrierStrategy.instance())}, {__.out().has("name","marko").limit(1).in().in(), __.out().has("name","marko").limit(1).in().in(), Collections.emptyList()}, @@ -92,12 +92,12 @@ public class EarlyLimitStrategyTest { {__.out().map(__.identity()).map(__.identity()).range(50, -1).map(__.identity()).map(__.identity()).range(10, 60), __.out().range(60, 110).map(__.identity()).map(__.identity()).map(__.identity()).map(__.identity()), Collections.emptyList()}, {__.out().map(__.identity()).map(__.identity()).range(50, 100).map(__.identity()).map(__.identity()).range(10, -1), __.out().range(60, 100).map(__.identity()).map(__.identity()).map(__.identity()).map(__.identity()), Collections.emptyList()}, {__.out().map(__.identity()).map(__.identity()).range(50, 100).as("a").map(__.identity()).map(__.identity()).range(10, -1).as("b"), __.out().range(60, 100).map(__.identity()).map(__.identity()).as("a").map(__.identity()).map(__.identity()).as("b"), Collections.emptyList()}, - {__.out().map(__.identity()).map(__.identity()).range(50, 100).map(__.identity()).map(__.identity()).range(50, -1), __.out().none(), Collections.emptyList()}, - {__.out().map(__.identity()).map(__.identity()).range(50, 100).map(__.identity()).map(__.identity()).range(60, -1), __.out().none(), Collections.emptyList()}, - {__.out().map(__.identity()).map(__.identity()).range(50, 100).as("a").map(__.identity()).map(__.identity()).range(60, -1).as("b"), __.out().none(), Collections.emptyList()}, - {__.out().range(50, 100).store("a").range(50, -1), __.out().range(50, 100).store("a").none(), Collections.emptyList()}, - {__.out().range(50, 100).store("a").range(50, -1).cap("a"), ((GraphTraversal) __.out().range(50, 100).store("a").none()).cap("a"), Collections.emptyList()}, - {__.out().range(50, 100).map(__.identity()).range(50, -1).profile(), __.out().none().profile(), Collections.singleton(ProfileStrategy.instance())}, + {__.out().map(__.identity()).map(__.identity()).range(50, 100).map(__.identity()).map(__.identity()).range(50, -1), __.out().discard(), Collections.emptyList()}, + {__.out().map(__.identity()).map(__.identity()).range(50, 100).map(__.identity()).map(__.identity()).range(60, -1), __.out().discard(), Collections.emptyList()}, + {__.out().map(__.identity()).map(__.identity()).range(50, 100).as("a").map(__.identity()).map(__.identity()).range(60, -1).as("b"), __.out().discard(), Collections.emptyList()}, + {__.out().range(50, 100).store("a").range(50, -1), __.out().range(50, 100).store("a").discard(), Collections.emptyList()}, + {__.out().range(50, 100).store("a").range(50, -1).cap("a"), ((GraphTraversal) __.out().range(50, 100).store("a").discard()).cap("a"), Collections.emptyList()}, + {__.out().range(50, 100).map(__.identity()).range(50, -1).profile(), __.out().discard().profile(), Collections.singleton(ProfileStrategy.instance())}, {__.out().store("a").limit(10), __.out().limit(10).store("a"), Collections.emptyList()}, {__.out().aggregate("a").limit(10), __.out().aggregate("a").limit(10), Collections.emptyList()}, {__.V().branch(__.label()).option("person", __.out("knows").valueMap().limit(1)).option("software", __.out("created").valueMap().limit(2).fold()), diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java index 084b795273..6bc20e4e21 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java @@ -77,7 +77,7 @@ public class StandardVerificationStrategyTest { if (legalTraversal) { copy.asAdmin().applyStrategies(); - // try to also apply strategies with iterate() so that a NoneStep is added - for consistency sake we want + // try to also apply strategies with iterate() so that a DiscardStep is added - for consistency sake we want // to be able to run a profile and get no result back with this. final Traversal forIteration = copyAndConfigureTraversal(traversal); forIteration.iterate(); diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/translator/PythonTranslatorTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/translator/PythonTranslatorTest.java index 45d5a33ebe..89bda921b9 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/translator/PythonTranslatorTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/translator/PythonTranslatorTest.java @@ -69,10 +69,10 @@ public class PythonTranslatorTest { } @Test - public void shouldTranslateNone() { + public void shouldTranslateDiscard() { final String gremlinAsPython = translator.translate( - g.V().none().asAdmin().getBytecode()).getScript(); - assertEquals("g.V().none()", gremlinAsPython); + g.V().discard().asAdmin().getBytecode()).getScript(); + assertEquals("g.V().discard()", gremlinAsPython); } @Test diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs index 9d7909324e..1b64474fbb 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs @@ -229,7 +229,7 @@ namespace Gremlin.Net.Process.Traversal /// <returns>The fully drained traversal.</returns> public ITraversal<TStart, TEnd> Iterate() { - Bytecode.AddStep("none"); + Bytecode.AddStep("discard"); while (MoveNext()) { } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs index d9091d1afb..162a89c0fe 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs @@ -714,6 +714,15 @@ namespace Gremlin.Net.Process.Traversal return Wrap<TStart, TEnd>(this); } + /// <summary> + /// Adds the discard step to this <see cref="GraphTraversal{SType, EType}" />. + /// </summary> + public GraphTraversal<TStart, TEnd> Discard () + { + Bytecode.AddStep("discard"); + return Wrap<TStart, TEnd>(this); + } + /// <summary> /// Adds the disjunct step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> @@ -1510,15 +1519,6 @@ namespace Gremlin.Net.Process.Traversal return Wrap<TStart, TNewEnd>(this); } - /// <summary> - /// Adds the none step to this <see cref="GraphTraversal{SType, EType}" />. - /// </summary> - public GraphTraversal<TStart, TEnd> None () - { - Bytecode.AddStep("none"); - return Wrap<TStart, TEnd>(this); - } - /// <summary> /// Adds the not step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs index 7e077f7fc5..6e5644da70 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs @@ -478,6 +478,14 @@ namespace Gremlin.Net.Process.Traversal return new GraphTraversal<object, object>().Difference(differenceObject); } + /// <summary> + /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the discard step to that traversal. + /// </summary> + public static GraphTraversal<object, object> discard() + { + return new GraphTraversal<object, object>().Discard(); + } + /// <summary> /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the disjunct step to that traversal. /// </summary> @@ -1104,14 +1112,6 @@ namespace Gremlin.Net.Process.Traversal return new GraphTraversal<object, E2>().Min<E2>(scope); } - /// <summary> - /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the none step to that traversal. - /// </summary> - public static GraphTraversal<object, object> None() - { - return new GraphTraversal<object, object>().None(); - } - /// <summary> /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the not step to that traversal. /// </summary> diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs index df5ac0d3cb..81bb7242df 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs @@ -203,6 +203,12 @@ namespace Gremlin.Net.IntegrationTest.Gherkin {"g_V_properties_dedup_count", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.AddV("person").Property("name", "josh").AddV("person").Property("name", "josh").AddV("person").Property("name", "josh"), (g,p) =>g.V().Properties<object>("name").Dedup().Count()}}, {"g_V_properties_dedup_byXvalueX_count", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.AddV("person").Property("name", "josh").AddV("person").Property("name", "josh").AddV("person").Property("name", "josh"), (g,p) =>g.V().Properties<object>("name").Dedup().By(T.Value).Count()}}, {"g_V_both_hasXlabel_softwareX_dedup_byXlangX_byXnameX_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Both().Has(T.Label, "software").Dedup().By("lang").By("name").Values<object>("name")}}, + {"g_V_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Discard()}}, + {"g_V_discard_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Discard().Discard()}}, + {"g_V_discard_fold", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Discard().Fold()}}, + {"g_V_discard_fold_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Discard().Fold().Discard()}}, + {"g_V_discard_fold_constantX1X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Discard().Fold().Constant<object>(1)}}, + {"g_V_projectXxX_byXcoalesceXage_isXgtX29XX_discardXX_selectXxX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Project<object>("x").By(__.Coalesce<object>(__.Values<object>("age").Is(P.Gt(29)), __.Discard())).Select<object>("x")}}, {"g_V_drop", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.AddV().As("a").AddV().As("b").AddE("knows").To("a"), (g,p) =>g.V().Drop(), (g,p) =>g.V(), (g,p) =>g.E()}}, {"g_V_outE_drop", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.AddV().As("a").AddV().As("b").AddE("knows").To("a"), (g,p) =>g.V().OutE().Drop(), (g,p) =>g.V(), (g,p) =>g.E()}}, {"g_V_properties_drop", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.AddV().Property("name", "bob").AddV().Property("name", "alice"), (g,p) =>g.V().Properties<object>().Drop(), (g,p) =>g.V(), (g,p) =>g.V().Properties<object>()}}, @@ -318,12 +324,6 @@ namespace Gremlin.Net.IntegrationTest.Gherkin {"g_V_valuesXageX_isXgte_29X_isXlt_34X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Values<object>("age").Is(P.Gte(29)).Is(P.Lt(34))}}, {"g_V_whereXinXcreatedX_count_isX1XX_valuesXnameX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Where(__.In("created").Count().Is(1)).Values<object>("name")}}, {"g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Where(__.In("created").Count().Is(P.Gte(2))).Values<object>("name")}}, - {"g_V_none", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().None()}}, - {"g_V_none_none", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().None().None()}}, - {"g_V_none_fold", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().None().Fold()}}, - {"g_V_none_fold_none", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().None().Fold().None()}}, - {"g_V_none_fold_constantX1X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().None().Fold().Constant<object>(1)}}, - {"g_V_projectXxX_byXcoalesceXage_isXgtX29XX_noneXX_selectXxX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Project<object>("x").By(__.Coalesce<object>(__.Values<object>("age").Is(P.Gt(29)), __.None())).Select<object>("x")}}, {"g_V_orXhasXage_gt_27X__outE_count_gte_2X_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Or(__.Has("age", P.Gt(27)), __.OutE().Count().Is(P.Gte(2))).Values<object>("name")}}, {"g_V_orXoutEXknowsX__hasXlabel_softwareX_or_hasXage_gte_35XX_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Or(__.OutE("knows"), __.Has(T.Label, "software").Or().Has("age", P.Gte(35))).Values<object>("name")}}, {"g_V_asXaX_orXselectXaX_selectXaXX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().As("a").Or(__.Select<object>("a"), __.Select<object>("a"))}}, diff --git a/gremlin-go/driver/anonymousTraversal.go b/gremlin-go/driver/anonymousTraversal.go index 67b107ab07..ac6c9a5348 100644 --- a/gremlin-go/driver/anonymousTraversal.go +++ b/gremlin-go/driver/anonymousTraversal.go @@ -117,6 +117,8 @@ type AnonymousTraversal interface { Dedup(args ...interface{}) *GraphTraversal // Difference adds the difference step to the GraphTraversal. Difference(args ...interface{}) *GraphTraversal + // Discard adds the discard step to the GraphTraversal. + Discard(args ...interface{}) *GraphTraversal // Disjunct adds the disjunct step to the GraphTraversal. Disjunct(args ...interface{}) *GraphTraversal // Drop adds the drop step to the GraphTraversal. @@ -205,8 +207,6 @@ type AnonymousTraversal interface { MergeV(args ...interface{}) *GraphTraversal // Min adds the min step to the GraphTraversal. Min(args ...interface{}) *GraphTraversal - // None adds the none step to the GraphTraversal. - None(args ...interface{}) *GraphTraversal // Not adds the not step to the GraphTraversal. Not(args ...interface{}) *GraphTraversal // Option adds the option step to the GraphTraversal. @@ -506,6 +506,11 @@ func (anonymousTraversal *anonymousTraversal) Difference(args ...interface{}) *G return anonymousTraversal.graphTraversal().Difference(args...) } +// Discard adds the discard step to the GraphTraversal. +func (anonymousTraversal *anonymousTraversal) Discard(args ...interface{}) *GraphTraversal { + return anonymousTraversal.graphTraversal().Discard(args...) +} + // Disjunct adds the disjunct step to the GraphTraversal. func (anonymousTraversal *anonymousTraversal) Disjunct(args ...interface{}) *GraphTraversal { return anonymousTraversal.graphTraversal().Disjunct(args...) @@ -726,11 +731,6 @@ func (anonymousTraversal *anonymousTraversal) Min(args ...interface{}) *GraphTra return anonymousTraversal.graphTraversal().Min(args...) } -// None adds the none step to the GraphTraversal. -func (anonymousTraversal *anonymousTraversal) None(args ...interface{}) *GraphTraversal { - return anonymousTraversal.graphTraversal().None(args...) -} - // Not adds the not step to the GraphTraversal. func (anonymousTraversal *anonymousTraversal) Not(args ...interface{}) *GraphTraversal { return anonymousTraversal.graphTraversal().Not(args...) diff --git a/gremlin-go/driver/cucumber/gremlin.go b/gremlin-go/driver/cucumber/gremlin.go index 0aca8a216b..b09f540c46 100644 --- a/gremlin-go/driver/cucumber/gremlin.go +++ b/gremlin-go/driver/cucumber/gremlin.go @@ -173,6 +173,12 @@ var translationMap = map[string][]func(g *gremlingo.GraphTraversalSource, p map[ "g_V_properties_dedup_count": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("name", "josh").AddV("person").Property("name", "josh").AddV("person").Property("name", "josh")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Properties("name").Dedup().Count()}}, "g_V_properties_dedup_byXvalueX_count": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("name", "josh").AddV("person").Property("name", "josh").AddV("person").Property("name", "josh")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Properties("name").Dedup().By(gremlingo.T.Value).Count()}}, "g_V_both_hasXlabel_softwareX_dedup_byXlangX_byXnameX_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Both().Has(gremlingo.T.Label, "software").Dedup().By("lang").By("name").Values("name")}}, + "g_V_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Discard()}}, + "g_V_discard_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Discard().Discard()}}, + "g_V_discard_fold": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Discard().Fold()}}, + "g_V_discard_fold_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Discard().Fold().Discard()}}, + "g_V_discard_fold_constantX1X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Discard().Fold().Constant(1)}}, + "g_V_projectXxX_byXcoalesceXage_isXgtX29XX_discardXX_selectXxX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Project("x").By(gremlingo.T__.Coalesce(gremlingo.T__.Values("age").Is(gremlingo.P.Gt(29)), gremlingo.T__.Discard())).Select("x")}}, "g_V_drop": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV().As("a").AddV().As("b").AddE("knows").To("a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Drop()}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V()}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {ret [...] "g_V_outE_drop": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV().As("a").AddV().As("b").AddE("knows").To("a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().OutE().Drop()}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V()}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTr [...] "g_V_properties_drop": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV().Property("name", "bob").AddV().Property("name", "alice")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Properties().Drop()}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V()}, func(g *gremlingo.GraphTraversalSource, p map[string]interfa [...] @@ -288,12 +294,6 @@ var translationMap = map[string][]func(g *gremlingo.GraphTraversalSource, p map[ "g_V_valuesXageX_isXgte_29X_isXlt_34X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Values("age").Is(gremlingo.P.Gte(29)).Is(gremlingo.P.Lt(34))}}, "g_V_whereXinXcreatedX_count_isX1XX_valuesXnameX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Where(gremlingo.T__.In("created").Count().Is(1)).Values("name")}}, "g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Where(gremlingo.T__.In("created").Count().Is(gremlingo.P.Gte(2))).Values("name")}}, - "g_V_none": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().None()}}, - "g_V_none_none": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().None().None()}}, - "g_V_none_fold": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().None().Fold()}}, - "g_V_none_fold_none": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().None().Fold().None()}}, - "g_V_none_fold_constantX1X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().None().Fold().Constant(1)}}, - "g_V_projectXxX_byXcoalesceXage_isXgtX29XX_noneXX_selectXxX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Project("x").By(gremlingo.T__.Coalesce(gremlingo.T__.Values("age").Is(gremlingo.P.Gt(29)), gremlingo.T__.None())).Select("x")}}, "g_V_orXhasXage_gt_27X__outE_count_gte_2X_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Or(gremlingo.T__.Has("age", gremlingo.P.Gt(27)), gremlingo.T__.OutE().Count().Is(gremlingo.P.Gte(2))).Values("name")}}, "g_V_orXoutEXknowsX__hasXlabel_softwareX_or_hasXage_gte_35XX_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Or(gremlingo.T__.OutE("knows"), gremlingo.T__.Has(gremlingo.T.Label, "software").Or().Has("age", gremlingo.P.Gte(35))).Values("name")}}, "g_V_asXaX_orXselectXaX_selectXaXX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().As("a").Or(gremlingo.T__.Select("a"), gremlingo.T__.Select("a"))}}, diff --git a/gremlin-go/driver/graphTraversal.go b/gremlin-go/driver/graphTraversal.go index ae9aa7f262..6573db7485 100644 --- a/gremlin-go/driver/graphTraversal.go +++ b/gremlin-go/driver/graphTraversal.go @@ -258,6 +258,12 @@ func (g *GraphTraversal) Difference(args ...interface{}) *GraphTraversal { return g } +// Discard adds the discard step to the GraphTraversal. +func (g *GraphTraversal) Discard(args ...interface{}) *GraphTraversal { + g.Bytecode.AddStep("discard", args...) + return g +} + // Disjunct adds the disjunct step to the GraphTraversal. func (g *GraphTraversal) Disjunct(args ...interface{}) *GraphTraversal { g.Bytecode.AddStep("disjunct", args...) @@ -524,12 +530,6 @@ func (g *GraphTraversal) Min(args ...interface{}) *GraphTraversal { return g } -// None adds the none step to the GraphTraversal. -func (g *GraphTraversal) None(args ...interface{}) *GraphTraversal { - g.Bytecode.AddStep("none", args...) - return g -} - // Not adds the not step to the GraphTraversal. func (g *GraphTraversal) Not(args ...interface{}) *GraphTraversal { g.Bytecode.AddStep("not", args...) diff --git a/gremlin-go/driver/traversal.go b/gremlin-go/driver/traversal.go index 6d82f6d0af..66f8cd3c2e 100644 --- a/gremlin-go/driver/traversal.go +++ b/gremlin-go/driver/traversal.go @@ -77,7 +77,7 @@ func (t *Traversal) Iterate() <-chan error { return } - if err := t.Bytecode.AddStep("none"); err != nil { + if err := t.Bytecode.AddStep("discard"); err != nil { r <- err return } diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js index e86dd4af47..b2aa34afba 100644 --- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js +++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js @@ -682,6 +682,16 @@ class GraphTraversal extends Traversal { return this; } + /** + * Graph traversal discard method. + * @param {...Object} args + * @returns {GraphTraversal} + */ + discard(...args) { + this.bytecode.addStep('discard', args); + return this; + } + /** * Graph traversal disjunct method. * @param {...Object} args @@ -1121,16 +1131,6 @@ class GraphTraversal extends Traversal { return this; } - /** - * Graph traversal none method. - * @param {...Object} args - * @returns {GraphTraversal} - */ - none(...args) { - this.bytecode.addStep('none', args); - return this; - } - /** * Graph traversal not method. * @param {...Object} args @@ -1770,6 +1770,7 @@ const statics = { dateAdd: (...args) => callOnEmptyTraversal('dateAdd', args), dateDiff: (...args) => callOnEmptyTraversal('dateDiff', args), dedup: (...args) => callOnEmptyTraversal('dedup', args), + discard: (...args) => callOnEmptyTraversal('discard', args), disjunct: (...args) => callOnEmptyTraversal('disjunct', args), drop: (...args) => callOnEmptyTraversal('drop', args), element: (...args) => callOnEmptyTraversal('element', args), @@ -1811,7 +1812,6 @@ const statics = { mergeE: (...args) => callOnEmptyTraversal('mergeE', args), mergeV: (...args) => callOnEmptyTraversal('mergeV', args), min: (...args) => callOnEmptyTraversal('min', args), - none: (...args) => callOnEmptyTraversal('none', args), not: (...args) => callOnEmptyTraversal('not', args), optional: (...args) => callOnEmptyTraversal('optional', args), or: (...args) => callOnEmptyTraversal('or', args), diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js index a1ff9316dd..f925a72624 100644 --- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js +++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js @@ -84,7 +84,7 @@ class Traversal { * @returns {Promise} */ iterate() { - this.bytecode.addStep('none'); + this.bytecode.addStep('discard'); return this._applyStrategies().then(() => { let it; while ((it = this._getNext()) && !it.done) { diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js index e84bbbcaf9..03840c482b 100644 --- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js +++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js @@ -203,6 +203,12 @@ const gremlins = { g_V_properties_dedup_count: [function({g}) { return g.addV("person").property("name", "josh").addV("person").property("name", "josh").addV("person").property("name", "josh") }, function({g}) { return g.V().properties("name").dedup().count() }], g_V_properties_dedup_byXvalueX_count: [function({g}) { return g.addV("person").property("name", "josh").addV("person").property("name", "josh").addV("person").property("name", "josh") }, function({g}) { return g.V().properties("name").dedup().by(T.value).count() }], g_V_both_hasXlabel_softwareX_dedup_byXlangX_byXnameX_name: [function({g}) { return g.V().both().has(T.label, "software").dedup().by("lang").by("name").values("name") }], + g_V_discard: [function({g}) { return g.V().discard() }], + g_V_discard_discard: [function({g}) { return g.V().discard().discard() }], + g_V_discard_fold: [function({g}) { return g.V().discard().fold() }], + g_V_discard_fold_discard: [function({g}) { return g.V().discard().fold().discard() }], + g_V_discard_fold_constantX1X: [function({g}) { return g.V().discard().fold().constant(1) }], + g_V_projectXxX_byXcoalesceXage_isXgtX29XX_discardXX_selectXxX: [function({g}) { return g.V().project("x").by(__.coalesce(__.values("age").is(P.gt(29)), __.discard())).select("x") }], g_V_drop: [function({g}) { return g.addV().as("a").addV().as("b").addE("knows").to("a") }, function({g}) { return g.V().drop() }, function({g}) { return g.V() }, function({g}) { return g.E() }], g_V_outE_drop: [function({g}) { return g.addV().as("a").addV().as("b").addE("knows").to("a") }, function({g}) { return g.V().outE().drop() }, function({g}) { return g.V() }, function({g}) { return g.E() }], g_V_properties_drop: [function({g}) { return g.addV().property("name", "bob").addV().property("name", "alice") }, function({g}) { return g.V().properties().drop() }, function({g}) { return g.V() }, function({g}) { return g.V().properties() }], @@ -318,12 +324,6 @@ const gremlins = { g_V_valuesXageX_isXgte_29X_isXlt_34X: [function({g}) { return g.V().values("age").is(P.gte(29)).is(P.lt(34)) }], g_V_whereXinXcreatedX_count_isX1XX_valuesXnameX: [function({g}) { return g.V().where(__.in_("created").count().is(1)).values("name") }], g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX: [function({g}) { return g.V().where(__.in_("created").count().is(P.gte(2))).values("name") }], - g_V_none: [function({g}) { return g.V().none() }], - g_V_none_none: [function({g}) { return g.V().none().none() }], - g_V_none_fold: [function({g}) { return g.V().none().fold() }], - g_V_none_fold_none: [function({g}) { return g.V().none().fold().none() }], - g_V_none_fold_constantX1X: [function({g}) { return g.V().none().fold().constant(1) }], - g_V_projectXxX_byXcoalesceXage_isXgtX29XX_noneXX_selectXxX: [function({g}) { return g.V().project("x").by(__.coalesce(__.values("age").is(P.gt(29)), __.none())).select("x") }], g_V_orXhasXage_gt_27X__outE_count_gte_2X_name: [function({g}) { return g.V().or(__.has("age", P.gt(27)), __.outE().count().is(P.gte(2))).values("name") }], g_V_orXoutEXknowsX__hasXlabel_softwareX_or_hasXage_gte_35XX_name: [function({g}) { return g.V().or(__.outE("knows"), __.has(T.label, "software").or().has("age", P.gte(35))).values("name") }], g_V_asXaX_orXselectXaX_selectXaXX: [function({g}) { return g.V().as("a").or(__.select("a"), __.select("a")) }], diff --git a/gremlin-language/src/main/antlr4/Gremlin.g4 b/gremlin-language/src/main/antlr4/Gremlin.g4 index 0b60761f35..9fbcae894e 100644 --- a/gremlin-language/src/main/antlr4/Gremlin.g4 +++ b/gremlin-language/src/main/antlr4/Gremlin.g4 @@ -202,6 +202,7 @@ traversalMethod | traversalMethod_cyclicPath | traversalMethod_dedup | traversalMethod_difference + | traversalMethod_discard | traversalMethod_disjunct | traversalMethod_drop | traversalMethod_elementMap @@ -238,7 +239,6 @@ traversalMethod | traversalMethod_max | traversalMethod_mean | traversalMethod_min - | traversalMethod_none | traversalMethod_not | traversalMethod_option | traversalMethod_optional @@ -474,6 +474,10 @@ traversalMethod_difference : K_DIFFERENCE LPAREN genericArgument RPAREN #traversalMethod_difference_Object ; +traversalMethod_discard + : K_DISCARD LPAREN RPAREN + ; + traversalMethod_disjunct : K_DISJUNCT LPAREN genericArgument RPAREN #traversalMethod_disjunct_Object ; @@ -683,10 +687,6 @@ traversalMethod_min | K_MIN LPAREN traversalScope RPAREN #traversalMethod_min_Scope ; -traversalMethod_none - : K_NONE LPAREN RPAREN - ; - traversalMethod_not : K_NOT LPAREN nestedTraversal RPAREN ; @@ -1715,6 +1715,7 @@ keyword | K_DESC | K_DIFFERENCE | K_DIRECTION + | K_DISCARD | K_DISJUNCT | K_DISTANCE | K_DIV @@ -1974,6 +1975,7 @@ K_DECR: 'decr'; K_DEDUP: 'dedup'; K_DESC: 'desc'; K_DIFFERENCE: 'difference'; +K_DISCARD: 'discard'; K_DIRECTION: 'Direction'; K_DISJUNCT: 'disjunct'; K_DISTANCE: 'distance'; diff --git a/gremlin-python/src/main/python/gremlin_python/process/graph_traversal.py b/gremlin-python/src/main/python/gremlin_python/process/graph_traversal.py index 9a33d899fd..df7c3d4e65 100644 --- a/gremlin-python/src/main/python/gremlin_python/process/graph_traversal.py +++ b/gremlin-python/src/main/python/gremlin_python/process/graph_traversal.py @@ -442,6 +442,10 @@ class GraphTraversal(Traversal): self.bytecode.add_step("difference", *args) return self + def discard(self, *args): + self.bytecode.add_step("discard", *args) + return self + def disjunct(self, *args): self.bytecode.add_step("disjunct", *args) return self @@ -703,10 +707,6 @@ class GraphTraversal(Traversal): self.bytecode.add_step("min", *args) return self - def none(self, *args): - self.bytecode.add_step("none", *args) - return self - def not_(self, *args): self.bytecode.add_step("not", *args) return self @@ -1215,6 +1215,10 @@ class __(object, metaclass=MagicType): def difference(cls, *args): return cls.graph_traversal(None, None, Bytecode()).difference(*args) + @classmethod + def discard(cls, *args): + return cls.graph_traversal(None, None, Bytecode()).discard(*args) + @classmethod def disjunct(cls, *args): return cls.graph_traversal(None, None, Bytecode()).disjunct(*args) @@ -1483,10 +1487,6 @@ class __(object, metaclass=MagicType): def min_(cls, *args): return cls.graph_traversal(None, None, Bytecode()).min_(*args) - @classmethod - def none(cls, *args): - return cls.graph_traversal(None, None, Bytecode()).none(*args) - @classmethod def not_(cls, *args): return cls.graph_traversal(None, None, Bytecode()).not_(*args) @@ -1967,6 +1967,10 @@ def dedup(*args): return __.dedup(*args) +def discard(*args): + return __.discard(*args) + + def disjunct(*args): return __.disjunct(*args) @@ -2177,10 +2181,6 @@ def min_(*args): return __.min_(*args) -def none(*args): - return __.none(*args) - - def not_(*args): return __.not_(*args) @@ -2471,6 +2471,8 @@ statics.add_static('date_diff', date_diff) statics.add_static('dedup', dedup) +statics.add_static('discard', discard) + statics.add_static('disjunct', disjunct) statics.add_static('drop', drop) @@ -2573,8 +2575,6 @@ statics.add_static('merge_v', merge_v) statics.add_static('min_', min_) -statics.add_static('none', none) - statics.add_static('not_', not_) statics.add_static('optional', optional) diff --git a/gremlin-python/src/main/python/gremlin_python/process/traversal.py b/gremlin-python/src/main/python/gremlin_python/process/traversal.py index fb74433348..e806e7aa69 100644 --- a/gremlin-python/src/main/python/gremlin_python/process/traversal.py +++ b/gremlin-python/src/main/python/gremlin_python/process/traversal.py @@ -75,7 +75,7 @@ class Traversal(object): return set(iter(self)) def iterate(self): - self.bytecode.add_step("none") + self.bytecode.add_step("discard") while True: try: self.next_traverser() except StopIteration: return self diff --git a/gremlin-python/src/main/python/radish/gremlin.py b/gremlin-python/src/main/python/radish/gremlin.py index 9f9d5aed6e..1351a0a4a1 100644 --- a/gremlin-python/src/main/python/radish/gremlin.py +++ b/gremlin-python/src/main/python/radish/gremlin.py @@ -176,6 +176,12 @@ world.gremlins = { 'g_V_properties_dedup_count': [(lambda g:g.add_v('person').property('name', 'josh').add_v('person').property('name', 'josh').add_v('person').property('name', 'josh')), (lambda g:g.V().properties('name').dedup().count())], 'g_V_properties_dedup_byXvalueX_count': [(lambda g:g.add_v('person').property('name', 'josh').add_v('person').property('name', 'josh').add_v('person').property('name', 'josh')), (lambda g:g.V().properties('name').dedup().by(T.value).count())], 'g_V_both_hasXlabel_softwareX_dedup_byXlangX_byXnameX_name': [(lambda g:g.V().both().has(T.label, 'software').dedup().by('lang').by('name').values('name'))], + 'g_V_discard': [(lambda g:g.V().discard())], + 'g_V_discard_discard': [(lambda g:g.V().discard().discard())], + 'g_V_discard_fold': [(lambda g:g.V().discard().fold())], + 'g_V_discard_fold_discard': [(lambda g:g.V().discard().fold().discard())], + 'g_V_discard_fold_constantX1X': [(lambda g:g.V().discard().fold().constant(1))], + 'g_V_projectXxX_byXcoalesceXage_isXgtX29XX_discardXX_selectXxX': [(lambda g:g.V().project('x').by(__.coalesce(__.values('age').is_(P.gt(29)), __.discard())).select('x'))], 'g_V_drop': [(lambda g:g.add_v().as_('a').add_v().as_('b').add_e('knows').to('a')), (lambda g:g.V().drop()), (lambda g:g.V()), (lambda g:g.E())], 'g_V_outE_drop': [(lambda g:g.add_v().as_('a').add_v().as_('b').add_e('knows').to('a')), (lambda g:g.V().out_e().drop()), (lambda g:g.V()), (lambda g:g.E())], 'g_V_properties_drop': [(lambda g:g.add_v().property('name', 'bob').add_v().property('name', 'alice')), (lambda g:g.V().properties().drop()), (lambda g:g.V()), (lambda g:g.V().properties())], @@ -291,12 +297,6 @@ world.gremlins = { 'g_V_valuesXageX_isXgte_29X_isXlt_34X': [(lambda g:g.V().values('age').is_(P.gte(29)).is_(P.lt(34)))], 'g_V_whereXinXcreatedX_count_isX1XX_valuesXnameX': [(lambda g:g.V().where(__.in_('created').count().is_(1)).values('name'))], 'g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX': [(lambda g:g.V().where(__.in_('created').count().is_(P.gte(2))).values('name'))], - 'g_V_none': [(lambda g:g.V().none())], - 'g_V_none_none': [(lambda g:g.V().none().none())], - 'g_V_none_fold': [(lambda g:g.V().none().fold())], - 'g_V_none_fold_none': [(lambda g:g.V().none().fold().none())], - 'g_V_none_fold_constantX1X': [(lambda g:g.V().none().fold().constant(1))], - 'g_V_projectXxX_byXcoalesceXage_isXgtX29XX_noneXX_selectXxX': [(lambda g:g.V().project('x').by(__.coalesce(__.values('age').is_(P.gt(29)), __.none())).select('x'))], 'g_V_orXhasXage_gt_27X__outE_count_gte_2X_name': [(lambda g:g.V().or_(__.has('age', P.gt(27)), __.out_e().count().is_(P.gte(2))).values('name'))], 'g_V_orXoutEXknowsX__hasXlabel_softwareX_or_hasXage_gte_35XX_name': [(lambda g:g.V().or_(__.out_e('knows'), __.has(T.label, 'software').or_().has('age', P.gte(35))).values('name'))], 'g_V_asXaX_orXselectXaX_selectXaXX': [(lambda g:g.V().as_('a').or_(__.select('a'), __.select('a')))], diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java index af61f822b5..bbf59db189 100644 --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java @@ -30,7 +30,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.VerificationException; import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal; import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException; -import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.Transaction; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -38,12 +37,10 @@ import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; import org.junit.Ignore; import org.junit.Test; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; -import java.util.stream.Collectors; import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN; import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal; @@ -52,7 +49,6 @@ import static org.apache.tinkerpop.gremlin.structure.Graph.Features.GraphFeature import static org.hamcrest.core.StringStartsWith.startsWith; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertTrue; @@ -110,7 +106,7 @@ public class CoreTraversalTest extends AbstractGremlinProcessTest { assertEquals(2, traversal.asAdmin().getSideEffects().<BulkSet>get("x").size()); assertTrue(traversal.asAdmin().getSideEffects().<BulkSet>get("x").contains("ripple")); assertTrue(traversal.asAdmin().getSideEffects().<BulkSet>get("x").contains("lop")); - assertEquals(Traversal.Symbols.none, traversal.asAdmin().getBytecode().getStepInstructions().get(traversal.asAdmin().getBytecode().getStepInstructions().size()-1).getOperator()); + assertEquals(Traversal.Symbols.discard, traversal.asAdmin().getBytecode().getStepInstructions().get(traversal.asAdmin().getBytecode().getStepInstructions().size()-1).getOperator()); } @Test diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/None.feature b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Discard.feature similarity index 78% rename from gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/None.feature rename to gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Discard.feature index 59f9788497..25e0dadff0 100644 --- a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/None.feature +++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Discard.feature @@ -15,63 +15,63 @@ # specific language governing permissions and limitations # under the License. -@StepClassFilter @StepNone -Feature: Step - none() +@StepClassFilter @StepDiscard +Feature: Step - discard() - Scenario: g_V_none + Scenario: g_V_discard Given the modern graph And the traversal of """ - g.V().none() + g.V().discard() """ When iterated to list Then the result should be empty - Scenario: g_V_none_none + Scenario: g_V_discard_discard Given the modern graph And the traversal of """ - g.V().none().none() + g.V().discard().discard() """ When iterated to list Then the result should be empty - Scenario: g_V_none_fold + Scenario: g_V_discard_fold Given the modern graph And the traversal of """ - g.V().none().fold() + g.V().discard().fold() """ When iterated to list Then the result should be unordered | result | | l[] | - Scenario: g_V_none_fold_none + Scenario: g_V_discard_fold_discard Given the modern graph And the traversal of """ - g.V().none().fold().none() + g.V().discard().fold().discard() """ When iterated to list Then the result should be empty - Scenario: g_V_none_fold_constantX1X + Scenario: g_V_discard_fold_constantX1X Given the modern graph And the traversal of """ - g.V().none().fold().constant(1) + g.V().discard().fold().constant(1) """ When iterated to list Then the result should be unordered | result | | d[1].i | - Scenario: g_V_projectXxX_byXcoalesceXage_isXgtX29XX_noneXX_selectXxX + Scenario: g_V_projectXxX_byXcoalesceXage_isXgtX29XX_discardXX_selectXxX Given the modern graph And the traversal of """ - g.V().project("x").by(__.coalesce(__.values("age").is(P.gt(29)), __.none())). + g.V().project("x").by(__.coalesce(__.values("age").is(P.gt(29)), __.discard())). select("x") """ When iterated to list