diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index a053f8de66e..be38509d8fd 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -23,7 +23,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima [[release-3-7-2]] === TinkerPop 3.7.2 (NOT OFFICIALLY RELEASED YET) -* Deprecated `none()` in favor of `discard()` to make room for a list filtering `none()` step. +* Deprecated `none()`, which will be renamed to `discard()` in release 4.0.0. [[release-3-7-1]] diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc index 5c6f9189159..a1dd16638ee 100644 --- a/docs/src/reference/the-traversal.asciidoc +++ b/docs/src/reference/the-traversal.asciidoc @@ -1448,21 +1448,6 @@ 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 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 `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 @@ -3170,12 +3155,11 @@ the remote end and not returned to the client side. Typically, this step does no quietly used by the `iterate()` terminal step which appends `none()` to the traversal before actually cycling through results. -NOTE: As of release 3.7.2, `none()` has been deprecated in favor of `discard()` and is no longer used by `iterate()`. +NOTE: As of release 3.7.2, `none()` has been deprecated and will be renamed to `discard()` in 4.0.0. *Additional References* -link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/Traversal.html#none()++[`discard()`] -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#none()++[`none()`] link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/Traversal.html#iterate()++[`iterate()`] [[not-step]] diff --git a/docs/src/upgrade/release-3.7.x.asciidoc b/docs/src/upgrade/release-3.7.x.asciidoc index aca5671de81..31a7cd3ea84 100644 --- a/docs/src/upgrade/release-3.7.x.asciidoc +++ b/docs/src/upgrade/release-3.7.x.asciidoc @@ -32,13 +32,13 @@ complete list of all the modifications that are part of this release. ==== Deprecated `none()` Step `none()`, which is primarily used by `iterate()` to discard traversal results in remote contexts, has been deprecated -in favor of `discard()`. Going forward, users should instead use `discard()` as `none()` will be removed in future versions. +and will be renamed to `discard()` in release 4.0.0. === Upgrading for Providers ==== Renaming None Step to Discard NoneStep, which is primarily used by `iterate()` to discard traversal results in remote contexts, has been deprecated -in favor of DiscardStep and will be removed in the next major release to make room for a list filtering step NoneStep. +and will be renamed to DiscardStep in release 4.0.0 to make room for a list filtering NoneStep. == TinkerPop 3.7.1 *Release Date: November 20, 2023* 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 fd8ef532acd..35660c10898 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 @@ -1247,10 +1247,6 @@ protected void notImplemented(final ParseTree ctx) { * {@inheritDoc} */ @Override public T visitTraversalTerminalMethod_toBulkSet(final GremlinParser.TraversalTerminalMethod_toBulkSetContext ctx) { notImplemented(ctx); return null; } - /** - * {@inheritDoc} - */ - @Override public T visitTraversalSelfMethod_discard(final GremlinParser.TraversalSelfMethod_discardContext ctx) { notImplemented(ctx); return null; } /** * {@inheritDoc} */ diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalRootVisitor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalRootVisitor.java index 57c9bbbdb84..2aee41e9a42 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalRootVisitor.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalRootVisitor.java @@ -104,14 +104,6 @@ public Traversal visitTraversalSelfMethod(final GremlinParser.TraversalSelfMetho return visitChildren(ctx); } - /** - * {@inheritDoc} - */ - @Override - public Traversal visitTraversalSelfMethod_discard(final GremlinParser.TraversalSelfMethod_discardContext ctx) { - this.traversal = traversal.discard(); - return this.traversal; - } /** * {@inheritDoc} 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 05d1ee3970a..c924e3c168b 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.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.DiscardStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep; 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,6 @@ private Symbols() { } public static final String profile = "profile"; - public static final String discard = "none"; public static final String none = "none"; } @@ -202,7 +201,7 @@ public default > C fill(final C collection) { public default Traversal iterate() { try { if (!this.asAdmin().isLocked()) { - this.discard(); + this.none(); this.asAdmin().applyStrategies(); } // use the end step so the results are bulked @@ -222,26 +221,14 @@ public default Traversal iterate() { * 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 DiscardStep}. - */ - public default Traversal discard() { - this.asAdmin().getBytecode().addStep(Symbols.discard); - return this.asAdmin().addStep(new DiscardStep<>(this.asAdmin())); - } - - /** - * Filter all traversers in the traversal. This step has narrow use cases and is primarily intended for use as 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 DiscardStep}. + * @return the updated traversal with respective {@link NoneStep}. * - * @deprecated As of release 3.7.2, replaced by {@link #discard()}. + * @deprecated As of release 3.7.2 and will be renamed to discard() in 4.0.0. */ @Deprecated public default Traversal none() { this.asAdmin().getBytecode().addStep(Symbols.none); - return this.asAdmin().addStep(new DiscardStep<>(this.asAdmin())); + return this.asAdmin().addStep(new NoneStep<>(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 2773d0b1fa6..26df4a9be28 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 @@ -63,7 +63,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.filter.CoinStep; import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DedupGlobalStep; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep; 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; @@ -2006,21 +2006,9 @@ public default GraphTraversal filter(final Traversal filterTraversal * 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 DiscardStep}. - */ - @Override - default GraphTraversal discard() { - return (GraphTraversal) Traversal.super.discard(); - } - - /** - * Filter all traversers in the traversal. This step has narrow use cases and is primarily intended for use as 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 DiscardStep}. + * @return the updated traversal with respective {@link NoneStep}. * - * @deprecated As of release 3.7.2, replaced by {@link #discard()}. + * @deprecated As of release 3.7.2 and will be renamed to discard() in 4.0.0. */ @Deprecated @Override 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 5a662c4eadb..2c2a069a193 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 @@ -805,13 +805,6 @@ public static GraphTraversal> difference(final Object values) { return __.start().difference(values); } - /** - * @see GraphTraversal#discard() - */ - public static GraphTraversal discard() { - return __.start().discard(); - } - /** * @see GraphTraversal#disjunct(Object) */ diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/DiscardStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/NoneStep.java similarity index 92% rename from gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/DiscardStep.java rename to gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/NoneStep.java index 45baf81fd78..1d43444bd55 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/DiscardStep.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/NoneStep.java @@ -26,9 +26,9 @@ /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public final class DiscardStep extends FilterStep { +public final class NoneStep extends FilterStep { - public DiscardStep(final Traversal.Admin traversal) { + public NoneStep(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 01038ae2fc5..e9903a96c63 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.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.DiscardStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep; 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; @@ -38,15 +38,15 @@ * 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 DiscardStep} instead. + * as many steps as possible and add a {@link NoneStep} instead. * * @author Daniel Kuppitz (http://gremlin.guru) * @example
  * __.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().discard()
- * __.outE().limit(5).valueMap().range(5, 10).cap("a")   // becomes __.outE().discard().cap("a")
+ * __.outE().limit(5).valueMap().range(5, 10)            // becomes __.outE().none()
+ * __.outE().limit(5).valueMap().range(5, 10).cap("a")   // becomes __.outE().none().cap("a")
  * 
*/ public final class EarlyLimitStrategy @@ -73,10 +73,10 @@ public void apply(final Traversal.Admin traversal) { // 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 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 (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 (!(steps.get(i) instanceof SideEffectCapStep) && !(steps.get(i) instanceof ProfileSideEffectStep)) { traversal.removeStep(i); } @@ -106,7 +106,7 @@ private Step moveRangeStep(final RangeGlobalStep step, final Step insertAfter, f 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 DiscardStep + // otherwise a NoneStep final RangeGlobalStep other = (RangeGlobalStep) insertAfter; final long low = other.getLowRange() + step.getLowRange(); if (other.getHighRange() == -1L) { @@ -116,11 +116,11 @@ private Step moveRangeStep(final RangeGlobalStep step, final Step insertAfter, f if (low < high) { rangeStep = new RangeGlobalStep(traversal, low, high); } else { - rangeStep = new DiscardStep<>(traversal); + rangeStep = new NoneStep<>(traversal); } } else { final long high = Math.min(other.getLowRange() + step.getHighRange(), other.getHighRange()); - rangeStep = high > low ? new RangeGlobalStep(traversal, low, high) : new DiscardStep<>(traversal); + rangeStep = high > low ? new RangeGlobalStep(traversal, low, high) : new NoneStep<>(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 1a51ea0685c..893ec21fd94 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 @@ -23,7 +23,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; 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.DiscardStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep; 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.map.ElementStep; @@ -113,14 +113,14 @@ public void apply(final Traversal.Admin traversal) { (i > 0 || ((GraphStep) step).getIds().length >= BIG_START_SIZE || (((GraphStep) step).getIds().length == 0 && !(step.getNextStep() instanceof HasStep))))) { - // DiscardStep, EmptyStep signify the end of the traversal where no barriers are really going to be + // NoneStep, EmptyStep signify the end of the traversal where no barriers are really going to be // helpful after that. ProfileSideEffectStep means the traversal had profile() called on it and if // we don't account for that a barrier will inject at the end of the traversal where it wouldn't // be otherwise. LazyBarrierStrategy executes before the finalization strategy of ProfileStrategy // so additionally injected ProfileSideEffectStep instances should not have effect here. if (foundFlatMap && !labeledPath && !(step.getNextStep() instanceof Barrier) && - !(step.getNextStep() instanceof DiscardStep) && + !(step.getNextStep() instanceof NoneStep) && !(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 7a2bedbe1a2..c8831cd0d61 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,7 +27,7 @@ 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.DiscardStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep; 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.util.EmptyStep; @@ -136,7 +136,7 @@ public void apply(final Traversal.Admin traversal) { !(currentStep instanceof Barrier) && !(currentStep.getNextStep() instanceof Barrier) && !(currentStep.getTraversal().getParent() instanceof MatchStep) && - !(currentStep.getNextStep() instanceof DiscardStep) && + !(currentStep.getNextStep() instanceof NoneStep) && !(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 a57cea667a3..43c758e8e4e 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 @@ -24,7 +24,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal; import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; import org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep; 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,9 +73,9 @@ public void apply(final Traversal.Admin traversal) { if (TraversalHelper.hasStepOfClass(ProfileSideEffectStep.class, traversal) && !(endStep instanceof ProfileSideEffectStep || (endStep instanceof SideEffectCapStep && endStep.getPreviousStep() instanceof ProfileSideEffectStep) || - (endStep instanceof DiscardStep && endStep.getPreviousStep() instanceof SideEffectCapStep && endStep.getPreviousStep().getPreviousStep() instanceof ProfileSideEffectStep) || + (endStep instanceof NoneStep && 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 DiscardStep && endStep.getPreviousStep().getPreviousStep() instanceof SideEffectCapStep && endStep.getPreviousStep().getPreviousStep().getPreviousStep() instanceof ProfileSideEffectStep))) { + (endStep instanceof RequirementsStep && endStep.getPreviousStep() instanceof NoneStep && 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 7f4ba73a463..432f66c81af 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 @@ -43,7 +43,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.filter.AnyStep; import org.apache.tinkerpop.gremlin.process.traversal.step.filter.CoinStep; import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DedupGlobalStep; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep; 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; @@ -322,8 +322,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.discard, Collections.singletonList(DiscardStep.class)); - put(Traversal.Symbols.none, Collections.singletonList(DiscardStep.class)); + put(Traversal.Symbols.none, Collections.singletonList(NoneStep.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/TraversalRootVisitorTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalRootVisitorTest.java index 8a07f34e7c8..a6bc04f0e67 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 @@ -40,12 +40,6 @@ public void setup() { antlrToLanguage = new GremlinAntlrToJava(); } - @Test - public void shouldParseTraversalMethod_discard() { - compare(g.V().discard(), eval("g.V().discard()")); - compare(g.V().union(__.identity().discard()), eval("g.V().union(__.identity().none())")); - } - @Test public void shouldParseTraversalMethod_none() { compare(g.V().none(), eval("g.V().none()")); 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 bde6045b0b6..28936eaa981 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 @@ -146,8 +146,6 @@ else if (stepMethod.getName().equals("option")) traversal.branch(__.identity().out(randomString(random))); else if (stepMethod.getName().equals("to") || stepMethod.getName().equals("from")) traversal.addE(randomString(random)); - else if (stepMethod.getName().equals("discard")) - continue; if (stepMethod.getName().equals("range")) { if (Scope.class.isAssignableFrom(stepMethod.getParameterTypes()[0])) { 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 55bd397f631..d6578dda241 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 void doTest() { public static Iterable 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().discard(), Collections.emptyList()}, - {__.out().limit(5).valueMap().range(6, 10), __.start().out().discard(), 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()}, {__.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 static Iterable generateTestParameters() { {__.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().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().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().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 6bc20e4e211..084b795273c 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 void shouldBeVerified() { if (legalTraversal) { copy.asAdmin().applyStrategies(); - // try to also apply strategies with iterate() so that a DiscardStep is added - for consistency sake we want + // try to also apply strategies with iterate() so that a NoneStep 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-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs index 93076323770..ad44007f34f 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs @@ -704,15 +704,6 @@ public GraphTraversal Difference (object differenceObject) return Wrap(this); } - /// - /// Adds the discard step to this . - /// - public GraphTraversal Discard () - { - Bytecode.AddStep("none"); - return Wrap(this); - } - /// /// Adds the disjunct step to this . /// diff --git a/gremlin-go/driver/anonymousTraversal.go b/gremlin-go/driver/anonymousTraversal.go index 10fbe25366c..eaefc55c9ad 100644 --- a/gremlin-go/driver/anonymousTraversal.go +++ b/gremlin-go/driver/anonymousTraversal.go @@ -105,8 +105,6 @@ 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. @@ -491,11 +489,6 @@ 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...) diff --git a/gremlin-go/driver/graphTraversal.go b/gremlin-go/driver/graphTraversal.go index c4ea2431728..c3f7fca266f 100644 --- a/gremlin-go/driver/graphTraversal.go +++ b/gremlin-go/driver/graphTraversal.go @@ -252,12 +252,6 @@ 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("none", args...) - return g -} - // Disjunct adds the disjunct step to the GraphTraversal. func (g *GraphTraversal) Disjunct(args ...interface{}) *GraphTraversal { g.Bytecode.AddStep("disjunct", args...) 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 3bcbed80937..1838f66a094 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 @@ -693,16 +693,6 @@ class GraphTraversal extends Traversal { return this; } - /** - * Graph traversal discard method. - * @param {...Object} args - * @returns {GraphTraversal} - */ - discard(...args) { - this.bytecode.addStep('none', args); - return this; - } - /** * Graph traversal disjunct method. * @param {...Object} args diff --git a/gremlin-language/src/main/antlr4/Gremlin.g4 b/gremlin-language/src/main/antlr4/Gremlin.g4 index 2974074eb6e..95b93e9e84a 100644 --- a/gremlin-language/src/main/antlr4/Gremlin.g4 +++ b/gremlin-language/src/main/antlr4/Gremlin.g4 @@ -1147,8 +1147,7 @@ traversalSackMethod ; traversalSelfMethod - : traversalSelfMethod_discard - | traversalSelfMethod_none + : traversalSelfMethod_none ; // Additional special rules that are derived from above @@ -1282,10 +1281,6 @@ traversalTerminalMethod_toBulkSet : 'toBulkSet' LPAREN RPAREN ; -traversalSelfMethod_discard - : 'discard' LPAREN RPAREN - ; - traversalSelfMethod_none : 'none' LPAREN RPAREN ; 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 48f8664daea..67d9dd788b5 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 @@ -449,10 +449,6 @@ def difference(self, *args): self.bytecode.add_step("difference", *args) return self - def discard(self, *args): - self.bytecode.add_step("none", *args) - return self - def disjunct(self, *args): self.bytecode.add_step("disjunct", *args) return self 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 9174270d3c4..c57eef8a1c8 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 @@ -46,12 +46,11 @@ import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal; import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.inject; import static org.apache.tinkerpop.gremlin.structure.Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; 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; import static org.junit.Assert.fail; @@ -107,7 +106,7 @@ public void shouldFilterOnIterate() { assertEquals(2, traversal.asAdmin().getSideEffects().get("x").size()); assertTrue(traversal.asAdmin().getSideEffects().get("x").contains("ripple")); assertTrue(traversal.asAdmin().getSideEffects().get("x").contains("lop")); - assertEquals(Traversal.Symbols.discard, traversal.asAdmin().getBytecode().getStepInstructions().get(traversal.asAdmin().getBytecode().getStepInstructions().size()-1).getOperator()); + assertEquals(Traversal.Symbols.none, 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/Discard.feature b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Discard.feature deleted file mode 100644 index 8d1194d2574..00000000000 --- a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Discard.feature +++ /dev/null @@ -1,49 +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. - -@StepClassMap @StepDiscard -Feature: Step - discard() - - Scenario: g_V_count_discard - Given the modern graph - And the traversal of - """ - g.V().count().discard() - """ - When iterated to list - Then the result should be empty - - Scenario: g_V_hasLabelXpersonX_discard - Given the modern graph - And the traversal of - """ - g.V().hasLabel("person").discard() - """ - When iterated to list - Then the result should be empty - - Scenario: g_VX1X_outXcreatedX_discard - Given the modern graph - And using the parameter vid1 defined as "v[marko].id" - And the traversal of - """ - g.V(vid1).out("created").discard() - """ - When iterated to list - Then the result should be empty - -