You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2025/08/02 17:00:22 UTC
(tinkerpop) branch backport-discard updated (b7d29c83d1 -> 1d11a4a089)
This is an automated email from the ASF dual-hosted git repository.
spmallette pushed a change to branch backport-discard
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
discard b7d29c83d1 Backported more discard() steps from 4.x
discard feba8de6ca Backported e8b9532fc0ec811460e97ebf5e00b8b9ec9192ac from 4.x
discard 39ee87903a Backported 62a3935152354eea54f2cfadc39edf10ebe2005d from 4.x
new 6b29a6659e Backported 62a3935152354eea54f2cfadc39edf10ebe2005d from 4.x
new a7921d5829 Backported e8b9532fc0ec811460e97ebf5e00b8b9ec9192ac from 4.x
new 1d11a4a089 Backported more discard() steps from 4.x
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (b7d29c83d1)
\
N -- N -- N refs/heads/backport-discard (1d11a4a089)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
CHANGELOG.asciidoc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(tinkerpop) 02/03: Backported e8b9532fc0ec811460e97ebf5e00b8b9ec9192ac from 4.x
Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
spmallette pushed a commit to branch backport-discard
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit a7921d5829d1e6b8f1ca67ce24916b36f2345870
Author: Stephen Mallette <st...@amazon.com>
AuthorDate: Sat Aug 2 12:05:41 2025 -0400
Backported e8b9532fc0ec811460e97ebf5e00b8b9ec9192ac from 4.x
Implement list filtering none() step that takes a predicate and filters out lists that fail to have none of their elements satisfying the predicate.
---
CHANGELOG.asciidoc | 1 +
docs/src/dev/provider/gremlin-semantics.asciidoc | 34 +++++
docs/src/reference/the-traversal.asciidoc | 23 +++
.../grammar/DefaultGremlinBaseVisitor.java | 4 +
.../language/grammar/TraversalMethodVisitor.java | 8 +
.../traversal/dsl/graph/GraphTraversal.java | 15 ++
.../gremlin/process/traversal/dsl/graph/__.java | 5 +
.../process/traversal/step/filter/NoneStep.java | 87 +++++++++++
.../process/traversal/util/BytecodeHelper.java | 2 +
.../traversal/step/filter/NoneStepTest.java | 89 +++++++++++
.../Process/Traversal/GraphTraversal.cs | 9 ++
.../src/Gremlin.Net/Process/Traversal/__.cs | 12 +-
.../Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs | 13 ++
gremlin-go/driver/anonymousTraversal.go | 7 +
gremlin-go/driver/cucumber/gremlin.go | 13 ++
gremlin-go/driver/graphTraversal.go | 6 +
.../lib/process/graph-traversal.js | 11 ++
.../gremlin-javascript/test/cucumber/gremlin.js | 13 ++
gremlin-language/src/main/antlr4/Gremlin.g4 | 5 +
.../gremlin_python/process/graph_traversal.py | 14 ++
gremlin-python/src/main/python/radish/gremlin.py | 13 ++
.../gremlin/test/features/filter/None.feature | 168 +++++++++++++++++++++
22 files changed, 550 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index d59b9f0969..0dddd61e30 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -27,6 +27,7 @@ This release also includes changes from <<release-3-7-XXX, 3.7.XXX>>.
* Removed Vertex/ReferenceVertex from grammar. Use vertex id in traversals now instead.
* Renamed the traversal discarding `none()` step to `discard()`.
+* Repurposed `none()` step as a list filtering step.
* Modified mathematical operators to prevent overflows in steps such as `sum()` and 'sack()' to prefer promotion to the next highest number type.
* Added `DateTime` ontop of the existing 'datetime' grammar.
* Added `UUID()` and `UUID(value)` to grammar.
diff --git a/docs/src/dev/provider/gremlin-semantics.asciidoc b/docs/src/dev/provider/gremlin-semantics.asciidoc
index 6fe0d2c68e..5e3f166f18 100644
--- a/docs/src/dev/provider/gremlin-semantics.asciidoc
+++ b/docs/src/dev/provider/gremlin-semantics.asciidoc
@@ -1832,6 +1832,40 @@ resolve to a `Map`.
See: link:https://github.com/apache/tinkerpop/tree/x.y.z/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeVertexStep.java[source],
link:https://tinkerpop.apache.org/docs/x.y.z/reference/#mergev-step[reference]
+[[none-step]]
+=== none()
+
+*Description:* Filters array data from the traversal stream if none of the array's items match the supplied predicate.
+
+*Syntax:* `none(P predicate)`
+
+[width="100%",options="header"]
+|=========================================================
+|Start Step |Mid Step |Modulated |Domain |Range
+|N |Y |N |`List`/`array`/`Iterable`/`Iterator` |`List`/`array`/`Iterable`/`Iterator`
+|=========================================================
+
+*Arguments:*
+
+* `predicate` - The predicate used to test each value in the array data.
+
+*Modulation:*
+
+None
+
+*Considerations:*
+
+Each value will be tested using the supplied predicate. Empty lists always pass through and null/non-list traversers
+will be filtered out of the traversal stream.
+
+*Exceptions*
+
+* A GremlinTypeErrorException will be thrown if one occurs and no other value evaluates to true.
+
+See: link:https://github.com/apache/tinkerpop/tree/x.y.z/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/NoneStep.java[source],
+link:https://tinkerpop.apache.org/docs/x.y.z/reference/#none-step[reference]
+
+
[[product-step]]
=== product()
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index edd28510cb..1bb31c090a 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -3255,6 +3255,29 @@ 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
+
+It is possible to filter list traversers using `none()`-step (*filter*). Every item in the list will be tested against
+the supplied predicate and if none of the items pass then the traverser is passed along the stream, otherwise it is
+filtered. Empty lists are passed along but null or non-iterable traversers are filtered out.
+
+NOTE: Prior to release 3.8.0, `none()` was a traversal discarding step primarily used by <<iterate-step,`iterate()`>>.
+This step has since been renamed to <<discard-step,`discard()`>>
+
+[gremlin-groovy,modern]
+----
+g.V().values('age').fold().none(gt(25)) <1>
+----
+
+<1> Return the list of ages only if no one's age is greater than 25.
+
+*Additional References*
+
+link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.html#none(org.apache.tinkerpop.gremlin.process.traversal.P)++[`none(P)`],
+link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/P.html++[`P`]
+
+
[[not-step]]
=== Not Step
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 6a7382c144..c4dcb81f52 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
@@ -615,6 +615,10 @@ public class DefaultGremlinBaseVisitor<T> extends AbstractParseTreeVisitor<T> im
* {@inheritDoc}
*/
@Override public T visitTraversalMethod_discard(final GremlinParser.TraversalMethod_discardContext ctx) { notImplemented(ctx); return null; }
+ /**
+ * {@inheritDoc}
+ */
+ @Override public T visitTraversalMethod_none_P(final GremlinParser.TraversalMethod_none_PContext ctx) { notImplemented(ctx); return null; }
/**
* {@inheritDoc}
*/
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java
index 9ff820393b..7fc4b9a78e 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java
@@ -1115,6 +1115,14 @@ public class TraversalMethodVisitor extends TraversalRootVisitor<GraphTraversal>
return this.graphTraversal.discard();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GraphTraversal visitTraversalMethod_none_P(final GremlinParser.TraversalMethod_none_PContext ctx) {
+ return graphTraversal.none(antlr.traversalPredicateVisitor.visitTraversalPredicate(ctx.traversalPredicate()));
+ }
+
/**
* {@inheritDoc}
*/
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 b91e8f5950..ffe1394889 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
@@ -68,6 +68,7 @@ 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.DiscardStep;
+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;
@@ -2882,6 +2883,19 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
return this.asAdmin().addStep(new AnyStep<>(this.asAdmin(), predicate));
}
+ /**
+ * Filters <code>E</code> lists given the provided {@code predicate}.
+ *
+ * @param predicate the filter to apply
+ * @return the traversal with an appended {@link NoneStep}
+ * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#none-step" target="_blank">Reference Documentation - None Step</a>
+ * @since 3.8.0
+ */
+ public default <S2> GraphTraversal<S, E> none(final P<S2> predicate) {
+ this.asAdmin().getBytecode().addStep(Symbols.none, predicate);
+ return this.asAdmin().addStep(new NoneStep<>(this.asAdmin(), predicate));
+ }
+
///////////////////// SIDE-EFFECT STEPS /////////////////////
/**
@@ -4150,6 +4164,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
public static final String dateDiff = "dateDiff";
public static final String all = "all";
public static final String any = "any";
+ public static final String none = "none";
public static final String merge = "merge";
public static final String product = "product";
public static final String combine = "combine";
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 068a200e9d..b20dc48f78 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
@@ -1213,6 +1213,11 @@ public class __ {
*/
public static <A> GraphTraversal<A, A> any(final P<A> predicate) { return __.<A>start().any(predicate); }
+ /**
+ * @see GraphTraversal#none(P)
+ */
+ public static <A> GraphTraversal<A, A> none(final P<A> predicate) { return __.<A>start().none(predicate); }
+
///////////////////// SIDE-EFFECT STEPS /////////////////////
/**
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/NoneStep.java
new file mode 100644
index 0000000000..78f4f755e8
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/NoneStep.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.traversal.step.filter;
+
+import org.apache.tinkerpop.gremlin.process.traversal.GremlinTypeErrorException;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
+
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.Set;
+
+public final class NoneStep<S, S2> extends FilterStep<S> {
+
+ private P<S2> predicate;
+
+ public NoneStep(final Traversal.Admin traversal, final P<S2> predicate) {
+ super(traversal);
+
+ if (null == predicate) {
+ throw new IllegalArgumentException("Input predicate to none step can't be null.");
+ }
+
+ this.predicate = predicate;
+ }
+
+ @Override
+ protected boolean filter(final Traverser.Admin<S> traverser) {
+ final S item = traverser.get();
+
+ if (item instanceof Iterable || item instanceof Iterator || ((item != null) && item.getClass().isArray())) {
+ GremlinTypeErrorException typeError = null;
+ final Iterator<S2> iterator = IteratorUtils.asIterator(item);
+ while (iterator.hasNext()) {
+ try {
+ if (this.predicate.test(iterator.next())) {
+ return false;
+ }
+ } catch (GremlinTypeErrorException gtee) {
+ // hold onto it until the end in case any other element evaluates to TRUE
+ typeError = gtee;
+ }
+ }
+ if (typeError != null) throw typeError;
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return StringFactory.stepString(this, this.predicate);
+ }
+
+ @Override
+ public NoneStep<S, S2> clone() {
+ final NoneStep<S, S2> clone = (NoneStep<S, S2>) super.clone();
+ clone.predicate = this.predicate.clone();
+ return clone;
+ }
+
+ @Override
+ public Set<TraverserRequirement> getRequirements() {
+ return EnumSet.of(TraverserRequirement.OBJECT);
+ }
+}
\ No newline at end of file
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 5eb5ef252b..2d5b526a3d 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
@@ -52,6 +52,7 @@ 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.DiscardStep;
+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;
@@ -251,6 +252,7 @@ public final class BytecodeHelper {
put(GraphTraversal.Symbols.dateDiff, Collections.singletonList(DateDiffStep.class));
put(GraphTraversal.Symbols.all, Collections.singletonList(AllStep.class));
put(GraphTraversal.Symbols.any, Collections.singletonList(AnyStep.class));
+ put(GraphTraversal.Symbols.none, Collections.singletonList(NoneStep.class));
put(GraphTraversal.Symbols.combine, Collections.singletonList(CombineStep.class));
put(GraphTraversal.Symbols.difference, Collections.singletonList(DifferenceStep.class));
put(GraphTraversal.Symbols.disjunct, Collections.singletonList(DisjunctStep.class));
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/NoneStepTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/NoneStepTest.java
new file mode 100644
index 0000000000..f53ec9f28a
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/NoneStepTest.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.traversal.step.filter;
+
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.process.traversal.step.StepTest;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+
+public class NoneStepTest extends StepTest {
+
+ @Override
+ protected List<Traversal> getTraversals() { return Collections.singletonList(__.none(P.gt(0))); }
+
+ @Test
+ public void testReturnTypes() {
+ assertTrue(__.__(new int[]{}).none(P.gt(7)).hasNext());
+ assertArrayEquals(new int[] {5, 6}, __.__(new int[] {5, 8, 10}, new int[] {5, 6}).none(P.gte(7)).next());
+ assertArrayEquals(new long[] {5L, 6L}, __.__(new long[] {5L, 8L, 10L}, new long[] {5L, 6L}).none(P.gte(7)).next());
+ assertArrayEquals(new Long[] {5L, 6L}, __.__(1).constant(new Long[] {5L, 6L}).none(P.gte(7)).next());
+ assertArrayEquals(new double[] {5.1, 6.5}, __.__(new double[] {5.5, 8.0, 10.1}, new double[] {5.1, 6.5}).none(P.gte(7.0)).next(), 0.01);
+ }
+
+ @Test
+ public void testNullParameter() {
+ final Throwable thrown = assertThrows(IllegalArgumentException.class, () -> __.__(new int[]{1}).none(null).hasNext());
+ assertEquals("Input predicate to none step can't be null.", thrown.getMessage());
+ }
+
+ @Test
+ public void testSetTraverser() {
+ final Set<Integer> numbers = new HashSet<>();
+ numbers.add(5);
+ numbers.add(6);
+
+ assertTrue(__.__(numbers).none(P.gt(7)).hasNext());
+ }
+
+ @Test
+ public void testListIteratorTraverser() {
+ final List<Integer> numbers = new ArrayList<>();
+ numbers.add(10);
+ numbers.add(11);
+
+ assertTrue(__.__(numbers.iterator()).none(P.lt(10)).hasNext());
+ }
+
+ @Test
+ public void testCornerCases() {
+ final List validOne = new ArrayList() {{ add(20); }};
+ final List validTwo = new ArrayList() {{ add(21); add(25);}};
+ final List validThree = new ArrayList() {{ add(51); add(57); add(71); }};
+ final List containsNull = new ArrayList() {{ add(50); add(null); add(60); }};
+ final List empty = new ArrayList();
+ final List incorrectType = new ArrayList() {{ add(100); add("25"); }};
+ final List valueTooSmall = new ArrayList() {{ add(101); add(1); add(10);}};
+
+ assertEquals(4L, __.__(validOne, null, containsNull, empty, incorrectType, valueTooSmall, validTwo, validThree)
+ .none(P.lte(3)).count().next().longValue());
+ }
+}
\ No newline at end of file
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
index 162a89c0fe..40e742b64d 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
@@ -1519,6 +1519,15 @@ 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 (P? predicate)
+ {
+ Bytecode.AddStep("none", predicate);
+ return Wrap<TStart, TEnd>(this);
+ }
+
/// <summary>
/// Adds the not step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
index 6e5644da70..14b63979f3 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
@@ -117,7 +117,7 @@ namespace Gremlin.Net.Process.Traversal
}
/// <summary>
- /// Spawns a <see cref="GraphTraversal{SType, EType}" /> all adds the all step to that traversal.
+ /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the all step to that traversal.
/// </summary>
public static GraphTraversal<object, object> All(P? predicate)
{
@@ -135,13 +135,21 @@ namespace Gremlin.Net.Process.Traversal
}
/// <summary>
- /// Spawns a <see cref="GraphTraversal{SType, EType}" /> any adds the any step to that traversal.
+ /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the any step to that traversal.
/// </summary>
public static GraphTraversal<object, object> Any(P? predicate)
{
return new GraphTraversal<object, object>().Any(predicate);
}
+ /// <summary>
+ /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the none step to that traversal.
+ /// </summary>
+ public static GraphTraversal<object, object> None(P? predicate)
+ {
+ return new GraphTraversal<object, object>().None(predicate);
+ }
+
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the as step to that traversal.
/// </summary>
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
index 81bb7242df..1549d3ae0d 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
@@ -324,6 +324,19 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
{"g_V_valuesXageX_isXgte_29X_isXlt_34X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Values<object>("age").Is(P.Gte(29)).Is(P.Lt(34))}},
{"g_V_whereXinXcreatedX_count_isX1XX_valuesXnameX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Where(__.In("created").Count().Is(1)).Values<object>("name")}},
{"g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Where(__.In("created").Count().Is(P.Gte(2))).Values<object>("name")}},
+ {"g_V_valuesXageX_noneXgtX32XX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Values<object>("age").None(P.Gt(32))}},
+ {"g_V_valuesXageX_whereXisXP_gtX33XXX_fold_noneXlteX33XX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Values<object>("age").Where(__.Is(P.Gt(33))).Fold().None(P.Lte(33))}},
+ {"g_V_valuesXageX_order_byXdescX_fold_noneXltX10XX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Values<object>("age").Order().By(Order.Desc).Fold().None(P.Lt(10))}},
+ {"g_V_valuesXageX_order_byXdescX_fold_noneXgtX30XX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Values<object>("age").Order().By(Order.Desc).Fold().None(P.Gt(30))}},
+ {"g_injectXabc_bcdX_noneXeqXbcdXX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>(new List<object> { "abc", "bcd" }).None(P.Eq("bcd"))}},
+ {"g_injectXbcd_bcdX_noneXeqXabcXX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>(p["xx1"]).None(P.Eq("abc"))}},
+ {"g_injectXnull_bcdX_noneXP_eqXabcXX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>(p["xx1"]).None(P.Eq("abc"))}},
+ {"g_injectX5_8_10_10_7X_noneXltX7XX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>(p["xx1"], p["xx2"]).None(P.Lt(7))}},
+ {"g_injectXnullX_noneXeqXnullXX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>(null).None(P.Eq(null))}},
+ {"g_injectX7X_noneXeqX7XX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>(7).None(P.Eq(7))}},
+ {"g_injectXnull_1_emptyX_noneXeqXnullXX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>(p["xx1"], p["xx2"]).None(P.Eq(null))}},
+ {"g_injectXnull_nullX_noneXnotXnullXX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>(p["xx1"]).None(P.Neq(null))}},
+ {"g_injectX3_threeX_noneXeqX3XX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>(p["xx1"]).None(P.Eq(3))}},
{"g_V_orXhasXage_gt_27X__outE_count_gte_2X_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Or(__.Has("age", P.Gt(27)), __.OutE().Count().Is(P.Gte(2))).Values<object>("name")}},
{"g_V_orXoutEXknowsX__hasXlabel_softwareX_or_hasXage_gte_35XX_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Or(__.OutE("knows"), __.Has(T.Label, "software").Or().Has("age", P.Gte(35))).Values<object>("name")}},
{"g_V_asXaX_orXselectXaX_selectXaXX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().As("a").Or(__.Select<object>("a"), __.Select<object>("a"))}},
diff --git a/gremlin-go/driver/anonymousTraversal.go b/gremlin-go/driver/anonymousTraversal.go
index ac6c9a5348..a72e89b679 100644
--- a/gremlin-go/driver/anonymousTraversal.go
+++ b/gremlin-go/driver/anonymousTraversal.go
@@ -207,6 +207,8 @@ type AnonymousTraversal interface {
MergeV(args ...interface{}) *GraphTraversal
// Min adds the min step to the GraphTraversal.
Min(args ...interface{}) *GraphTraversal
+ // None adds the not 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.
@@ -731,6 +733,11 @@ 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 b09f540c46..79fecd7d60 100644
--- a/gremlin-go/driver/cucumber/gremlin.go
+++ b/gremlin-go/driver/cucumber/gremlin.go
@@ -294,6 +294,19 @@ var translationMap = map[string][]func(g *gremlingo.GraphTraversalSource, p map[
"g_V_valuesXageX_isXgte_29X_isXlt_34X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Values("age").Is(gremlingo.P.Gte(29)).Is(gremlingo.P.Lt(34))}},
"g_V_whereXinXcreatedX_count_isX1XX_valuesXnameX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Where(gremlingo.T__.In("created").Count().Is(1)).Values("name")}},
"g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Where(gremlingo.T__.In("created").Count().Is(gremlingo.P.Gte(2))).Values("name")}},
+ "g_V_valuesXageX_noneXgtX32XX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Values("age").None(gremlingo.P.Gt(32))}},
+ "g_V_valuesXageX_whereXisXP_gtX33XXX_fold_noneXlteX33XX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Values("age").Where(gremlingo.T__.Is(gremlingo.P.Gt(33))).Fold().None(gremlingo.P.Lte(33))}},
+ "g_V_valuesXageX_order_byXdescX_fold_noneXltX10XX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Values("age").Order().By(gremlingo.Order.Desc).Fold().None(gremlingo.P.Lt(10))}},
+ "g_V_valuesXageX_order_byXdescX_fold_noneXgtX30XX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Values("age").Order().By(gremlingo.Order.Desc).Fold().None(gremlingo.P.Gt(30))}},
+ "g_injectXabc_bcdX_noneXeqXbcdXX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject([]interface{}{"abc", "bcd"}).None(gremlingo.P.Eq("bcd"))}},
+ "g_injectXbcd_bcdX_noneXeqXabcXX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(p["xx1"]).None(gremlingo.P.Eq("abc"))}},
+ "g_injectXnull_bcdX_noneXP_eqXabcXX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(p["xx1"]).None(gremlingo.P.Eq("abc"))}},
+ "g_injectX5_8_10_10_7X_noneXltX7XX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(p["xx1"], p["xx2"]).None(gremlingo.P.Lt(7))}},
+ "g_injectXnullX_noneXeqXnullXX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(nil).None(gremlingo.P.Eq(nil))}},
+ "g_injectX7X_noneXeqX7XX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(7).None(gremlingo.P.Eq(7))}},
+ "g_injectXnull_1_emptyX_noneXeqXnullXX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(p["xx1"], p["xx2"]).None(gremlingo.P.Eq(nil))}},
+ "g_injectXnull_nullX_noneXnotXnullXX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(p["xx1"]).None(gremlingo.P.Neq(nil))}},
+ "g_injectX3_threeX_noneXeqX3XX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(p["xx1"]).None(gremlingo.P.Eq(3))}},
"g_V_orXhasXage_gt_27X__outE_count_gte_2X_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Or(gremlingo.T__.Has("age", gremlingo.P.Gt(27)), gremlingo.T__.OutE().Count().Is(gremlingo.P.Gte(2))).Values("name")}},
"g_V_orXoutEXknowsX__hasXlabel_softwareX_or_hasXage_gte_35XX_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Or(gremlingo.T__.OutE("knows"), gremlingo.T__.Has(gremlingo.T.Label, "software").Or().Has("age", gremlingo.P.Gte(35))).Values("name")}},
"g_V_asXaX_orXselectXaX_selectXaXX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().As("a").Or(gremlingo.T__.Select("a"), gremlingo.T__.Select("a"))}},
diff --git a/gremlin-go/driver/graphTraversal.go b/gremlin-go/driver/graphTraversal.go
index 6573db7485..6d8463a438 100644
--- a/gremlin-go/driver/graphTraversal.go
+++ b/gremlin-go/driver/graphTraversal.go
@@ -530,6 +530,12 @@ 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-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 b2aa34afba..40bd087343 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
@@ -1131,6 +1131,16 @@ 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
@@ -1812,6 +1822,7 @@ const statics = {
mergeE: (...args) => callOnEmptyTraversal('mergeE', args),
mergeV: (...args) => callOnEmptyTraversal('mergeV', args),
min: (...args) => callOnEmptyTraversal('min', args),
+ none: (...args) => callOnEmptyTraversal('none', args),
not: (...args) => callOnEmptyTraversal('not', args),
optional: (...args) => callOnEmptyTraversal('optional', args),
or: (...args) => callOnEmptyTraversal('or', args),
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
index 03840c482b..5c23d7a430 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
@@ -324,6 +324,19 @@ const gremlins = {
g_V_valuesXageX_isXgte_29X_isXlt_34X: [function({g}) { return g.V().values("age").is(P.gte(29)).is(P.lt(34)) }],
g_V_whereXinXcreatedX_count_isX1XX_valuesXnameX: [function({g}) { return g.V().where(__.in_("created").count().is(1)).values("name") }],
g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX: [function({g}) { return g.V().where(__.in_("created").count().is(P.gte(2))).values("name") }],
+ g_V_valuesXageX_noneXgtX32XX: [function({g}) { return g.V().values("age").none(P.gt(32)) }],
+ g_V_valuesXageX_whereXisXP_gtX33XXX_fold_noneXlteX33XX: [function({g}) { return g.V().values("age").where(__.is(P.gt(33))).fold().none(P.lte(33)) }],
+ g_V_valuesXageX_order_byXdescX_fold_noneXltX10XX: [function({g}) { return g.V().values("age").order().by(Order.desc).fold().none(P.lt(10)) }],
+ g_V_valuesXageX_order_byXdescX_fold_noneXgtX30XX: [function({g}) { return g.V().values("age").order().by(Order.desc).fold().none(P.gt(30)) }],
+ g_injectXabc_bcdX_noneXeqXbcdXX: [function({g}) { return g.inject(["abc", "bcd"]).none(P.eq("bcd")) }],
+ g_injectXbcd_bcdX_noneXeqXabcXX: [function({g, xx1}) { return g.inject(xx1).none(P.eq("abc")) }],
+ g_injectXnull_bcdX_noneXP_eqXabcXX: [function({g, xx1}) { return g.inject(xx1).none(P.eq("abc")) }],
+ g_injectX5_8_10_10_7X_noneXltX7XX: [function({g, xx1, xx2}) { return g.inject(xx1, xx2).none(P.lt(7)) }],
+ g_injectXnullX_noneXeqXnullXX: [function({g}) { return g.inject(null).none(P.eq(null)) }],
+ g_injectX7X_noneXeqX7XX: [function({g}) { return g.inject(7).none(P.eq(7)) }],
+ g_injectXnull_1_emptyX_noneXeqXnullXX: [function({g, xx1, xx2}) { return g.inject(xx1, xx2).none(P.eq(null)) }],
+ g_injectXnull_nullX_noneXnotXnullXX: [function({g, xx1}) { return g.inject(xx1).none(P.neq(null)) }],
+ g_injectX3_threeX_noneXeqX3XX: [function({g, xx1}) { return g.inject(xx1).none(P.eq(3)) }],
g_V_orXhasXage_gt_27X__outE_count_gte_2X_name: [function({g}) { return g.V().or(__.has("age", P.gt(27)), __.outE().count().is(P.gte(2))).values("name") }],
g_V_orXoutEXknowsX__hasXlabel_softwareX_or_hasXage_gte_35XX_name: [function({g}) { return g.V().or(__.outE("knows"), __.has(T.label, "software").or().has("age", P.gte(35))).values("name") }],
g_V_asXaX_orXselectXaX_selectXaXX: [function({g}) { return g.V().as("a").or(__.select("a"), __.select("a")) }],
diff --git a/gremlin-language/src/main/antlr4/Gremlin.g4 b/gremlin-language/src/main/antlr4/Gremlin.g4
index 9fbcae894e..07c5059b97 100644
--- a/gremlin-language/src/main/antlr4/Gremlin.g4
+++ b/gremlin-language/src/main/antlr4/Gremlin.g4
@@ -239,6 +239,7 @@ traversalMethod
| traversalMethod_max
| traversalMethod_mean
| traversalMethod_min
+ | traversalMethod_none
| traversalMethod_not
| traversalMethod_option
| traversalMethod_optional
@@ -687,6 +688,10 @@ traversalMethod_min
| K_MIN LPAREN traversalScope RPAREN #traversalMethod_min_Scope
;
+traversalMethod_none
+ : K_NONE LPAREN traversalPredicate RPAREN #traversalMethod_none_P
+ ;
+
traversalMethod_not
: K_NOT LPAREN nestedTraversal 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 df7c3d4e65..f21248b445 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
@@ -707,6 +707,10 @@ 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
@@ -1487,6 +1491,10 @@ class __(object, metaclass=MagicType):
def min_(cls, *args):
return cls.graph_traversal(None, None, Bytecode()).min_(*args)
+ @classmethod
+ def none(cls, *args):
+ return cls.graph_traversal(None, None, Bytecode()).none(*args)
+
@classmethod
def not_(cls, *args):
return cls.graph_traversal(None, None, Bytecode()).not_(*args)
@@ -2181,6 +2189,10 @@ def min_(*args):
return __.min_(*args)
+def none(*args):
+ return __.none(*args)
+
+
def not_(*args):
return __.not_(*args)
@@ -2575,6 +2587,8 @@ statics.add_static('merge_v', merge_v)
statics.add_static('min_', min_)
+statics.add_static('none', none)
+
statics.add_static('not_', not_)
statics.add_static('optional', optional)
diff --git a/gremlin-python/src/main/python/radish/gremlin.py b/gremlin-python/src/main/python/radish/gremlin.py
index 1351a0a4a1..64d5257aa9 100644
--- a/gremlin-python/src/main/python/radish/gremlin.py
+++ b/gremlin-python/src/main/python/radish/gremlin.py
@@ -297,6 +297,19 @@ world.gremlins = {
'g_V_valuesXageX_isXgte_29X_isXlt_34X': [(lambda g:g.V().values('age').is_(P.gte(29)).is_(P.lt(34)))],
'g_V_whereXinXcreatedX_count_isX1XX_valuesXnameX': [(lambda g:g.V().where(__.in_('created').count().is_(1)).values('name'))],
'g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX': [(lambda g:g.V().where(__.in_('created').count().is_(P.gte(2))).values('name'))],
+ 'g_V_valuesXageX_noneXgtX32XX': [(lambda g:g.V().values('age').none(P.gt(32)))],
+ 'g_V_valuesXageX_whereXisXP_gtX33XXX_fold_noneXlteX33XX': [(lambda g:g.V().values('age').where(__.is_(P.gt(33))).fold().none(P.lte(33)))],
+ 'g_V_valuesXageX_order_byXdescX_fold_noneXltX10XX': [(lambda g:g.V().values('age').order().by(Order.desc).fold().none(P.lt(10)))],
+ 'g_V_valuesXageX_order_byXdescX_fold_noneXgtX30XX': [(lambda g:g.V().values('age').order().by(Order.desc).fold().none(P.gt(30)))],
+ 'g_injectXabc_bcdX_noneXeqXbcdXX': [(lambda g:g.inject(['abc', 'bcd']).none(P.eq('bcd')))],
+ 'g_injectXbcd_bcdX_noneXeqXabcXX': [(lambda g, xx1=None:g.inject(xx1).none(P.eq('abc')))],
+ 'g_injectXnull_bcdX_noneXP_eqXabcXX': [(lambda g, xx1=None:g.inject(xx1).none(P.eq('abc')))],
+ 'g_injectX5_8_10_10_7X_noneXltX7XX': [(lambda g, xx1=None,xx2=None:g.inject(xx1, xx2).none(P.lt(7)))],
+ 'g_injectXnullX_noneXeqXnullXX': [(lambda g:g.inject(None).none(P.eq(None)))],
+ 'g_injectX7X_noneXeqX7XX': [(lambda g:g.inject(7).none(P.eq(7)))],
+ 'g_injectXnull_1_emptyX_noneXeqXnullXX': [(lambda g, xx1=None,xx2=None:g.inject(xx1, xx2).none(P.eq(None)))],
+ 'g_injectXnull_nullX_noneXnotXnullXX': [(lambda g, xx1=None:g.inject(xx1).none(P.neq(None)))],
+ 'g_injectX3_threeX_noneXeqX3XX': [(lambda g, xx1=None:g.inject(xx1).none(P.eq(3)))],
'g_V_orXhasXage_gt_27X__outE_count_gte_2X_name': [(lambda g:g.V().or_(__.has('age', P.gt(27)), __.out_e().count().is_(P.gte(2))).values('name'))],
'g_V_orXoutEXknowsX__hasXlabel_softwareX_or_hasXage_gte_35XX_name': [(lambda g:g.V().or_(__.out_e('knows'), __.has(T.label, 'software').or_().has('age', P.gte(35))).values('name'))],
'g_V_asXaX_orXselectXaX_selectXaXX': [(lambda g:g.V().as_('a').or_(__.select('a'), __.select('a')))],
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/None.feature b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/None.feature
new file mode 100644
index 0000000000..b16ec5fc68
--- /dev/null
+++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/None.feature
@@ -0,0 +1,168 @@
+# 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.
+
+@StepClassFilter @StepNone
+Feature: Step - none()
+
+ Scenario: g_V_valuesXageX_noneXgtX32XX
+ Given the modern graph
+ And the traversal of
+ """
+ g.V().values("age").none(P.gt(32))
+ """
+ When iterated to list
+ Then the result should be empty
+
+ Scenario: g_V_valuesXageX_whereXisXP_gtX33XXX_fold_noneXlteX33XX
+ Given the modern graph
+ And the traversal of
+ """
+ g.V().values("age").where(__.is(P.gt(33))).fold().none(P.lte(33))
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | l[d[35].i] |
+
+ Scenario: g_V_valuesXageX_order_byXdescX_fold_noneXltX10XX
+ Given the modern graph
+ And the traversal of
+ """
+ g.V().values("age").order().by(desc).fold().none(P.lt(10))
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | l[d[35].i,d[32].i,d[29].i,d[27].i] |
+
+ Scenario: g_V_valuesXageX_order_byXdescX_fold_noneXgtX30XX
+ Given the modern graph
+ And the traversal of
+ """
+ g.V().values("age").order().by(desc).fold().none(P.gt(30))
+ """
+ When iterated to list
+ Then the result should be empty
+
+ @GraphComputerVerificationInjectionNotSupported
+ Scenario: g_injectXabc_bcdX_noneXeqXbcdXX
+ Given the empty graph
+ And the traversal of
+ """
+ g.inject(["abc","bcd"]).none(P.eq("bcd"))
+ """
+ When iterated to list
+ Then the result should be empty
+
+ @GraphComputerVerificationInjectionNotSupported
+ Scenario: g_injectXbcd_bcdX_noneXeqXabcXX
+ Given the empty graph
+ And using the parameter xx1 defined as "l[bcd,bcd]"
+ And the traversal of
+ """
+ g.inject(xx1).none(P.eq("abc"))
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | l[bcd,bcd] |
+
+ @GraphComputerVerificationInjectionNotSupported
+ Scenario: g_injectXnull_bcdX_noneXP_eqXabcXX
+ Given the empty graph
+ And using the parameter xx1 defined as "l[null,bcd]"
+ And the traversal of
+ """
+ g.inject(xx1).none(P.eq("abc"))
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | l[null,bcd] |
+
+ @GraphComputerVerificationInjectionNotSupported
+ Scenario: g_injectX5_8_10_10_7X_noneXltX7XX
+ Given the empty graph
+ And using the parameter xx1 defined as "l[d[5].i,d[8].i,d[10].i]"
+ And using the parameter xx2 defined as "l[d[10].i,d[7].i]"
+ And the traversal of
+ """
+ g.inject(xx1,xx2).none(P.lt(7))
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | l[d[10].i,d[7].i] |
+
+ @GraphComputerVerificationInjectionNotSupported
+ Scenario: g_injectXnullX_noneXeqXnullXX
+ Given the empty graph
+ And the traversal of
+ """
+ g.inject(null).none(P.eq(null))
+ """
+ When iterated to list
+ Then the result should be empty
+
+ @GraphComputerVerificationInjectionNotSupported
+ Scenario: g_injectX7X_noneXeqX7XX
+ Given the empty graph
+ And the traversal of
+ """
+ g.inject(7).none(P.eq(7))
+ """
+ When iterated to list
+ Then the result should be empty
+
+
+ @GraphComputerVerificationInjectionNotSupported
+ Scenario: g_injectXnull_1_emptyX_noneXeqXnullXX
+ Given the empty graph
+ And using the parameter xx1 defined as "l[null,1]"
+ And using the parameter xx2 defined as "l[]"
+ And the traversal of
+ """
+ g.inject(xx1,xx2).none(P.eq(null))
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | l[] |
+
+ @GraphComputerVerificationInjectionNotSupported
+ Scenario: g_injectXnull_nullX_noneXnotXnullXX
+ Given the empty graph
+ And using the parameter xx1 defined as "l[null,null]"
+ And the traversal of
+ """
+ g.inject(xx1).none(P.neq(null))
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | l[null,null] |
+
+ @GraphComputerVerificationInjectionNotSupported
+ Scenario: g_injectX3_threeX_noneXeqX3XX
+ Given the empty graph
+ And using the parameter xx1 defined as "l[d[3].i,three]"
+ And the traversal of
+ """
+ g.inject(xx1).none(P.eq(3))
+ """
+ When iterated to list
+ Then the result should be empty
\ No newline at end of file
(tinkerpop) 01/03: Backported 62a3935152354eea54f2cfadc39edf10ebe2005d from 4.x
Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
spmallette pushed a commit to branch backport-discard
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 6b29a6659e09ac337b363b514ef4ec98789f4387
Author: Stephen Mallette <st...@amazon.com>
AuthorDate: Sat Aug 2 11:11:42 2025 -0400
Backported 62a3935152354eea54f2cfadc39edf10ebe2005d from 4.x
Renames none() to discard()
---
CHANGELOG.asciidoc | 1 +
docs/src/reference/the-traversal.asciidoc | 43 +++++++++++++---------
docs/src/upgrade/release-3.8.x.asciidoc | 13 +++++++
.../grammar/DefaultGremlinBaseVisitor.java | 2 +-
.../language/grammar/TraversalMethodVisitor.java | 4 +-
.../gremlin/process/traversal/Traversal.java | 14 +++----
.../traversal/dsl/graph/GraphTraversal.java | 8 ++--
.../gremlin/process/traversal/dsl/graph/__.java | 6 +--
.../filter/{NoneStep.java => DiscardStep.java} | 4 +-
.../strategy/optimization/EarlyLimitStrategy.java | 22 +++++------
.../strategy/optimization/LazyBarrierStrategy.java | 4 +-
.../optimization/PathRetractionStrategy.java | 8 +---
.../verification/StandardVerificationStrategy.java | 9 ++---
.../process/traversal/util/BytecodeHelper.java | 4 +-
.../grammar/TraversalMethodVisitorTest.java | 8 ++--
.../language/grammar/TraversalRootVisitorTest.java | 4 +-
.../traversal/dsl/graph/GraphTraversalTest.java | 2 +-
.../optimization/EarlyLimitStrategyTest.java | 16 ++++----
.../StandardVerificationStrategyTest.java | 2 +-
.../traversal/translator/PythonTranslatorTest.java | 6 +--
.../Process/Traversal/DefaultTraversal.cs | 2 +-
.../Process/Traversal/GraphTraversal.cs | 18 ++++-----
.../src/Gremlin.Net/Process/Traversal/__.cs | 16 ++++----
.../Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs | 12 +++---
gremlin-go/driver/anonymousTraversal.go | 14 +++----
gremlin-go/driver/cucumber/gremlin.go | 12 +++---
gremlin-go/driver/graphTraversal.go | 12 +++---
gremlin-go/driver/traversal.go | 2 +-
.../lib/process/graph-traversal.js | 22 +++++------
.../gremlin-javascript/lib/process/traversal.js | 2 +-
.../gremlin-javascript/test/cucumber/gremlin.js | 12 +++---
gremlin-language/src/main/antlr4/Gremlin.g4 | 12 +++---
.../gremlin_python/process/graph_traversal.py | 28 +++++++-------
.../python/gremlin_python/process/traversal.py | 2 +-
gremlin-python/src/main/python/radish/gremlin.py | 12 +++---
.../process/traversal/CoreTraversalTest.java | 6 +--
.../filter/{None.feature => Discard.feature} | 28 +++++++-------
37 files changed, 204 insertions(+), 188 deletions(-)
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 355bf27d67..d59b9f0969 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
This release also includes changes from <<release-3-7-XXX, 3.7.XXX>>.
* Removed Vertex/ReferenceVertex from grammar. Use vertex id in traversals now instead.
+* Renamed the traversal discarding `none()` step to `discard()`.
* Modified mathematical operators to prevent overflows in steps such as `sum()` and 'sack()' to prefer promotion to the next highest number type.
* Added `DateTime` ontop of the existing 'datetime' grammar.
* Added `UUID()` and `UUID(value)` to grammar.
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index bbc2f106f3..edd28510cb 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -1508,6 +1508,32 @@ g.V().values("name").fold().difference(__.V().limit(2).values("name").fold())
link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.html#difference(java.lang.Object)++[`difference(Object)`]
link:++https://tinkerpop.apache.org/docs/x.y.z/dev/provider/#difference-step++[`Semantics`]
+[[discard-step]]
+=== Discard Step
+
+The `discard()`-step (*filter*) filters all objects from a traversal stream. It is helpful with <<branch-step>> types
+of steps where a particular branch of code should "throw away" traversers. In the following example, traversers that
+don't match are filtered out of the traversal stream.
+
+[gremlin-groovy,modern]
+----
+g.V().choose(T.label).
+ option("person", __.out("knows").values("name")).
+ option("bleep", __.out("created").values("name")).
+ option(none, discard())
+----
+
+It is also useful for traversals that are executed remotely where returning results is not useful and the traversal is
+only meant to generate side-effects. Choosing not to return results saves in serialization and network costs as the
+objects are filtered on the remote end and not returned to the client side. Typically, this step does not need to be
+used directly and is quietly used by the `iterate()` terminal step which appends `discard()` to the traversal before
+actually cycling through results.
+
+*Additional References*
+
+link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/Traversal.html#discard()++[`discard()`]
+link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/Traversal.html#iterate()++[`iterate()`]
+
[[disjunct-step]]
=== Disjunct Step
@@ -3229,23 +3255,6 @@ link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gre
link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.html#min(org.apache.tinkerpop.gremlin.process.traversal.Scope)++[`min(Scope)`],
link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/Scope.html++[`Scope`]
-[[none-step]]
-=== None Step
-
-The `none()`-step (*filter*) filters all objects from a traversal stream. It is especially useful for traversals
-that are executed remotely where returning results is not useful and the traversal is only meant to generate
-side-effects. Choosing not to return results saves in serialization and network costs as the objects are filtered on
-the remote end and not returned to the client side. Typically, this step does not need to be used directly and is
-quietly used by the `iterate()` terminal step which appends `none()` to the traversal before actually cycling through
-results.
-
-NOTE: As of release 4.0.0, `none()` will be renamed to `discard()`.
-
-*Additional References*
-
-link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/Traversal.html#none()++[`none()`]
-link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/Traversal.html#iterate()++[`iterate()`]
-
[[not-step]]
=== Not Step
diff --git a/docs/src/upgrade/release-3.8.x.asciidoc b/docs/src/upgrade/release-3.8.x.asciidoc
index 85c8b495d4..0363f70bb7 100644
--- a/docs/src/upgrade/release-3.8.x.asciidoc
+++ b/docs/src/upgrade/release-3.8.x.asciidoc
@@ -58,6 +58,13 @@ gremlin> g.V().sack(assign).by(__.hasLabel('person').count().asBool()).sack(and)
See: link:https://tinkerpop.apache.org/docs/3.8.0/reference/#asBool-step[asBool()-step]
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3175[TINKERPOP-3175]
+==== none() and discard()
+
+There is a complicated relationship with the `none()` and `discard()` steps that begs some discussion. Prior to this
+version, the `none()` step was used to "throw away" all traversers that passed into it. In 3.8.0, that step has been
+renamed to `discard()`. The `discard()` step with its verb tone arguably makes for a better name for that feature, but
+it also helped make room for `none()` to be repurposed as `none(P)` which is a complement to `any(P)` and `all(P) steps.
+
==== Set minimum Java version to 11
TinkerPop 3.8 requires a minimum of Java 11 for building and running. Support for Java 1.8 has been dropped.
@@ -438,6 +445,12 @@ link:https://issues.apache.org/jira/browse/TINKERPOP-2974[TINKERPOP-2974]
==== Graph System Providers
+===== NoneStep Renaming
+
+The `DiscardStep` is now renamed to `DiscardStep`. Providers who developed strategies or other optimizations around
+`DiscardStep` should switch to `DiscardStep`. Note that `DiscardStep` has been repurposed as `none(P)` for filtering
+collections as a complement to `any(P)` and `all(P)`.
+
==== Set minimum Java version to 11
TinkerPop 3.8 requires a minimum of Java 11 for building and running. Support for Java 1.8 has been dropped.
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/DefaultGremlinBaseVisitor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/DefaultGremlinBaseVisitor.java
index 4b64161115..6a7382c144 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/DefaultGremlinBaseVisitor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/DefaultGremlinBaseVisitor.java
@@ -614,7 +614,7 @@ public class DefaultGremlinBaseVisitor<T> extends AbstractParseTreeVisitor<T> im
/**
* {@inheritDoc}
*/
- @Override public T visitTraversalMethod_none(final GremlinParser.TraversalMethod_noneContext ctx) { notImplemented(ctx); return null; }
+ @Override public T visitTraversalMethod_discard(final GremlinParser.TraversalMethod_discardContext ctx) { notImplemented(ctx); return null; }
/**
* {@inheritDoc}
*/
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java
index 6b1578fb1e..9ff820393b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java
@@ -1111,8 +1111,8 @@ public class TraversalMethodVisitor extends TraversalRootVisitor<GraphTraversal>
* {@inheritDoc}
*/
@Override
- public GraphTraversal visitTraversalMethod_none(final GremlinParser.TraversalMethod_noneContext ctx) {
- return this.graphTraversal.none();
+ public GraphTraversal visitTraversalMethod_discard(final GremlinParser.TraversalMethod_discardContext ctx) {
+ return this.graphTraversal.discard();
}
/**
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
index 494ba58f60..d2b3cb2966 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
@@ -23,7 +23,7 @@ import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
import org.apache.tinkerpop.gremlin.process.remote.traversal.step.map.RemoteStep;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ProfileSideEffectStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectCapStep;
@@ -75,7 +75,7 @@ public interface Traversal<S, E> extends Iterator<E>, Serializable, Cloneable, A
}
public static final String profile = "profile";
- public static final String none = "none";
+ public static final String discard = "discard";
}
/**
@@ -201,7 +201,7 @@ public interface Traversal<S, E> extends Iterator<E>, Serializable, Cloneable, A
public default <A, B> Traversal<A, B> iterate() {
try {
if (!this.asAdmin().isLocked()) {
- this.none();
+ this.discard();
this.asAdmin().applyStrategies();
}
// use the end step so the results are bulked
@@ -221,11 +221,11 @@ public interface Traversal<S, E> extends Iterator<E>, Serializable, Cloneable, A
* signal to remote servers that {@link #iterate()} was called. While it may be directly used, it is often a sign
* that a traversal should be re-written in another form.
*
- * @return the updated traversal with respective {@link NoneStep}.
+ * @return the updated traversal with respective {@link DiscardStep}.
*/
- public default Traversal<S, E> none() {
- this.asAdmin().getBytecode().addStep(Symbols.none);
- return this.asAdmin().addStep(new NoneStep<>(this.asAdmin()));
+ public default Traversal<S, E> discard() {
+ this.asAdmin().getBytecode().addStep(Symbols.discard);
+ return this.asAdmin().addStep(new DiscardStep<>(this.asAdmin()));
}
/**
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index 8470cb289a..b91e8f5950 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
@@ -67,7 +67,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DropStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.IsStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.LambdaFilterStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NotStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.PathFilterStep;
@@ -2047,11 +2047,11 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
* signal to remote servers that {@link #iterate()} was called. While it may be directly used, it is often a sign
* that a traversal should be re-written in another form.
*
- * @return the updated traversal with respective {@link NoneStep}.
+ * @return the updated traversal with respective {@link DiscardStep}.
*/
@Override
- default GraphTraversal<S, E> none() {
- return (GraphTraversal<S, E>) Traversal.super.none();
+ default GraphTraversal<S, E> discard() {
+ return (GraphTraversal<S, E>) Traversal.super.discard();
}
/**
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/__.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/__.java
index 22bb3b1be0..068a200e9d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/__.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/__.java
@@ -1078,10 +1078,10 @@ public class __ {
}
/**
- * @see GraphTraversal#none()
+ * @see GraphTraversal#discard()
*/
- public static <A> GraphTraversal<A, A> none() {
- return __.<A>start().none();
+ public static <A> GraphTraversal<A, A> discard() {
+ return __.<A>start().discard();
}
/**
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/NoneStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/DiscardStep.java
similarity index 92%
rename from gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/NoneStep.java
rename to gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/DiscardStep.java
index 1d43444bd5..45baf81fd7 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/NoneStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/DiscardStep.java
@@ -26,9 +26,9 @@ import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
-public final class NoneStep<S> extends FilterStep<S> {
+public final class DiscardStep<S> extends FilterStep<S> {
- public NoneStep(final Traversal.Admin traversal) {
+ public DiscardStep(final Traversal.Admin traversal) {
super(traversal);
}
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/EarlyLimitStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/EarlyLimitStrategy.java
index cffff8c9ad..b56d65a79c 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/EarlyLimitStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/EarlyLimitStrategy.java
@@ -23,7 +23,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Step;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.step.SideEffectCapable;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeGlobalStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.MapStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ProfileSideEffectStep;
@@ -39,15 +39,15 @@ import java.util.List;
* This strategy looks for {@link RangeGlobalStep}s that can be moved further left in the traversal and thus be applied
* earlier. It will also try to merge multiple {@link RangeGlobalStep}s into one.
* If the logical consequence of one or multiple {@link RangeGlobalStep}s is an empty result, the strategy will remove
- * as many steps as possible and add a {@link NoneStep} instead.
+ * as many steps as possible and add a {@link DiscardStep} instead.
*
* @author Daniel Kuppitz (http://gremlin.guru)
* @example <pre>
* __.out().valueMap().limit(5) // becomes __.out().limit(5).valueMap()
* __.outE().range(2, 10).valueMap().limit(5) // becomes __.outE().range(2, 7).valueMap()
* __.outE().limit(5).valueMap().range(2, -1) // becomes __.outE().range(2, 5).valueMap()
- * __.outE().limit(5).valueMap().range(5, 10) // becomes __.outE().none()
- * __.outE().limit(5).valueMap().range(5, 10).cap("a") // becomes __.outE().none().cap("a")
+ * __.outE().limit(5).valueMap().range(5, 10) // becomes __.outE().discard()
+ * __.outE().limit(5).valueMap().range(5, 10).cap("a") // becomes __.outE().discard().cap("a")
* </pre>
*/
public final class EarlyLimitStrategy
@@ -74,10 +74,10 @@ public final class EarlyLimitStrategy
// previous RangeStep; keep the RangeStep's labels at its preceding step
TraversalHelper.copyLabels(step, step.getPreviousStep(), true);
insertAfter = moveRangeStep((RangeGlobalStep) step, insertAfter, traversal, merge);
- if (insertAfter instanceof NoneStep) {
- // any step besides a SideEffectCapStep after a NoneStep would be pointless
- final int noneStepIndex = TraversalHelper.stepIndex(insertAfter, traversal);
- for (i = j - 2; i > noneStepIndex; i--) {
+ if (insertAfter instanceof DiscardStep) {
+ // any step besides a SideEffectCapStep after a DiscardStep would be pointless
+ final int discardStepIndex = TraversalHelper.stepIndex(insertAfter, traversal);
+ for (i = j - 2; i > discardStepIndex; i--) {
if (!(steps.get(i) instanceof SideEffectCapStep) && !(steps.get(i) instanceof ProfileSideEffectStep)) {
traversal.removeStep(i);
}
@@ -110,7 +110,7 @@ public final class EarlyLimitStrategy
if (insertAfter instanceof RangeGlobalStep) {
// there's a previous RangeStep which might affect the effective range of the current RangeStep
// recompute this step's low and high; if the result is still a valid range, create a new RangeStep,
- // otherwise a NoneStep
+ // otherwise a DiscardStep
final RangeGlobalStep other = (RangeGlobalStep) insertAfter;
final long low = other.getLowRange() + step.getLowRange();
if (other.getHighRange() == -1L) {
@@ -120,11 +120,11 @@ public final class EarlyLimitStrategy
if (low < high) {
rangeStep = new RangeGlobalStep(traversal, low, high);
} else {
- rangeStep = new NoneStep<>(traversal);
+ rangeStep = new DiscardStep<>(traversal);
}
} else {
final long high = Math.min(other.getLowRange() + step.getHighRange(), other.getHighRange());
- rangeStep = high > low ? new RangeGlobalStep(traversal, low, high) : new NoneStep<>(traversal);
+ rangeStep = high > low ? new RangeGlobalStep(traversal, low, high) : new DiscardStep<>(traversal);
}
remove = merge;
TraversalHelper.replaceStep(merge ? insertAfter : step, rangeStep, traversal);
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
index adb7b40460..aa46b59a4e 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
@@ -25,7 +25,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier;
import org.apache.tinkerpop.gremlin.process.traversal.step.PathProcessor;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DropStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.ElementStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
@@ -120,7 +120,7 @@ public final class LazyBarrierStrategy extends AbstractTraversalStrategy<Travers
// so additionally injected ProfileSideEffectStep instances should not have effect here.
if (foundFlatMap && !labeledPath &&
!(step.getNextStep() instanceof Barrier) &&
- !(step.getNextStep() instanceof NoneStep) &&
+ !(step.getNextStep() instanceof DiscardStep) &&
!(step.getNextStep() instanceof EmptyStep) &&
!(step.getNextStep() instanceof ProfileSideEffectStep)) {
final Step noOpBarrierStep = new NoOpBarrierStep<>(traversal, MAX_BARRIER_SIZE);
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategy.java
index fc4e845797..4a007c910a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategy.java
@@ -27,13 +27,9 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.LambdaHolder;
import org.apache.tinkerpop.gremlin.process.traversal.step.PathProcessor;
import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
import org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DedupGlobalStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.NoOpBarrierStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.SelectOneStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.SelectStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
@@ -140,7 +136,7 @@ public final class PathRetractionStrategy extends AbstractTraversalStrategy<Trav
!(currentStep instanceof Barrier) &&
!(currentStep.getNextStep() instanceof Barrier) &&
!(currentStep.getTraversal().getParent() instanceof MatchStep) &&
- !(currentStep.getNextStep() instanceof NoneStep) &&
+ !(currentStep.getNextStep() instanceof DiscardStep) &&
!(currentStep.getNextStep() instanceof EmptyStep))
TraversalHelper.insertAfterStep(new NoOpBarrierStep<>(traversal, this.standardBarrierSize), currentStep, traversal);
}
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
index 33bf519252..99e015d957 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
@@ -23,9 +23,8 @@ import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.finaliza
import org.apache.tinkerpop.gremlin.process.traversal.Step;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
import org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ProfileSideEffectStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectCapStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.ReducingBarrierStep;
@@ -73,15 +72,15 @@ public final class StandardVerificationStrategy extends AbstractTraversalStrateg
// The ProfileSideEffectStep must be one of the following
// (1) the last step
- // (2) 2nd last step when accompanied by the cap step or none step (i.e. iterate() to nothing)
+ // (2) 2nd last step when accompanied by the cap step or discard step (i.e. iterate() to nothing)
// (3) 3rd to last when the traversal ends with a RequirementsStep.
final Step<?, ?> endStep = traversal.asAdmin().getEndStep();
if (TraversalHelper.hasStepOfClass(ProfileSideEffectStep.class, traversal) &&
!(endStep instanceof ProfileSideEffectStep ||
(endStep instanceof SideEffectCapStep && endStep.getPreviousStep() instanceof ProfileSideEffectStep) ||
- (endStep instanceof NoneStep && endStep.getPreviousStep() instanceof SideEffectCapStep && endStep.getPreviousStep().getPreviousStep() instanceof ProfileSideEffectStep) ||
+ (endStep instanceof DiscardStep && endStep.getPreviousStep() instanceof SideEffectCapStep && endStep.getPreviousStep().getPreviousStep() instanceof ProfileSideEffectStep) ||
(endStep instanceof RequirementsStep && endStep.getPreviousStep() instanceof SideEffectCapStep && endStep.getPreviousStep().getPreviousStep() instanceof ProfileSideEffectStep) ||
- (endStep instanceof RequirementsStep && endStep.getPreviousStep() instanceof NoneStep && endStep.getPreviousStep().getPreviousStep() instanceof SideEffectCapStep && endStep.getPreviousStep().getPreviousStep().getPreviousStep() instanceof ProfileSideEffectStep))) {
+ (endStep instanceof RequirementsStep && endStep.getPreviousStep() instanceof DiscardStep && endStep.getPreviousStep().getPreviousStep() instanceof SideEffectCapStep && endStep.getPreviousStep().getPreviousStep().getPreviousStep() instanceof ProfileSideEffectStep))) {
throw new VerificationException("When specified, the profile()-Step must be the last step or followed only by the cap()-step.", traversal);
}
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/BytecodeHelper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/BytecodeHelper.java
index 0ad7c53764..5eb5ef252b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/BytecodeHelper.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/BytecodeHelper.java
@@ -51,7 +51,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DropStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.IsStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.LambdaFilterStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DiscardStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NotStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.PathFilterStep;
@@ -325,7 +325,7 @@ public final class BytecodeHelper {
put(GraphTraversal.Symbols.as, Collections.emptyList());
put(GraphTraversal.Symbols.option, Collections.emptyList());
put(Traversal.Symbols.profile, Collections.singletonList(ProfileStep.class));
- put(Traversal.Symbols.none, Collections.singletonList(NoneStep.class));
+ put(Traversal.Symbols.discard, Collections.singletonList(DiscardStep.class));
put(TraversalSource.Symbols.withSack, Collections.emptyList());
put(TraversalSource.Symbols.withoutStrategies, Collections.emptyList());
put(TraversalSource.Symbols.withStrategies, Collections.emptyList());
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitorTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitorTest.java
index 6e4a26f5ab..e8866f18df 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitorTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitorTest.java
@@ -1300,9 +1300,9 @@ public class TraversalMethodVisitorTest {
}
@Test
- public void shouldParseTraversalMethod_none_somethingAfter() throws Exception {
- compare(g.V().none().path(), eval("g.V().none().path()"));
- compare(g.V().none().E(), eval("g.V().none().E()"));
- compare(g.V().none().none(), eval("g.V().none().none()"));
+ public void shouldParseTraversalMethod_discard_somethingAfter() throws Exception {
+ compare(g.V().discard().path(), eval("g.V().discard().path()"));
+ compare(g.V().discard().E(), eval("g.V().discard().E()"));
+ compare(g.V().discard().discard(), eval("g.V().discard().discard()"));
}
}
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalRootVisitorTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalRootVisitorTest.java
index a6bc04f0e6..c153b091bf 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalRootVisitorTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalRootVisitorTest.java
@@ -42,8 +42,8 @@ public class TraversalRootVisitorTest {
@Test
public void shouldParseTraversalMethod_none() {
- compare(g.V().none(), eval("g.V().none()"));
- compare(g.V().union(__.identity().none()), eval("g.V().union(__.identity().none())"));
+ compare(g.V().discard(), eval("g.V().discard()"));
+ compare(g.V().union(__.identity().discard()), eval("g.V().union(__.identity().discard())"));
}
private void compare(Object expected, Object actual) {
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java
index 32c81f4fc8..7f58f0b748 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java
@@ -53,7 +53,7 @@ public class GraphTraversalTest {
private static final Logger logger = LoggerFactory.getLogger(GraphTraversalTest.class);
private static final GraphTraversalSource g = traversal().withEmbedded(EmptyGraph.instance());
- private static Set<String> NO_GRAPH = new HashSet<>(Arrays.asList("asAdmin", "by", "read", "write", "with", "option", "iterate", "to", "from", "profile", "pageRank", "connectedComponent", "peerPressure", "shortestPath", "program", "none"));
+ private static Set<String> NO_GRAPH = new HashSet<>(Arrays.asList("asAdmin", "by", "read", "write", "with", "option", "iterate", "to", "from", "profile", "pageRank", "connectedComponent", "peerPressure", "shortestPath", "program", "discard"));
private static Set<String> NO_ANONYMOUS = new HashSet<>(Arrays.asList("start", "__"));
private static Set<String> IGNORES_BYTECODE = new HashSet<>(Arrays.asList("asAdmin", "read", "write", "iterate"));
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/EarlyLimitStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/EarlyLimitStrategyTest.java
index d6578dda24..55bd397f63 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/EarlyLimitStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/EarlyLimitStrategyTest.java
@@ -77,8 +77,8 @@ public class EarlyLimitStrategyTest {
public static Iterable<Object[]> generateTestParameters() {
return Arrays.asList(new Object[][]{
{__.out().valueMap().limit(1), __.out().limit(1).valueMap(), Collections.emptyList()},
- {__.out().limit(5).valueMap().range(5, 10), __.start().out().none(), Collections.emptyList()},
- {__.out().limit(5).valueMap().range(6, 10), __.start().out().none(), Collections.emptyList()},
+ {__.out().limit(5).valueMap().range(5, 10), __.start().out().discard(), Collections.emptyList()},
+ {__.out().limit(5).valueMap().range(6, 10), __.start().out().discard(), Collections.emptyList()},
{__.V().out().valueMap().limit(1), __.V().out().limit(1).valueMap(), Collections.singleton(LazyBarrierStrategy.instance())},
{__.out().out().limit(1).in().in(), __.out().out().limit(1).in().barrier(LazyBarrierStrategy.MAX_BARRIER_SIZE).in(), Collections.singleton(LazyBarrierStrategy.instance())},
{__.out().has("name","marko").limit(1).in().in(), __.out().has("name","marko").limit(1).in().in(), Collections.emptyList()},
@@ -92,12 +92,12 @@ public class EarlyLimitStrategyTest {
{__.out().map(__.identity()).map(__.identity()).range(50, -1).map(__.identity()).map(__.identity()).range(10, 60), __.out().range(60, 110).map(__.identity()).map(__.identity()).map(__.identity()).map(__.identity()), Collections.emptyList()},
{__.out().map(__.identity()).map(__.identity()).range(50, 100).map(__.identity()).map(__.identity()).range(10, -1), __.out().range(60, 100).map(__.identity()).map(__.identity()).map(__.identity()).map(__.identity()), Collections.emptyList()},
{__.out().map(__.identity()).map(__.identity()).range(50, 100).as("a").map(__.identity()).map(__.identity()).range(10, -1).as("b"), __.out().range(60, 100).map(__.identity()).map(__.identity()).as("a").map(__.identity()).map(__.identity()).as("b"), Collections.emptyList()},
- {__.out().map(__.identity()).map(__.identity()).range(50, 100).map(__.identity()).map(__.identity()).range(50, -1), __.out().none(), Collections.emptyList()},
- {__.out().map(__.identity()).map(__.identity()).range(50, 100).map(__.identity()).map(__.identity()).range(60, -1), __.out().none(), Collections.emptyList()},
- {__.out().map(__.identity()).map(__.identity()).range(50, 100).as("a").map(__.identity()).map(__.identity()).range(60, -1).as("b"), __.out().none(), Collections.emptyList()},
- {__.out().range(50, 100).store("a").range(50, -1), __.out().range(50, 100).store("a").none(), Collections.emptyList()},
- {__.out().range(50, 100).store("a").range(50, -1).cap("a"), ((GraphTraversal) __.out().range(50, 100).store("a").none()).cap("a"), Collections.emptyList()},
- {__.out().range(50, 100).map(__.identity()).range(50, -1).profile(), __.out().none().profile(), Collections.singleton(ProfileStrategy.instance())},
+ {__.out().map(__.identity()).map(__.identity()).range(50, 100).map(__.identity()).map(__.identity()).range(50, -1), __.out().discard(), Collections.emptyList()},
+ {__.out().map(__.identity()).map(__.identity()).range(50, 100).map(__.identity()).map(__.identity()).range(60, -1), __.out().discard(), Collections.emptyList()},
+ {__.out().map(__.identity()).map(__.identity()).range(50, 100).as("a").map(__.identity()).map(__.identity()).range(60, -1).as("b"), __.out().discard(), Collections.emptyList()},
+ {__.out().range(50, 100).store("a").range(50, -1), __.out().range(50, 100).store("a").discard(), Collections.emptyList()},
+ {__.out().range(50, 100).store("a").range(50, -1).cap("a"), ((GraphTraversal) __.out().range(50, 100).store("a").discard()).cap("a"), Collections.emptyList()},
+ {__.out().range(50, 100).map(__.identity()).range(50, -1).profile(), __.out().discard().profile(), Collections.singleton(ProfileStrategy.instance())},
{__.out().store("a").limit(10), __.out().limit(10).store("a"), Collections.emptyList()},
{__.out().aggregate("a").limit(10), __.out().aggregate("a").limit(10), Collections.emptyList()},
{__.V().branch(__.label()).option("person", __.out("knows").valueMap().limit(1)).option("software", __.out("created").valueMap().limit(2).fold()),
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
index 084b795273..6bc20e4e21 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
@@ -77,7 +77,7 @@ public class StandardVerificationStrategyTest {
if (legalTraversal) {
copy.asAdmin().applyStrategies();
- // try to also apply strategies with iterate() so that a NoneStep is added - for consistency sake we want
+ // try to also apply strategies with iterate() so that a DiscardStep is added - for consistency sake we want
// to be able to run a profile and get no result back with this.
final Traversal forIteration = copyAndConfigureTraversal(traversal);
forIteration.iterate();
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/translator/PythonTranslatorTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/translator/PythonTranslatorTest.java
index 45d5a33ebe..89bda921b9 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/translator/PythonTranslatorTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/translator/PythonTranslatorTest.java
@@ -69,10 +69,10 @@ public class PythonTranslatorTest {
}
@Test
- public void shouldTranslateNone() {
+ public void shouldTranslateDiscard() {
final String gremlinAsPython = translator.translate(
- g.V().none().asAdmin().getBytecode()).getScript();
- assertEquals("g.V().none()", gremlinAsPython);
+ g.V().discard().asAdmin().getBytecode()).getScript();
+ assertEquals("g.V().discard()", gremlinAsPython);
}
@Test
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs
index 9d7909324e..1b64474fbb 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs
@@ -229,7 +229,7 @@ namespace Gremlin.Net.Process.Traversal
/// <returns>The fully drained traversal.</returns>
public ITraversal<TStart, TEnd> Iterate()
{
- Bytecode.AddStep("none");
+ Bytecode.AddStep("discard");
while (MoveNext())
{
}
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
index d9091d1afb..162a89c0fe 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
@@ -714,6 +714,15 @@ namespace Gremlin.Net.Process.Traversal
return Wrap<TStart, TEnd>(this);
}
+ /// <summary>
+ /// Adds the discard step to this <see cref="GraphTraversal{SType, EType}" />.
+ /// </summary>
+ public GraphTraversal<TStart, TEnd> Discard ()
+ {
+ Bytecode.AddStep("discard");
+ return Wrap<TStart, TEnd>(this);
+ }
+
/// <summary>
/// Adds the disjunct step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
@@ -1510,15 +1519,6 @@ namespace Gremlin.Net.Process.Traversal
return Wrap<TStart, TNewEnd>(this);
}
- /// <summary>
- /// Adds the none step to this <see cref="GraphTraversal{SType, EType}" />.
- /// </summary>
- public GraphTraversal<TStart, TEnd> None ()
- {
- Bytecode.AddStep("none");
- return Wrap<TStart, TEnd>(this);
- }
-
/// <summary>
/// Adds the not step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
index 7e077f7fc5..6e5644da70 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
@@ -478,6 +478,14 @@ namespace Gremlin.Net.Process.Traversal
return new GraphTraversal<object, object>().Difference(differenceObject);
}
+ /// <summary>
+ /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the discard step to that traversal.
+ /// </summary>
+ public static GraphTraversal<object, object> discard()
+ {
+ return new GraphTraversal<object, object>().Discard();
+ }
+
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the disjunct step to that traversal.
/// </summary>
@@ -1104,14 +1112,6 @@ namespace Gremlin.Net.Process.Traversal
return new GraphTraversal<object, E2>().Min<E2>(scope);
}
- /// <summary>
- /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the none step to that traversal.
- /// </summary>
- public static GraphTraversal<object, object> None()
- {
- return new GraphTraversal<object, object>().None();
- }
-
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the not step to that traversal.
/// </summary>
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
index df5ac0d3cb..81bb7242df 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
@@ -203,6 +203,12 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
{"g_V_properties_dedup_count", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.AddV("person").Property("name", "josh").AddV("person").Property("name", "josh").AddV("person").Property("name", "josh"), (g,p) =>g.V().Properties<object>("name").Dedup().Count()}},
{"g_V_properties_dedup_byXvalueX_count", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.AddV("person").Property("name", "josh").AddV("person").Property("name", "josh").AddV("person").Property("name", "josh"), (g,p) =>g.V().Properties<object>("name").Dedup().By(T.Value).Count()}},
{"g_V_both_hasXlabel_softwareX_dedup_byXlangX_byXnameX_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Both().Has(T.Label, "software").Dedup().By("lang").By("name").Values<object>("name")}},
+ {"g_V_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Discard()}},
+ {"g_V_discard_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Discard().Discard()}},
+ {"g_V_discard_fold", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Discard().Fold()}},
+ {"g_V_discard_fold_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Discard().Fold().Discard()}},
+ {"g_V_discard_fold_constantX1X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Discard().Fold().Constant<object>(1)}},
+ {"g_V_projectXxX_byXcoalesceXage_isXgtX29XX_discardXX_selectXxX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Project<object>("x").By(__.Coalesce<object>(__.Values<object>("age").Is(P.Gt(29)), __.Discard())).Select<object>("x")}},
{"g_V_drop", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.AddV().As("a").AddV().As("b").AddE("knows").To("a"), (g,p) =>g.V().Drop(), (g,p) =>g.V(), (g,p) =>g.E()}},
{"g_V_outE_drop", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.AddV().As("a").AddV().As("b").AddE("knows").To("a"), (g,p) =>g.V().OutE().Drop(), (g,p) =>g.V(), (g,p) =>g.E()}},
{"g_V_properties_drop", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.AddV().Property("name", "bob").AddV().Property("name", "alice"), (g,p) =>g.V().Properties<object>().Drop(), (g,p) =>g.V(), (g,p) =>g.V().Properties<object>()}},
@@ -318,12 +324,6 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
{"g_V_valuesXageX_isXgte_29X_isXlt_34X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Values<object>("age").Is(P.Gte(29)).Is(P.Lt(34))}},
{"g_V_whereXinXcreatedX_count_isX1XX_valuesXnameX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Where(__.In("created").Count().Is(1)).Values<object>("name")}},
{"g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Where(__.In("created").Count().Is(P.Gte(2))).Values<object>("name")}},
- {"g_V_none", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().None()}},
- {"g_V_none_none", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().None().None()}},
- {"g_V_none_fold", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().None().Fold()}},
- {"g_V_none_fold_none", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().None().Fold().None()}},
- {"g_V_none_fold_constantX1X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().None().Fold().Constant<object>(1)}},
- {"g_V_projectXxX_byXcoalesceXage_isXgtX29XX_noneXX_selectXxX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Project<object>("x").By(__.Coalesce<object>(__.Values<object>("age").Is(P.Gt(29)), __.None())).Select<object>("x")}},
{"g_V_orXhasXage_gt_27X__outE_count_gte_2X_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Or(__.Has("age", P.Gt(27)), __.OutE().Count().Is(P.Gte(2))).Values<object>("name")}},
{"g_V_orXoutEXknowsX__hasXlabel_softwareX_or_hasXage_gte_35XX_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Or(__.OutE("knows"), __.Has(T.Label, "software").Or().Has("age", P.Gte(35))).Values<object>("name")}},
{"g_V_asXaX_orXselectXaX_selectXaXX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().As("a").Or(__.Select<object>("a"), __.Select<object>("a"))}},
diff --git a/gremlin-go/driver/anonymousTraversal.go b/gremlin-go/driver/anonymousTraversal.go
index 67b107ab07..ac6c9a5348 100644
--- a/gremlin-go/driver/anonymousTraversal.go
+++ b/gremlin-go/driver/anonymousTraversal.go
@@ -117,6 +117,8 @@ type AnonymousTraversal interface {
Dedup(args ...interface{}) *GraphTraversal
// Difference adds the difference step to the GraphTraversal.
Difference(args ...interface{}) *GraphTraversal
+ // Discard adds the discard step to the GraphTraversal.
+ Discard(args ...interface{}) *GraphTraversal
// Disjunct adds the disjunct step to the GraphTraversal.
Disjunct(args ...interface{}) *GraphTraversal
// Drop adds the drop step to the GraphTraversal.
@@ -205,8 +207,6 @@ type AnonymousTraversal interface {
MergeV(args ...interface{}) *GraphTraversal
// Min adds the min step to the GraphTraversal.
Min(args ...interface{}) *GraphTraversal
- // None adds the none step to the GraphTraversal.
- None(args ...interface{}) *GraphTraversal
// Not adds the not step to the GraphTraversal.
Not(args ...interface{}) *GraphTraversal
// Option adds the option step to the GraphTraversal.
@@ -506,6 +506,11 @@ func (anonymousTraversal *anonymousTraversal) Difference(args ...interface{}) *G
return anonymousTraversal.graphTraversal().Difference(args...)
}
+// Discard adds the discard step to the GraphTraversal.
+func (anonymousTraversal *anonymousTraversal) Discard(args ...interface{}) *GraphTraversal {
+ return anonymousTraversal.graphTraversal().Discard(args...)
+}
+
// Disjunct adds the disjunct step to the GraphTraversal.
func (anonymousTraversal *anonymousTraversal) Disjunct(args ...interface{}) *GraphTraversal {
return anonymousTraversal.graphTraversal().Disjunct(args...)
@@ -726,11 +731,6 @@ func (anonymousTraversal *anonymousTraversal) Min(args ...interface{}) *GraphTra
return anonymousTraversal.graphTraversal().Min(args...)
}
-// None adds the none step to the GraphTraversal.
-func (anonymousTraversal *anonymousTraversal) None(args ...interface{}) *GraphTraversal {
- return anonymousTraversal.graphTraversal().None(args...)
-}
-
// Not adds the not step to the GraphTraversal.
func (anonymousTraversal *anonymousTraversal) Not(args ...interface{}) *GraphTraversal {
return anonymousTraversal.graphTraversal().Not(args...)
diff --git a/gremlin-go/driver/cucumber/gremlin.go b/gremlin-go/driver/cucumber/gremlin.go
index 0aca8a216b..b09f540c46 100644
--- a/gremlin-go/driver/cucumber/gremlin.go
+++ b/gremlin-go/driver/cucumber/gremlin.go
@@ -173,6 +173,12 @@ var translationMap = map[string][]func(g *gremlingo.GraphTraversalSource, p map[
"g_V_properties_dedup_count": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("name", "josh").AddV("person").Property("name", "josh").AddV("person").Property("name", "josh")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Properties("name").Dedup().Count()}},
"g_V_properties_dedup_byXvalueX_count": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("name", "josh").AddV("person").Property("name", "josh").AddV("person").Property("name", "josh")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Properties("name").Dedup().By(gremlingo.T.Value).Count()}},
"g_V_both_hasXlabel_softwareX_dedup_byXlangX_byXnameX_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Both().Has(gremlingo.T.Label, "software").Dedup().By("lang").By("name").Values("name")}},
+ "g_V_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Discard()}},
+ "g_V_discard_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Discard().Discard()}},
+ "g_V_discard_fold": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Discard().Fold()}},
+ "g_V_discard_fold_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Discard().Fold().Discard()}},
+ "g_V_discard_fold_constantX1X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Discard().Fold().Constant(1)}},
+ "g_V_projectXxX_byXcoalesceXage_isXgtX29XX_discardXX_selectXxX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Project("x").By(gremlingo.T__.Coalesce(gremlingo.T__.Values("age").Is(gremlingo.P.Gt(29)), gremlingo.T__.Discard())).Select("x")}},
"g_V_drop": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV().As("a").AddV().As("b").AddE("knows").To("a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Drop()}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V()}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {ret [...]
"g_V_outE_drop": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV().As("a").AddV().As("b").AddE("knows").To("a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().OutE().Drop()}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V()}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTr [...]
"g_V_properties_drop": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV().Property("name", "bob").AddV().Property("name", "alice")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Properties().Drop()}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V()}, func(g *gremlingo.GraphTraversalSource, p map[string]interfa [...]
@@ -288,12 +294,6 @@ var translationMap = map[string][]func(g *gremlingo.GraphTraversalSource, p map[
"g_V_valuesXageX_isXgte_29X_isXlt_34X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Values("age").Is(gremlingo.P.Gte(29)).Is(gremlingo.P.Lt(34))}},
"g_V_whereXinXcreatedX_count_isX1XX_valuesXnameX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Where(gremlingo.T__.In("created").Count().Is(1)).Values("name")}},
"g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Where(gremlingo.T__.In("created").Count().Is(gremlingo.P.Gte(2))).Values("name")}},
- "g_V_none": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().None()}},
- "g_V_none_none": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().None().None()}},
- "g_V_none_fold": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().None().Fold()}},
- "g_V_none_fold_none": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().None().Fold().None()}},
- "g_V_none_fold_constantX1X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().None().Fold().Constant(1)}},
- "g_V_projectXxX_byXcoalesceXage_isXgtX29XX_noneXX_selectXxX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Project("x").By(gremlingo.T__.Coalesce(gremlingo.T__.Values("age").Is(gremlingo.P.Gt(29)), gremlingo.T__.None())).Select("x")}},
"g_V_orXhasXage_gt_27X__outE_count_gte_2X_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Or(gremlingo.T__.Has("age", gremlingo.P.Gt(27)), gremlingo.T__.OutE().Count().Is(gremlingo.P.Gte(2))).Values("name")}},
"g_V_orXoutEXknowsX__hasXlabel_softwareX_or_hasXage_gte_35XX_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Or(gremlingo.T__.OutE("knows"), gremlingo.T__.Has(gremlingo.T.Label, "software").Or().Has("age", gremlingo.P.Gte(35))).Values("name")}},
"g_V_asXaX_orXselectXaX_selectXaXX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().As("a").Or(gremlingo.T__.Select("a"), gremlingo.T__.Select("a"))}},
diff --git a/gremlin-go/driver/graphTraversal.go b/gremlin-go/driver/graphTraversal.go
index ae9aa7f262..6573db7485 100644
--- a/gremlin-go/driver/graphTraversal.go
+++ b/gremlin-go/driver/graphTraversal.go
@@ -258,6 +258,12 @@ func (g *GraphTraversal) Difference(args ...interface{}) *GraphTraversal {
return g
}
+// Discard adds the discard step to the GraphTraversal.
+func (g *GraphTraversal) Discard(args ...interface{}) *GraphTraversal {
+ g.Bytecode.AddStep("discard", args...)
+ return g
+}
+
// Disjunct adds the disjunct step to the GraphTraversal.
func (g *GraphTraversal) Disjunct(args ...interface{}) *GraphTraversal {
g.Bytecode.AddStep("disjunct", args...)
@@ -524,12 +530,6 @@ func (g *GraphTraversal) Min(args ...interface{}) *GraphTraversal {
return g
}
-// None adds the none step to the GraphTraversal.
-func (g *GraphTraversal) None(args ...interface{}) *GraphTraversal {
- g.Bytecode.AddStep("none", args...)
- return g
-}
-
// Not adds the not step to the GraphTraversal.
func (g *GraphTraversal) Not(args ...interface{}) *GraphTraversal {
g.Bytecode.AddStep("not", args...)
diff --git a/gremlin-go/driver/traversal.go b/gremlin-go/driver/traversal.go
index 6d82f6d0af..66f8cd3c2e 100644
--- a/gremlin-go/driver/traversal.go
+++ b/gremlin-go/driver/traversal.go
@@ -77,7 +77,7 @@ func (t *Traversal) Iterate() <-chan error {
return
}
- if err := t.Bytecode.AddStep("none"); err != nil {
+ if err := t.Bytecode.AddStep("discard"); err != nil {
r <- err
return
}
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
index e86dd4af47..b2aa34afba 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
@@ -682,6 +682,16 @@ class GraphTraversal extends Traversal {
return this;
}
+ /**
+ * Graph traversal discard method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ discard(...args) {
+ this.bytecode.addStep('discard', args);
+ return this;
+ }
+
/**
* Graph traversal disjunct method.
* @param {...Object} args
@@ -1121,16 +1131,6 @@ class GraphTraversal extends Traversal {
return this;
}
- /**
- * Graph traversal none method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- none(...args) {
- this.bytecode.addStep('none', args);
- return this;
- }
-
/**
* Graph traversal not method.
* @param {...Object} args
@@ -1770,6 +1770,7 @@ const statics = {
dateAdd: (...args) => callOnEmptyTraversal('dateAdd', args),
dateDiff: (...args) => callOnEmptyTraversal('dateDiff', args),
dedup: (...args) => callOnEmptyTraversal('dedup', args),
+ discard: (...args) => callOnEmptyTraversal('discard', args),
disjunct: (...args) => callOnEmptyTraversal('disjunct', args),
drop: (...args) => callOnEmptyTraversal('drop', args),
element: (...args) => callOnEmptyTraversal('element', args),
@@ -1811,7 +1812,6 @@ const statics = {
mergeE: (...args) => callOnEmptyTraversal('mergeE', args),
mergeV: (...args) => callOnEmptyTraversal('mergeV', args),
min: (...args) => callOnEmptyTraversal('min', args),
- none: (...args) => callOnEmptyTraversal('none', args),
not: (...args) => callOnEmptyTraversal('not', args),
optional: (...args) => callOnEmptyTraversal('optional', args),
or: (...args) => callOnEmptyTraversal('or', args),
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index a1ff9316dd..f925a72624 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -84,7 +84,7 @@ class Traversal {
* @returns {Promise}
*/
iterate() {
- this.bytecode.addStep('none');
+ this.bytecode.addStep('discard');
return this._applyStrategies().then(() => {
let it;
while ((it = this._getNext()) && !it.done) {
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
index e84bbbcaf9..03840c482b 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
@@ -203,6 +203,12 @@ const gremlins = {
g_V_properties_dedup_count: [function({g}) { return g.addV("person").property("name", "josh").addV("person").property("name", "josh").addV("person").property("name", "josh") }, function({g}) { return g.V().properties("name").dedup().count() }],
g_V_properties_dedup_byXvalueX_count: [function({g}) { return g.addV("person").property("name", "josh").addV("person").property("name", "josh").addV("person").property("name", "josh") }, function({g}) { return g.V().properties("name").dedup().by(T.value).count() }],
g_V_both_hasXlabel_softwareX_dedup_byXlangX_byXnameX_name: [function({g}) { return g.V().both().has(T.label, "software").dedup().by("lang").by("name").values("name") }],
+ g_V_discard: [function({g}) { return g.V().discard() }],
+ g_V_discard_discard: [function({g}) { return g.V().discard().discard() }],
+ g_V_discard_fold: [function({g}) { return g.V().discard().fold() }],
+ g_V_discard_fold_discard: [function({g}) { return g.V().discard().fold().discard() }],
+ g_V_discard_fold_constantX1X: [function({g}) { return g.V().discard().fold().constant(1) }],
+ g_V_projectXxX_byXcoalesceXage_isXgtX29XX_discardXX_selectXxX: [function({g}) { return g.V().project("x").by(__.coalesce(__.values("age").is(P.gt(29)), __.discard())).select("x") }],
g_V_drop: [function({g}) { return g.addV().as("a").addV().as("b").addE("knows").to("a") }, function({g}) { return g.V().drop() }, function({g}) { return g.V() }, function({g}) { return g.E() }],
g_V_outE_drop: [function({g}) { return g.addV().as("a").addV().as("b").addE("knows").to("a") }, function({g}) { return g.V().outE().drop() }, function({g}) { return g.V() }, function({g}) { return g.E() }],
g_V_properties_drop: [function({g}) { return g.addV().property("name", "bob").addV().property("name", "alice") }, function({g}) { return g.V().properties().drop() }, function({g}) { return g.V() }, function({g}) { return g.V().properties() }],
@@ -318,12 +324,6 @@ const gremlins = {
g_V_valuesXageX_isXgte_29X_isXlt_34X: [function({g}) { return g.V().values("age").is(P.gte(29)).is(P.lt(34)) }],
g_V_whereXinXcreatedX_count_isX1XX_valuesXnameX: [function({g}) { return g.V().where(__.in_("created").count().is(1)).values("name") }],
g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX: [function({g}) { return g.V().where(__.in_("created").count().is(P.gte(2))).values("name") }],
- g_V_none: [function({g}) { return g.V().none() }],
- g_V_none_none: [function({g}) { return g.V().none().none() }],
- g_V_none_fold: [function({g}) { return g.V().none().fold() }],
- g_V_none_fold_none: [function({g}) { return g.V().none().fold().none() }],
- g_V_none_fold_constantX1X: [function({g}) { return g.V().none().fold().constant(1) }],
- g_V_projectXxX_byXcoalesceXage_isXgtX29XX_noneXX_selectXxX: [function({g}) { return g.V().project("x").by(__.coalesce(__.values("age").is(P.gt(29)), __.none())).select("x") }],
g_V_orXhasXage_gt_27X__outE_count_gte_2X_name: [function({g}) { return g.V().or(__.has("age", P.gt(27)), __.outE().count().is(P.gte(2))).values("name") }],
g_V_orXoutEXknowsX__hasXlabel_softwareX_or_hasXage_gte_35XX_name: [function({g}) { return g.V().or(__.outE("knows"), __.has(T.label, "software").or().has("age", P.gte(35))).values("name") }],
g_V_asXaX_orXselectXaX_selectXaXX: [function({g}) { return g.V().as("a").or(__.select("a"), __.select("a")) }],
diff --git a/gremlin-language/src/main/antlr4/Gremlin.g4 b/gremlin-language/src/main/antlr4/Gremlin.g4
index 0b60761f35..9fbcae894e 100644
--- a/gremlin-language/src/main/antlr4/Gremlin.g4
+++ b/gremlin-language/src/main/antlr4/Gremlin.g4
@@ -202,6 +202,7 @@ traversalMethod
| traversalMethod_cyclicPath
| traversalMethod_dedup
| traversalMethod_difference
+ | traversalMethod_discard
| traversalMethod_disjunct
| traversalMethod_drop
| traversalMethod_elementMap
@@ -238,7 +239,6 @@ traversalMethod
| traversalMethod_max
| traversalMethod_mean
| traversalMethod_min
- | traversalMethod_none
| traversalMethod_not
| traversalMethod_option
| traversalMethod_optional
@@ -474,6 +474,10 @@ traversalMethod_difference
: K_DIFFERENCE LPAREN genericArgument RPAREN #traversalMethod_difference_Object
;
+traversalMethod_discard
+ : K_DISCARD LPAREN RPAREN
+ ;
+
traversalMethod_disjunct
: K_DISJUNCT LPAREN genericArgument RPAREN #traversalMethod_disjunct_Object
;
@@ -683,10 +687,6 @@ traversalMethod_min
| K_MIN LPAREN traversalScope RPAREN #traversalMethod_min_Scope
;
-traversalMethod_none
- : K_NONE LPAREN RPAREN
- ;
-
traversalMethod_not
: K_NOT LPAREN nestedTraversal RPAREN
;
@@ -1715,6 +1715,7 @@ keyword
| K_DESC
| K_DIFFERENCE
| K_DIRECTION
+ | K_DISCARD
| K_DISJUNCT
| K_DISTANCE
| K_DIV
@@ -1974,6 +1975,7 @@ K_DECR: 'decr';
K_DEDUP: 'dedup';
K_DESC: 'desc';
K_DIFFERENCE: 'difference';
+K_DISCARD: 'discard';
K_DIRECTION: 'Direction';
K_DISJUNCT: 'disjunct';
K_DISTANCE: 'distance';
diff --git a/gremlin-python/src/main/python/gremlin_python/process/graph_traversal.py b/gremlin-python/src/main/python/gremlin_python/process/graph_traversal.py
index 9a33d899fd..df7c3d4e65 100644
--- a/gremlin-python/src/main/python/gremlin_python/process/graph_traversal.py
+++ b/gremlin-python/src/main/python/gremlin_python/process/graph_traversal.py
@@ -442,6 +442,10 @@ class GraphTraversal(Traversal):
self.bytecode.add_step("difference", *args)
return self
+ def discard(self, *args):
+ self.bytecode.add_step("discard", *args)
+ return self
+
def disjunct(self, *args):
self.bytecode.add_step("disjunct", *args)
return self
@@ -703,10 +707,6 @@ class GraphTraversal(Traversal):
self.bytecode.add_step("min", *args)
return self
- def none(self, *args):
- self.bytecode.add_step("none", *args)
- return self
-
def not_(self, *args):
self.bytecode.add_step("not", *args)
return self
@@ -1215,6 +1215,10 @@ class __(object, metaclass=MagicType):
def difference(cls, *args):
return cls.graph_traversal(None, None, Bytecode()).difference(*args)
+ @classmethod
+ def discard(cls, *args):
+ return cls.graph_traversal(None, None, Bytecode()).discard(*args)
+
@classmethod
def disjunct(cls, *args):
return cls.graph_traversal(None, None, Bytecode()).disjunct(*args)
@@ -1483,10 +1487,6 @@ class __(object, metaclass=MagicType):
def min_(cls, *args):
return cls.graph_traversal(None, None, Bytecode()).min_(*args)
- @classmethod
- def none(cls, *args):
- return cls.graph_traversal(None, None, Bytecode()).none(*args)
-
@classmethod
def not_(cls, *args):
return cls.graph_traversal(None, None, Bytecode()).not_(*args)
@@ -1967,6 +1967,10 @@ def dedup(*args):
return __.dedup(*args)
+def discard(*args):
+ return __.discard(*args)
+
+
def disjunct(*args):
return __.disjunct(*args)
@@ -2177,10 +2181,6 @@ def min_(*args):
return __.min_(*args)
-def none(*args):
- return __.none(*args)
-
-
def not_(*args):
return __.not_(*args)
@@ -2471,6 +2471,8 @@ statics.add_static('date_diff', date_diff)
statics.add_static('dedup', dedup)
+statics.add_static('discard', discard)
+
statics.add_static('disjunct', disjunct)
statics.add_static('drop', drop)
@@ -2573,8 +2575,6 @@ statics.add_static('merge_v', merge_v)
statics.add_static('min_', min_)
-statics.add_static('none', none)
-
statics.add_static('not_', not_)
statics.add_static('optional', optional)
diff --git a/gremlin-python/src/main/python/gremlin_python/process/traversal.py b/gremlin-python/src/main/python/gremlin_python/process/traversal.py
index fb74433348..e806e7aa69 100644
--- a/gremlin-python/src/main/python/gremlin_python/process/traversal.py
+++ b/gremlin-python/src/main/python/gremlin_python/process/traversal.py
@@ -75,7 +75,7 @@ class Traversal(object):
return set(iter(self))
def iterate(self):
- self.bytecode.add_step("none")
+ self.bytecode.add_step("discard")
while True:
try: self.next_traverser()
except StopIteration: return self
diff --git a/gremlin-python/src/main/python/radish/gremlin.py b/gremlin-python/src/main/python/radish/gremlin.py
index 9f9d5aed6e..1351a0a4a1 100644
--- a/gremlin-python/src/main/python/radish/gremlin.py
+++ b/gremlin-python/src/main/python/radish/gremlin.py
@@ -176,6 +176,12 @@ world.gremlins = {
'g_V_properties_dedup_count': [(lambda g:g.add_v('person').property('name', 'josh').add_v('person').property('name', 'josh').add_v('person').property('name', 'josh')), (lambda g:g.V().properties('name').dedup().count())],
'g_V_properties_dedup_byXvalueX_count': [(lambda g:g.add_v('person').property('name', 'josh').add_v('person').property('name', 'josh').add_v('person').property('name', 'josh')), (lambda g:g.V().properties('name').dedup().by(T.value).count())],
'g_V_both_hasXlabel_softwareX_dedup_byXlangX_byXnameX_name': [(lambda g:g.V().both().has(T.label, 'software').dedup().by('lang').by('name').values('name'))],
+ 'g_V_discard': [(lambda g:g.V().discard())],
+ 'g_V_discard_discard': [(lambda g:g.V().discard().discard())],
+ 'g_V_discard_fold': [(lambda g:g.V().discard().fold())],
+ 'g_V_discard_fold_discard': [(lambda g:g.V().discard().fold().discard())],
+ 'g_V_discard_fold_constantX1X': [(lambda g:g.V().discard().fold().constant(1))],
+ 'g_V_projectXxX_byXcoalesceXage_isXgtX29XX_discardXX_selectXxX': [(lambda g:g.V().project('x').by(__.coalesce(__.values('age').is_(P.gt(29)), __.discard())).select('x'))],
'g_V_drop': [(lambda g:g.add_v().as_('a').add_v().as_('b').add_e('knows').to('a')), (lambda g:g.V().drop()), (lambda g:g.V()), (lambda g:g.E())],
'g_V_outE_drop': [(lambda g:g.add_v().as_('a').add_v().as_('b').add_e('knows').to('a')), (lambda g:g.V().out_e().drop()), (lambda g:g.V()), (lambda g:g.E())],
'g_V_properties_drop': [(lambda g:g.add_v().property('name', 'bob').add_v().property('name', 'alice')), (lambda g:g.V().properties().drop()), (lambda g:g.V()), (lambda g:g.V().properties())],
@@ -291,12 +297,6 @@ world.gremlins = {
'g_V_valuesXageX_isXgte_29X_isXlt_34X': [(lambda g:g.V().values('age').is_(P.gte(29)).is_(P.lt(34)))],
'g_V_whereXinXcreatedX_count_isX1XX_valuesXnameX': [(lambda g:g.V().where(__.in_('created').count().is_(1)).values('name'))],
'g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX': [(lambda g:g.V().where(__.in_('created').count().is_(P.gte(2))).values('name'))],
- 'g_V_none': [(lambda g:g.V().none())],
- 'g_V_none_none': [(lambda g:g.V().none().none())],
- 'g_V_none_fold': [(lambda g:g.V().none().fold())],
- 'g_V_none_fold_none': [(lambda g:g.V().none().fold().none())],
- 'g_V_none_fold_constantX1X': [(lambda g:g.V().none().fold().constant(1))],
- 'g_V_projectXxX_byXcoalesceXage_isXgtX29XX_noneXX_selectXxX': [(lambda g:g.V().project('x').by(__.coalesce(__.values('age').is_(P.gt(29)), __.none())).select('x'))],
'g_V_orXhasXage_gt_27X__outE_count_gte_2X_name': [(lambda g:g.V().or_(__.has('age', P.gt(27)), __.out_e().count().is_(P.gte(2))).values('name'))],
'g_V_orXoutEXknowsX__hasXlabel_softwareX_or_hasXage_gte_35XX_name': [(lambda g:g.V().or_(__.out_e('knows'), __.has(T.label, 'software').or_().has('age', P.gte(35))).values('name'))],
'g_V_asXaX_orXselectXaX_selectXaXX': [(lambda g:g.V().as_('a').or_(__.select('a'), __.select('a')))],
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
index af61f822b5..bbf59db189 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
@@ -30,7 +30,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.VerificationException;
import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
-import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Transaction;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -38,12 +37,10 @@ import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
import org.junit.Ignore;
import org.junit.Test;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
-import java.util.stream.Collectors;
import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal;
@@ -52,7 +49,6 @@ import static org.apache.tinkerpop.gremlin.structure.Graph.Features.GraphFeature
import static org.hamcrest.core.StringStartsWith.startsWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertTrue;
@@ -110,7 +106,7 @@ public class CoreTraversalTest extends AbstractGremlinProcessTest {
assertEquals(2, traversal.asAdmin().getSideEffects().<BulkSet>get("x").size());
assertTrue(traversal.asAdmin().getSideEffects().<BulkSet>get("x").contains("ripple"));
assertTrue(traversal.asAdmin().getSideEffects().<BulkSet>get("x").contains("lop"));
- assertEquals(Traversal.Symbols.none, traversal.asAdmin().getBytecode().getStepInstructions().get(traversal.asAdmin().getBytecode().getStepInstructions().size()-1).getOperator());
+ assertEquals(Traversal.Symbols.discard, traversal.asAdmin().getBytecode().getStepInstructions().get(traversal.asAdmin().getBytecode().getStepInstructions().size()-1).getOperator());
}
@Test
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/None.feature b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Discard.feature
similarity index 78%
rename from gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/None.feature
rename to gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Discard.feature
index 59f9788497..25e0dadff0 100644
--- a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/None.feature
+++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Discard.feature
@@ -15,63 +15,63 @@
# specific language governing permissions and limitations
# under the License.
-@StepClassFilter @StepNone
-Feature: Step - none()
+@StepClassFilter @StepDiscard
+Feature: Step - discard()
- Scenario: g_V_none
+ Scenario: g_V_discard
Given the modern graph
And the traversal of
"""
- g.V().none()
+ g.V().discard()
"""
When iterated to list
Then the result should be empty
- Scenario: g_V_none_none
+ Scenario: g_V_discard_discard
Given the modern graph
And the traversal of
"""
- g.V().none().none()
+ g.V().discard().discard()
"""
When iterated to list
Then the result should be empty
- Scenario: g_V_none_fold
+ Scenario: g_V_discard_fold
Given the modern graph
And the traversal of
"""
- g.V().none().fold()
+ g.V().discard().fold()
"""
When iterated to list
Then the result should be unordered
| result |
| l[] |
- Scenario: g_V_none_fold_none
+ Scenario: g_V_discard_fold_discard
Given the modern graph
And the traversal of
"""
- g.V().none().fold().none()
+ g.V().discard().fold().discard()
"""
When iterated to list
Then the result should be empty
- Scenario: g_V_none_fold_constantX1X
+ Scenario: g_V_discard_fold_constantX1X
Given the modern graph
And the traversal of
"""
- g.V().none().fold().constant(1)
+ g.V().discard().fold().constant(1)
"""
When iterated to list
Then the result should be unordered
| result |
| d[1].i |
- Scenario: g_V_projectXxX_byXcoalesceXage_isXgtX29XX_noneXX_selectXxX
+ Scenario: g_V_projectXxX_byXcoalesceXage_isXgtX29XX_discardXX_selectXxX
Given the modern graph
And the traversal of
"""
- g.V().project("x").by(__.coalesce(__.values("age").is(P.gt(29)), __.none())).
+ g.V().project("x").by(__.coalesce(__.values("age").is(P.gt(29)), __.discard())).
select("x")
"""
When iterated to list
(tinkerpop) 03/03: Backported more discard() steps from 4.x
Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
spmallette pushed a commit to branch backport-discard
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 1d11a4a08979d044748f8a4cb33903d464078bb6
Author: Stephen Mallette <st...@amazon.com>
AuthorDate: Sat Aug 2 12:51:02 2025 -0400
Backported more discard() steps from 4.x
---
.../Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs | 3 +++
gremlin-go/driver/cucumber/gremlin.go | 3 +++
.../gremlin-javascript/test/cucumber/gremlin.js | 3 +++
gremlin-python/src/main/python/radish/gremlin.py | 3 +++
.../gremlin/test/features/filter/Discard.feature | 30 +++++++++++++++++++++-
5 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
index 1549d3ae0d..c08b66053c 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
@@ -203,6 +203,9 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
{"g_V_properties_dedup_count", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.AddV("person").Property("name", "josh").AddV("person").Property("name", "josh").AddV("person").Property("name", "josh"), (g,p) =>g.V().Properties<object>("name").Dedup().Count()}},
{"g_V_properties_dedup_byXvalueX_count", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.AddV("person").Property("name", "josh").AddV("person").Property("name", "josh").AddV("person").Property("name", "josh"), (g,p) =>g.V().Properties<object>("name").Dedup().By(T.Value).Count()}},
{"g_V_both_hasXlabel_softwareX_dedup_byXlangX_byXnameX_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Both().Has(T.Label, "software").Dedup().By("lang").By("name").Values<object>("name")}},
+ {"g_V_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_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Discard()}},
{"g_V_discard_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Discard().Discard()}},
{"g_V_discard_fold", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Discard().Fold()}},
diff --git a/gremlin-go/driver/cucumber/gremlin.go b/gremlin-go/driver/cucumber/gremlin.go
index 79fecd7d60..1c21117aae 100644
--- a/gremlin-go/driver/cucumber/gremlin.go
+++ b/gremlin-go/driver/cucumber/gremlin.go
@@ -173,6 +173,9 @@ var translationMap = map[string][]func(g *gremlingo.GraphTraversalSource, p map[
"g_V_properties_dedup_count": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("name", "josh").AddV("person").Property("name", "josh").AddV("person").Property("name", "josh")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Properties("name").Dedup().Count()}},
"g_V_properties_dedup_byXvalueX_count": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("name", "josh").AddV("person").Property("name", "josh").AddV("person").Property("name", "josh")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Properties("name").Dedup().By(gremlingo.T.Value).Count()}},
"g_V_both_hasXlabel_softwareX_dedup_byXlangX_byXnameX_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Both().Has(gremlingo.T.Label, "software").Dedup().By("lang").By("name").Values("name")}},
+ "g_V_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_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Discard()}},
"g_V_discard_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Discard().Discard()}},
"g_V_discard_fold": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Discard().Fold()}},
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 5c23d7a430..1815521452 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
@@ -203,6 +203,9 @@ const gremlins = {
g_V_properties_dedup_count: [function({g}) { return g.addV("person").property("name", "josh").addV("person").property("name", "josh").addV("person").property("name", "josh") }, function({g}) { return g.V().properties("name").dedup().count() }],
g_V_properties_dedup_byXvalueX_count: [function({g}) { return g.addV("person").property("name", "josh").addV("person").property("name", "josh").addV("person").property("name", "josh") }, function({g}) { return g.V().properties("name").dedup().by(T.value).count() }],
g_V_both_hasXlabel_softwareX_dedup_byXlangX_byXnameX_name: [function({g}) { return g.V().both().has(T.label, "software").dedup().by("lang").by("name").values("name") }],
+ g_V_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_discard: [function({g}) { return g.V().discard() }],
g_V_discard_discard: [function({g}) { return g.V().discard().discard() }],
g_V_discard_fold: [function({g}) { return g.V().discard().fold() }],
diff --git a/gremlin-python/src/main/python/radish/gremlin.py b/gremlin-python/src/main/python/radish/gremlin.py
index 64d5257aa9..8e61ccaf51 100644
--- a/gremlin-python/src/main/python/radish/gremlin.py
+++ b/gremlin-python/src/main/python/radish/gremlin.py
@@ -176,6 +176,9 @@ world.gremlins = {
'g_V_properties_dedup_count': [(lambda g:g.add_v('person').property('name', 'josh').add_v('person').property('name', 'josh').add_v('person').property('name', 'josh')), (lambda g:g.V().properties('name').dedup().count())],
'g_V_properties_dedup_byXvalueX_count': [(lambda g:g.add_v('person').property('name', 'josh').add_v('person').property('name', 'josh').add_v('person').property('name', 'josh')), (lambda g:g.V().properties('name').dedup().by(T.value).count())],
'g_V_both_hasXlabel_softwareX_dedup_byXlangX_byXnameX_name': [(lambda g:g.V().both().has(T.label, 'software').dedup().by('lang').by('name').values('name'))],
+ 'g_V_count_discard': [(lambda g:g.V().count().discard())],
+ 'g_V_hasLabelXpersonX_discard': [(lambda g:g.V().has_label('person').discard())],
+ 'g_VX1X_outXcreatedX_discard': [(lambda g, vid1=None:g.V(vid1).out('created').discard())],
'g_V_discard': [(lambda g:g.V().discard())],
'g_V_discard_discard': [(lambda g:g.V().discard().discard())],
'g_V_discard_fold': [(lambda g:g.V().discard().fold())],
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
index 25e0dadff0..985437847c 100644
--- 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
@@ -15,9 +15,37 @@
# specific language governing permissions and limitations
# under the License.
-@StepClassFilter @StepDiscard
+@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
+
Scenario: g_V_discard
Given the modern graph
And the traversal of