You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by xi...@apache.org on 2023/12/20 22:06:00 UTC
(tinkerpop) branch master updated: Replace `none()` with `discard()` (#2377)
This is an automated email from the ASF dual-hosted git repository.
xiazcy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
The following commit(s) were added to refs/heads/master by this push:
new 62a3935152 Replace `none()` with `discard()` (#2377)
62a3935152 is described below
commit 62a3935152354eea54f2cfadc39edf10ebe2005d
Author: Ryan Tan <65...@users.noreply.github.com>
AuthorDate: Wed Dec 20 14:05:53 2023 -0800
Replace `none()` with `discard()` (#2377)
Renames none() to discard() to make room for a new list filtering none() step in #2385.
---
CHANGELOG.asciidoc | 2 +-
docs/src/reference/the-traversal.asciidoc | 32 +++++++-------
docs/src/upgrade/release-4.x.x.asciidoc | 10 +++++
.../grammar/DefaultGremlinBaseVisitor.java | 2 +-
.../language/grammar/TraversalRootVisitor.java | 4 +-
.../gremlin/process/traversal/Traversal.java | 18 ++++----
.../traversal/dsl/graph/GraphTraversal.java | 8 ++--
.../gremlin/process/traversal/dsl/graph/__.java | 1 -
.../filter/{NoneStep.java => DiscardStep.java} | 4 +-
.../strategy/optimization/EarlyLimitStrategy.java | 22 +++++-----
.../strategy/optimization/LazyBarrierStrategy.java | 6 +--
.../optimization/PathRetractionStrategy.java | 8 +---
.../verification/StandardVerificationStrategy.java | 7 ++--
.../process/traversal/util/BytecodeHelper.java | 12 +++---
.../language/grammar/TraversalRootVisitorTest.java | 6 +--
.../traversal/dsl/graph/GraphTraversalTest.java | 2 +-
.../optimization/EarlyLimitStrategyTest.java | 16 +++----
.../StandardVerificationStrategyTest.java | 2 +-
.../Process/Traversal/DefaultTraversal.cs | 2 +-
.../Process/Traversal/GraphTraversal.cs | 18 ++++----
.../Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs | 3 ++
gremlin-go/driver/anonymousTraversal.go | 14 +++----
gremlin-go/driver/cucumber/gremlin.go | 3 ++
gremlin-go/driver/graphTraversal.go | 12 +++---
gremlin-go/driver/traversal.go | 2 +-
.../lib/process/graph-traversal.js | 20 ++++-----
.../gremlin-javascript/lib/process/traversal.js | 2 +-
.../gremlin-javascript/test/cucumber/gremlin.js | 3 ++
gremlin-language/src/main/antlr4/Gremlin.g4 | 6 +--
.../gremlin_python/process/graph_traversal.py | 8 ++--
.../python/gremlin_python/process/traversal.py | 2 +-
gremlin-python/src/main/python/radish/gremlin.py | 3 ++
.../process/traversal/CoreTraversalTest.java | 5 +--
.../gremlin/test/features/filter/Discard.feature | 49 ++++++++++++++++++++++
34 files changed, 187 insertions(+), 127 deletions(-)
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 604c5aabd4..65dff64335 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -31,6 +31,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
* Deprecated `withEmbedded()` and `withRemote()` options on `AnonymousTraversalSource`.
* Added `with()` on `AnonymousTraversalSource` to cover both embedded and remote creation options.
* Removed the deprecated `withGraph()` option from `AnonymousTraversalSource`.
+* Renamed the traversal discarding `none()` step to `discard()`.
* Bumped to `commons-collection4`.
== TinkerPop 3.7.0 (Gremfir Master of the Pan Flute)
@@ -41,7 +42,6 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
=== TinkerPop 3.7.2 (NOT OFFICIALLY RELEASED YET)
-
[[release-3-7-1]]
=== TinkerPop 3.7.1 (November 20, 2023)
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index 01f92208b8..fe1e3e7224 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -1448,6 +1448,21 @@ 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
@@ -3145,23 +3160,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-4.x.x.asciidoc b/docs/src/upgrade/release-4.x.x.asciidoc
index ddaf969d05..b697303747 100644
--- a/docs/src/upgrade/release-4.x.x.asciidoc
+++ b/docs/src/upgrade/release-4.x.x.asciidoc
@@ -75,6 +75,11 @@ See: link:https://issues.apache.org/jira/browse/TINKERPOP-3017[TINKERPOP-3017]
Starting from this version, `gremlin-javascript` will deserialize `Set` data into a ECMAScript 2015 Set. Previously,
these were deserialized into arrays.
+==== Renaming none() to discard()
+`none()`, which was primarily used by `iterate()` to discard traversal results in remote contexts, has been renamed to
+`discard()`. In its place will be a new list filtering step `none()`, which takes a predicate as an argument and passes
+lists with no elements matching the predicate.
+
==== Improved handling of integer overflows
Integer overflows caused by addition and multiplication operations will throw an exception instead of being silently
@@ -82,6 +87,11 @@ skipped with incorrect result.
=== Upgrading for Providers
+==== Renaming NoneStep to DiscardStep
+NoneStep, which was primarily used by `iterate()` to discard traversal results in remote contexts, has been renamed to
+DiscardStep. In its place will be a new list filtering NoneStep, which takes a predicate as an argument and passes lists
+with no elements matching the predicate.
+
==== Graph System Providers
===== AbstractAuthenticatorHandler Constructor
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 35660c1089..ef6f632f19 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
@@ -1250,7 +1250,7 @@ public class DefaultGremlinBaseVisitor<T> extends AbstractParseTreeVisitor<T> im
/**
* {@inheritDoc}
*/
- @Override public T visitTraversalSelfMethod_none(final GremlinParser.TraversalSelfMethod_noneContext ctx) { notImplemented(ctx); return null; }
+ @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 0e52b606d5..501050d977 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
@@ -108,8 +108,8 @@ public class TraversalRootVisitor<G extends Traversal> extends DefaultGremlinBas
* {@inheritDoc}
*/
@Override
- public Traversal visitTraversalSelfMethod_none(final GremlinParser.TraversalSelfMethod_noneContext ctx) {
- this.traversal = traversal.none();
+ public Traversal visitTraversalSelfMethod_discard(final GremlinParser.TraversalSelfMethod_discardContext ctx) {
+ this.traversal = traversal.discard();
return this.traversal;
}
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..17e4fbe9b2 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;
@@ -35,6 +35,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalExplanation;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics;
import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator;
+import org.apache.tinkerpop.gremlin.util.function.TraverserSetSupplier;
import java.io.Serializable;
import java.util.ArrayList;
@@ -53,8 +55,6 @@ import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
-import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator;
-import org.apache.tinkerpop.gremlin.util.function.TraverserSetSupplier;
/**
* A {@link Traversal} represents a directed walk over a {@link Graph}.
@@ -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 0fac884f26..4451882375 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,11 +63,11 @@ 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.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.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.NotStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.PathFilterStep;
@@ -2006,11 +2006,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 d6cdc1ef7f..2c2a069a19 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
@@ -25,7 +25,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.Pop;
import org.apache.tinkerpop.gremlin.process.traversal.Scope;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.FormatStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.TraverserSet;
import org.apache.tinkerpop.gremlin.structure.Column;
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 e9903a96c6..01038ae2fc 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;
@@ -38,15 +38,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
@@ -73,10 +73,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);
}
@@ -106,7 +106,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) {
@@ -116,11 +116,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..1a51ea0685 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,9 +23,9 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
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.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.map.ElementStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
@@ -113,14 +113,14 @@ public final class LazyBarrierStrategy extends AbstractTraversalStrategy<Travers
(i > 0 || ((GraphStep) step).getIds().length >= BIG_START_SIZE ||
(((GraphStep) step).getIds().length == 0 && !(step.getNextStep() instanceof HasStep))))) {
- // NoneStep, EmptyStep signify the end of the traversal where no barriers are really going to be
+ // DiscardStep, 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 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 cd29b28820..7a2bedbe1a 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 5a41c92f7b..a57cea667a 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;
@@ -74,9 +73,9 @@ public final class StandardVerificationStrategy extends AbstractTraversalStrateg
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 bc43aaeb52..aca26d11dc 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
@@ -19,10 +19,6 @@
package org.apache.tinkerpop.gremlin.process.traversal.util;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ConnectedComponentVertexProgramStep;
import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.PageRankVertexProgramStep;
import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.PeerPressureVertexProgramStep;
@@ -47,11 +43,11 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.filter.AndStep;
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.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.NotStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.PathFilterStep;
@@ -169,8 +165,12 @@ import org.apache.tinkerpop.gremlin.util.function.Lambda;
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Stream;
@@ -322,7 +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.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/TraversalRootVisitorTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalRootVisitorTest.java
index a6bc04f0e6..352547b1a5 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
@@ -41,9 +41,9 @@ 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())"));
+ public void shouldParseTraversalMethod_discard() {
+ 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 28936eaa98..f0c53eba78 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
@@ -50,7 +50,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-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs
index d2da68e703..fc621f1758 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs
@@ -228,7 +228,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 2c38967374..4902d85802 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
@@ -704,6 +704,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>
@@ -1491,15 +1500,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/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
index 4cc6e6401d..66efb53e85 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
@@ -197,6 +197,9 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
{"g_V_both_dedup_age_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Both().Dedup().By("age").Values<object>("name")}},
{"g_VX1X_asXaX_both_asXbX_both_asXcX_dedupXa_bX_age_selectXa_b_cX_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).As("a").Both().As("b").Both().As("c").Dedup("a","b").By("age").Select<object>("a","b","c").By("name")}},
{"g_VX1X_valuesXageX_dedupXlocalX_unfold", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Values<object>("age").Dedup(Scope.Local).Unfold<object>()}},
+ {"g_V_count_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Count().Discard()}},
+ {"g_V_hasLabelXpersonX_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().HasLabel("person").Discard()}},
+ {"g_VX1X_outXcreatedX_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Out("created").Discard()}},
{"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>()}},
diff --git a/gremlin-go/driver/anonymousTraversal.go b/gremlin-go/driver/anonymousTraversal.go
index a1b3a3f0b1..a766c4983c 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.
@@ -501,6 +501,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...)
@@ -721,11 +726,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 7cbf449ed7..67fb2625e9 100644
--- a/gremlin-go/driver/cucumber/gremlin.go
+++ b/gremlin-go/driver/cucumber/gremlin.go
@@ -168,6 +168,9 @@ var translationMap = map[string][]func(g *gremlingo.GraphTraversalSource, p map[
"g_V_both_dedup_age_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Both().Dedup().By("age").Values("name")}},
"g_VX1X_asXaX_both_asXbX_both_asXcX_dedupXa_bX_age_selectXa_b_cX_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid1"]).As("a").Both().As("b").Both().As("c").Dedup("a", "b").By("age").Select("a", "b", "c").By("name")}},
"g_VX1X_valuesXageX_dedupXlocalX_unfold": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid1"]).Values("age").Dedup(gremlingo.Scope.Local).Unfold()}},
+ "g_V_count_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Count().Discard()}},
+ "g_V_hasLabelXpersonX_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().HasLabel("person").Discard()}},
+ "g_VX1X_outXcreatedX_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid1"]).Out("created").Discard()}},
"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 [...]
diff --git a/gremlin-go/driver/graphTraversal.go b/gremlin-go/driver/graphTraversal.go
index c3f7fca266..d0a6403876 100644
--- a/gremlin-go/driver/graphTraversal.go
+++ b/gremlin-go/driver/graphTraversal.go
@@ -252,6 +252,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...)
@@ -518,12 +524,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 ce07501d5b..9532d98f7d 100644
--- a/gremlin-go/driver/traversal.go
+++ b/gremlin-go/driver/traversal.go
@@ -76,7 +76,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 50265246da..3992e0db24 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
@@ -672,6 +672,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
@@ -1111,16 +1121,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
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 7a96ea60be..2f949b54b6 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
@@ -188,6 +188,9 @@ const gremlins = {
g_V_both_dedup_age_name: [function({g}) { return g.V().both().dedup().by("age").values("name") }],
g_VX1X_asXaX_both_asXbX_both_asXcX_dedupXa_bX_age_selectXa_b_cX_name: [function({g, vid1}) { return g.V(vid1).as("a").both().as("b").both().as("c").dedup("a","b").by("age").select("a","b","c").by("name") }],
g_VX1X_valuesXageX_dedupXlocalX_unfold: [function({g, vid1}) { return g.V(vid1).values("age").dedup(Scope.local).unfold() }],
+ g_V_count_discard: [function({g}) { return g.V().count().discard() }],
+ g_V_hasLabelXpersonX_discard: [function({g}) { return g.V().hasLabel("person").discard() }],
+ g_VX1X_outXcreatedX_discard: [function({g, vid1}) { return g.V(vid1).out("created").discard() }],
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() }],
diff --git a/gremlin-language/src/main/antlr4/Gremlin.g4 b/gremlin-language/src/main/antlr4/Gremlin.g4
index 95b93e9e84..4cb4c076b7 100644
--- a/gremlin-language/src/main/antlr4/Gremlin.g4
+++ b/gremlin-language/src/main/antlr4/Gremlin.g4
@@ -1147,7 +1147,7 @@ traversalSackMethod
;
traversalSelfMethod
- : traversalSelfMethod_none
+ : traversalSelfMethod_discard
;
// Additional special rules that are derived from above
@@ -1281,8 +1281,8 @@ traversalTerminalMethod_toBulkSet
: 'toBulkSet' LPAREN RPAREN
;
-traversalSelfMethod_none
- : 'none' LPAREN RPAREN
+traversalSelfMethod_discard
+ : 'discard' LPAREN RPAREN
;
// Gremlin specific lexer rules
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 eae0c8d264..a5466669ed 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
@@ -438,6 +438,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
@@ -684,10 +688,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
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 3183e43480..2b995b4012 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 ab5168e468..c427c7d4cd 100644
--- a/gremlin-python/src/main/python/radish/gremlin.py
+++ b/gremlin-python/src/main/python/radish/gremlin.py
@@ -170,6 +170,9 @@ world.gremlins = {
'g_V_both_dedup_age_name': [(lambda g:g.V().both().dedup().by('age').name)],
'g_VX1X_asXaX_both_asXbX_both_asXcX_dedupXa_bX_age_selectXa_b_cX_name': [(lambda g, vid1=None:g.V(vid1).as_('a').both().as_('b').both().as_('c').dedup('a','b').by('age').select('a','b','c').by('name'))],
'g_VX1X_valuesXageX_dedupXlocalX_unfold': [(lambda g, vid1=None:g.V(vid1).age.dedup(Scope.local).unfold())],
+ 'g_V_count_discard': [(lambda g:g.V().count().discard())],
+ 'g_V_hasLabelXpersonX_discard': [(lambda g:g.V().hasLabel('person').discard())],
+ 'g_VX1X_outXcreatedX_discard': [(lambda g, vid1=None:g.V(vid1).out('created').discard())],
'g_V_drop': [(lambda g:g.addV().as_('a').addV().as_('b').addE('knows').to('a')), (lambda g:g.V().drop()), (lambda g:g.V()), (lambda g:g.E())],
'g_V_outE_drop': [(lambda g:g.addV().as_('a').addV().as_('b').addE('knows').to('a')), (lambda g:g.V().outE().drop()), (lambda g:g.V()), (lambda g:g.E())],
'g_V_properties_drop': [(lambda g:g.addV().property('name','bob').addV().property('name','alice')), (lambda g:g.V().properties().drop()), (lambda g:g.V()), (lambda g:g.V().properties())],
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..9174270d3c 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;
@@ -110,7 +107,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/Discard.feature b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Discard.feature
new file mode 100644
index 0000000000..8d1194d257
--- /dev/null
+++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Discard.feature
@@ -0,0 +1,49 @@
+# 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
+
+