You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by co...@apache.org on 2024/11/21 23:09:08 UTC
(tinkerpop) branch gvalue-feature-tests updated: cleanup
This is an automated email from the ASF dual-hosted git repository.
colegreer pushed a commit to branch gvalue-feature-tests
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
The following commit(s) were added to refs/heads/gvalue-feature-tests by this push:
new 086886901f cleanup
086886901f is described below
commit 086886901ff0ca73c4ca7db1ae0e3e4546b25e0c
Author: Cole-Greer <Co...@improving.com>
AuthorDate: Thu Nov 21 15:09:01 2024 -0800
cleanup
---
.../language/grammar/TraversalMethodVisitor.java | 12 +++----
.../grammar/TraversalSourceSelfMethodVisitor.java | 2 +-
.../traversal/dsl/graph/GraphTraversal.java | 38 +---------------------
.../gremlin/process/traversal/dsl/graph/__.java | 1 -
.../traversal/step/map/ReplaceGlobalStep.java | 5 ---
.../traversal/step/map/ReplaceLocalStep.java | 5 ---
.../traversal/step/map/ReplaceGlobalStepTest.java | 2 +-
.../traversal/step/map/ReplaceLocalStepTest.java | 2 +-
gremlin-language/src/main/antlr4/Gremlin.g4 | 6 ++--
.../gremlin/test/features/filter/Has.feature | 13 --------
10 files changed, 13 insertions(+), 73 deletions(-)
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 cd3547c068..496c95aefd 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
@@ -91,7 +91,7 @@ public class TraversalMethodVisitor extends TraversalRootVisitor<GraphTraversal>
*/
@Override
public GraphTraversal visitTraversalMethod_addV_String(final GremlinParser.TraversalMethod_addV_StringContext ctx) {
- Object literalOrVar = antlr.argumentVisitor.parseString(ctx.stringArgument());
+ final Object literalOrVar = antlr.argumentVisitor.visitStringArgument(ctx.stringArgument());
if (GValue.valueInstanceOf(literalOrVar, GType.STRING)) {
return this.graphTraversal.addV((GValue<String>) literalOrVar);
} else {
@@ -176,7 +176,7 @@ public class TraversalMethodVisitor extends TraversalRootVisitor<GraphTraversal>
*/
@Override
public GraphTraversal visitTraversalMethod_addE_String(final GremlinParser.TraversalMethod_addE_StringContext ctx) {
- Object literalOrVar = antlr.argumentVisitor.parseString(ctx.stringArgument());
+ final Object literalOrVar = antlr.argumentVisitor.visitStringArgument(ctx.stringArgument());
if (GValue.valueInstanceOf(literalOrVar, GType.STRING)) {
return this.graphTraversal.addE((GValue<String>) literalOrVar);
} else {
@@ -2076,8 +2076,8 @@ public class TraversalMethodVisitor extends TraversalRootVisitor<GraphTraversal>
*/
@Override
public GraphTraversal visitTraversalMethod_replace_String_String(final GremlinParser.TraversalMethod_replace_String_StringContext ctx) {
- return graphTraversal.replace(antlr.argumentVisitor.parseString(ctx.stringNullableArgument(0)),
- antlr.argumentVisitor.parseString(ctx.stringNullableArgument(1)));
+ return graphTraversal.replace(antlr.argumentVisitor.parseString(ctx.stringNullableLiteral(0)),
+ antlr.argumentVisitor.parseString(ctx.stringNullableLiteral(1)));
}
/**
@@ -2086,8 +2086,8 @@ public class TraversalMethodVisitor extends TraversalRootVisitor<GraphTraversal>
@Override
public GraphTraversal visitTraversalMethod_replace_Scope_String_String(final GremlinParser.TraversalMethod_replace_Scope_String_StringContext ctx) {
return graphTraversal.replace(TraversalEnumParser.parseTraversalEnumFromContext(Scope.class, ctx.traversalScope()),
- antlr.argumentVisitor.parseString(ctx.stringNullableArgument(0)),
- antlr.argumentVisitor.parseString(ctx.stringNullableArgument(1)));
+ antlr.argumentVisitor.parseString(ctx.stringNullableLiteral(0)),
+ antlr.argumentVisitor.parseString(ctx.stringNullableLiteral(1)));
}
/**
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalSourceSelfMethodVisitor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalSourceSelfMethodVisitor.java
index b93c4d2c66..a57b9a1da4 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalSourceSelfMethodVisitor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalSourceSelfMethodVisitor.java
@@ -141,7 +141,7 @@ public class TraversalSourceSelfMethodVisitor extends DefaultGremlinBaseVisitor<
return source.with(antlr.argumentVisitor.parseString(ctx.stringLiteral()));
} else {
return source.with(antlr.argumentVisitor.parseString(ctx.stringLiteral()),
- antlr.argumentVisitor.visitGenericLiteral(ctx.genericLiteral()));
+ antlr.argumentVisitor.visitGenericLiteralArgument(ctx.genericLiteralArgument()));
}
}
}
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 62fa282fa6..58101a34a6 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
@@ -2077,42 +2077,6 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
new ReplaceGlobalStep<>(this.asAdmin(), oldChar, newChar) : new ReplaceLocalStep<>(this.asAdmin(), oldChar, newChar));
}
- /**
- * Returns a string with the specified characters in the original string replaced with the new characters. Any null
- * arguments will be a no-op and the original string is returned. Null values from incoming traversers are not
- * processed and remain as null when returned. If the incoming traverser is a non-String value then an
- * {@code IllegalArgumentException} will be thrown.
- *
- * @param newChar the character to replace.
- * @param oldChar the character to be replaced.
- * @return the traversal with an appended {@link ReplaceGlobalStep}.
- * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#replace-step" target="_blank">Reference Documentation - Replace Step</a>
- * @since 3.7.1
- */
- public default GraphTraversal<S, String> replace(final GValue<String> oldChar, final GValue<String> newChar) {
- this.asAdmin().getGremlinLang().addStep(Symbols.replace, oldChar, newChar);
- return this.asAdmin().addStep(new ReplaceGlobalStep<>(this.asAdmin(), oldChar, newChar));
- }
-
- /**
- * Returns a string with the specified characters in the original string replaced with the new characters. Any null
- * arguments will be a no-op and the original string is returned. Null values from incoming traversers are not
- * processed and remain as null when returned. If the incoming traverser is a non-String value then an
- * {@code IllegalArgumentException} will be thrown.
- *
- * @param scope local will operate on individual strings within incoming lists, global will operate on current traversal as a single object.
- * @param newChar the character to replace.
- * @param oldChar the character to be replaced.
- * @return the traversal with an appended {@link ReplaceGlobalStep} or {@link ReplaceLocalStep} depending on the {@link Scope}.
- * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#replace-step" target="_blank">Reference Documentation - Replace Step</a>
- * @since 3.7.1
- */
- public default <E2> GraphTraversal<S, E2> replace(final Scope scope, final GValue<String> oldChar, final GValue<String> newChar) {
- this.asAdmin().getGremlinLang().addStep(Symbols.replace, scope, oldChar, newChar);
- return this.asAdmin().addStep(scope.equals(Scope.global) ?
- new ReplaceGlobalStep<>(this.asAdmin(), oldChar, newChar) : new ReplaceLocalStep<>(this.asAdmin(), oldChar, newChar));
- }
-
/**
* Returns a list of strings created by splitting the incoming string traverser around the matches of the given separator.
* A null separator will split the string by whitespaces. Null values from incoming traversers are not processed
@@ -2811,7 +2775,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
* @param predicate the filter to apply to the key's value
* @return the traversal with an appended {@link HasStep}
* @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a>
- * @since 3.0.0-incubating
+ * @since 4.0.0
*/
public default GraphTraversal<S, E> has(final GValue<String> label, final String propertyKey, final P<?> predicate) {
this.asAdmin().getGremlinLang().addStep(Symbols.has, label.get(), propertyKey, predicate);
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 7075295033..5d24f70d44 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
@@ -1763,5 +1763,4 @@ public class __ {
public static <A, B> GraphTraversal<A, B> call(final String service, final GValue<Map> params, final Traversal<?, Map<?,?>> childTraversal) {
return __.<A>start().call(service, params, childTraversal);
}
-
}
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReplaceGlobalStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReplaceGlobalStep.java
index c3b349c550..8e13aaf010 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReplaceGlobalStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReplaceGlobalStep.java
@@ -21,7 +21,6 @@ package org.apache.tinkerpop.gremlin.process.traversal.step.map;
import org.apache.commons.lang3.StringUtils;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.step.GValue;
import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
@@ -48,10 +47,6 @@ public final class ReplaceGlobalStep<S, E> extends ScalarMapStep<S, E> {
this.newChar=newChar;
}
- public ReplaceGlobalStep(final Traversal.Admin traversal, final GValue<String> oldChar, final GValue<String> newChar ) {
- this(traversal, oldChar.get(), newChar.get());
- }
-
@Override
protected E map(final Traverser.Admin<S> traverser) {
final S item = traverser.get();
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReplaceLocalStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReplaceLocalStep.java
index 5fde99ddb6..6d5a615271 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReplaceLocalStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReplaceLocalStep.java
@@ -21,7 +21,6 @@ package org.apache.tinkerpop.gremlin.process.traversal.step.map;
import org.apache.commons.lang3.StringUtils;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.step.GValue;
import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.StringLocalStep;
import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
@@ -49,10 +48,6 @@ public final class ReplaceLocalStep<S, E> extends StringLocalStep<S, E> {
this.newChar=newChar;
}
- public ReplaceLocalStep(final Traversal.Admin traversal, final GValue<String> oldChar, final GValue<String> newChar ) {
- this(traversal, oldChar.get(), newChar.get());
- }
-
@Override
protected E applyStringOperation(String item) {
return (E) StringUtils.replace(item, this.oldChar, this.newChar);
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReplaceGlobalStepTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReplaceGlobalStepTest.java
index fa8b0189cb..1b1216fbee 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReplaceGlobalStepTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReplaceGlobalStepTest.java
@@ -47,7 +47,7 @@ public class ReplaceGlobalStepTest extends StepTest {
assertEquals("hello", __.__("hello").replace(null, "a").next());
assertEquals("hello", __.__("hello").replace("el", null).next());
- assertEquals("hello", __.__("hello").replace((String) null, null).next());
+ assertEquals("hello", __.__("hello").replace(null, null).next());
assertArrayEquals(new String[]{"hell0", "w0rld", null, ""},
__.__("hello", "world", null, "").replace("o", "0").toList().toArray());
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReplaceLocalStepTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReplaceLocalStepTest.java
index d4343920e2..2b5c7d87d5 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReplaceLocalStepTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReplaceLocalStepTest.java
@@ -44,7 +44,7 @@ public class ReplaceLocalStepTest extends StepTest {
assertEquals("hello", __.__("hello").replace(Scope.local, null, "a").next());
assertEquals("hello", __.__("hello").replace(Scope.local, "el", null).next());
- assertEquals("hello", __.__("hello").replace(Scope.local, (String) null, null).next());
+ assertEquals("hello", __.__("hello").replace(Scope.local, null, null).next());
assertArrayEquals(new String[]{"hell0", "w0rld", null, ""},
((List<?>) __.__(Arrays.asList("hello", "world", null, "")).replace(Scope.local, "o", "0").next()).toArray());
diff --git a/gremlin-language/src/main/antlr4/Gremlin.g4 b/gremlin-language/src/main/antlr4/Gremlin.g4
index 7162fe8e4c..06f42f5fc3 100644
--- a/gremlin-language/src/main/antlr4/Gremlin.g4
+++ b/gremlin-language/src/main/antlr4/Gremlin.g4
@@ -95,7 +95,7 @@ traversalSourceSelfMethod_withoutStrategies
traversalSourceSelfMethod_with
: 'with' LPAREN stringLiteral RPAREN
- | 'with' LPAREN stringLiteral COMMA genericLiteral RPAREN
+ | 'with' LPAREN stringLiteral COMMA genericLiteralArgument RPAREN
;
traversalSourceSpawnMethod
@@ -924,8 +924,8 @@ traversalMethod_rTrim
;
traversalMethod_replace
- : 'replace' LPAREN stringNullableArgument COMMA stringNullableArgument RPAREN #traversalMethod_replace_String_String
- | 'replace' LPAREN traversalScope COMMA stringNullableArgument COMMA stringNullableArgument RPAREN #traversalMethod_replace_Scope_String_String
+ : 'replace' LPAREN stringNullableLiteral COMMA stringNullableLiteral RPAREN #traversalMethod_replace_String_String
+ | 'replace' LPAREN traversalScope COMMA stringNullableLiteral COMMA stringNullableLiteral RPAREN #traversalMethod_replace_Scope_String_String
;
traversalMethod_split
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Has.feature b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Has.feature
index b7fb1173cf..42059bccdb 100644
--- a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Has.feature
+++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Has.feature
@@ -42,19 +42,6 @@ Feature: Step - has()
| result |
| v[marko] |
-# Scenario: g_VX1X_hasXnamevarX
-# Given the modern graph
-# And using the parameter vid1 defined as "v[marko].id"
-# And using the parameter xx1 defined as "name"
-# And the traversal of
-# """
-# g.V(vid1).has(xx1)
-# """
-# When iterated to list
-# Then the result should be unordered
-# | result |
-# | v[marko] |
-
Scenario: g_VX1X_hasXcircumferenceX
Given the modern graph
And using the parameter vid1 defined as "v[marko].id"