This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch gvalue
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 93be41da5c7605d2aba493755dcd8ad52d1e43b5
Author: Stephen Mallette <[email protected]>
AuthorDate: Tue Aug 27 16:06:14 2024 -0400

    wip - moved all the params out of admin interfaces - not working
---
 .../grammar/TraversalSourceSpawnMethodVisitor.java |   8 +-
 .../traversal/dsl/graph/GraphTraversal.java        | 118 +++++++++++++++++++++
 .../traversal/dsl/graph/GraphTraversalSource.java  |  30 ++++++
 .../gremlin/process/traversal/dsl/graph/__.java    |  63 +++++++++++
 .../traversal/step/sideEffect/InjectStep.java      |   2 +-
 .../traversal/step/map/ConjoinStepTest.java        |   2 +-
 6 files changed, 217 insertions(+), 6 deletions(-)

diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalSourceSpawnMethodVisitor.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalSourceSpawnMethodVisitor.java
index 2758ea429c..02fb654451 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalSourceSpawnMethodVisitor.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalSourceSpawnMethodVisitor.java
@@ -123,7 +123,7 @@ public class TraversalSourceSpawnMethodVisitor extends 
DefaultGremlinBaseVisitor
     public GraphTraversal visitTraversalSourceSpawnMethod_mergeV_Map(final 
GremlinParser.TraversalSourceSpawnMethod_mergeV_MapContext ctx) {
         final Object literalOrVar = 
antlr.argumentVisitor.visitGenericLiteralMapNullableArgument(ctx.genericLiteralMapNullableArgument());
         if (GValue.valueInstanceOf(literalOrVar, GType.MAP))
-            return this.traversalSource.asAdmin().mergeV((GValue) 
literalOrVar);
+            return this.traversalSource.mergeV((GValue) literalOrVar);
         else
             return this.traversalSource.mergeV((Map) literalOrVar);
     }
@@ -151,7 +151,7 @@ public class TraversalSourceSpawnMethodVisitor extends 
DefaultGremlinBaseVisitor
     public GraphTraversal visitTraversalSourceSpawnMethod_mergeE_Map(final 
GremlinParser.TraversalSourceSpawnMethod_mergeE_MapContext ctx) {
         final Object literalOrVar = 
antlr.argumentVisitor.visitGenericLiteralMapNullableArgument(ctx.genericLiteralMapNullableArgument());
         if (GValue.valueInstanceOf(literalOrVar, GType.MAP))
-            return this.traversalSource.asAdmin().mergeE((GValue) 
literalOrVar);
+            return this.traversalSource.mergeE((GValue) literalOrVar);
         else
             return this.traversalSource.mergeE((Map) literalOrVar);
     }
@@ -179,7 +179,7 @@ public class TraversalSourceSpawnMethodVisitor extends 
DefaultGremlinBaseVisitor
     public GraphTraversal 
visitTraversalSourceSpawnMethod_call_string_map(final 
GremlinParser.TraversalSourceSpawnMethod_call_string_mapContext ctx) {
         final Object literalOrVar = 
antlr.argumentVisitor.visitGenericLiteralMapArgument(ctx.genericLiteralMapArgument());
         if (GValue.valueInstanceOf(literalOrVar, GType.MAP))
-            return 
this.traversalSource.asAdmin().call(antlr.argumentVisitor.parseString(ctx.stringArgument()),
 (GValue<Map>) literalOrVar);
+            return 
this.traversalSource.call(antlr.argumentVisitor.parseString(ctx.stringArgument()),
 (GValue<Map>) literalOrVar);
         else
             return 
this.traversalSource.call(antlr.argumentVisitor.parseString(ctx.stringArgument()),
 (Map) literalOrVar);
     }
@@ -200,7 +200,7 @@ public class TraversalSourceSpawnMethodVisitor extends 
DefaultGremlinBaseVisitor
     public GraphTraversal 
visitTraversalSourceSpawnMethod_call_string_map_traversal(final 
GremlinParser.TraversalSourceSpawnMethod_call_string_map_traversalContext ctx) {
         final Object literalOrVar = 
antlr.argumentVisitor.visitGenericLiteralMapArgument(ctx.genericLiteralMapArgument());
         if (GValue.valueInstanceOf(literalOrVar, GType.MAP))
-            return 
this.traversalSource.asAdmin().call(antlr.argumentVisitor.parseString(ctx.stringArgument()),
 (GValue<Map>) literalOrVar, 
anonymousVisitor.visitNestedTraversal(ctx.nestedTraversal()));
+            return 
this.traversalSource.call(antlr.argumentVisitor.parseString(ctx.stringArgument()),
 (GValue<Map>) literalOrVar, 
anonymousVisitor.visitNestedTraversal(ctx.nestedTraversal()));
         else
             return 
this.traversalSource.call(antlr.argumentVisitor.parseString(ctx.stringArgument()),
 (Map) literalOrVar, 
anonymousVisitor.visitNestedTraversal(ctx.nestedTraversal()));
     }
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 5f6825acdc..572c46f52b 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
@@ -1661,6 +1661,21 @@ public interface GraphTraversal<S, E> extends 
Traversal<S, E> {
         return this.asAdmin().addStep(call);
     }
 
+    /**
+     * Perform the specified service call with the specified static parameters.
+     *
+     * @param service the name of the service call
+     * @param params static parameter map (no nested traversals)
+     * @return the traversal with an appended {@link CallStep}.
+     * @see <a 
href="http://tinkerpop.apache.org/docs/${project.version}/reference/#call-step"; 
target="_blank">Reference Documentation - Call Step</a>
+     * @since 4.0.0
+     */
+    default <E> GraphTraversal<S, E> call(final String service, final 
GValue<Map> params) {
+        this.asAdmin().getBytecode().addStep(GraphTraversal.Symbols.call, 
service, params);
+        final CallStep<S,E> call = new CallStep<>(this.asAdmin(), false, 
service, params);
+        return this.asAdmin().addStep(call);
+    }
+
     /**
      * Perform the specified service call with dynamic parameters produced by 
the specified child traversal.
      *
@@ -1696,6 +1711,25 @@ public interface GraphTraversal<S, E> extends 
Traversal<S, E> {
         return this.asAdmin().addStep(step);
     }
 
+    /**
+     * Perform the specified service call with both static and dynamic 
parameters produced by the specified child
+     * traversal. These parameters will be merged at execution time per the 
provider implementation. Reference
+     * implementation merges dynamic into static (dynamic will overwrite 
static).
+     *
+     * @param service the name of the service call
+     * @param params static parameter map (no nested traversals)
+     * @param childTraversal a traversal that will produce a Map of parameters 
for the service call when invoked.
+     * @return the traversal with an appended {@link CallStep}.
+     * @see <a 
href="http://tinkerpop.apache.org/docs/${project.version}/reference/#call-step"; 
target="_blank">Reference Documentation - Call Step</a>
+     * @since 4.0.0
+     */
+    default <E> GraphTraversal<S, E> call(final String service, final 
GValue<Map> params, final Traversal<?, Map<?,?>> childTraversal) {
+        this.asAdmin().getBytecode().addStep(GraphTraversal.Symbols.call, 
service, params, childTraversal);
+        final CallStep<S,E> step = null == childTraversal ? new 
CallStep(this.asAdmin(), false, service, params) :
+                new CallStep(this.asAdmin(), false, service, params, 
childTraversal.asAdmin());
+        return this.asAdmin().addStep(step);
+    }
+
     /**
      * Concatenate values of an arbitrary number of string traversals to the 
incoming traverser.
      *
@@ -2145,6 +2179,18 @@ public interface GraphTraversal<S, E> extends 
Traversal<S, E> {
         return this.asAdmin().addStep(new DifferenceStep<>(this.asAdmin(), 
values));
     }
 
+    /**
+     * Calculates the difference between the list traverser and list argument.
+     *
+     * @return the traversal with an appended {@link DifferenceStep}.
+     * @see <a 
href="http://tinkerpop.apache.org/docs/${project.version}/reference/#difference-step";
 target="_blank">Reference Documentation - Difference Step</a>
+     * @since 4.0.0
+     */
+    public default GraphTraversal<S, Set<?>> difference(final GValue<Object> 
values) {
+        
this.asAdmin().getBytecode().addStep(GraphTraversal.Symbols.difference, values);
+        return this.asAdmin().addStep(new DifferenceStep<>(this.asAdmin(), 
values));
+    }
+
     /**
      * Calculates the disjunction between the list traverser and list argument.
      *
@@ -2157,6 +2203,18 @@ public interface GraphTraversal<S, E> extends 
Traversal<S, E> {
         return this.asAdmin().addStep(new DisjunctStep<>(this.asAdmin(), 
values));
     }
 
+    /**
+     * Calculates the disjunction between the list traverser and list argument.
+     *
+     * @return the traversal with an appended {@link DisjunctStep}.
+     * @see <a 
href="http://tinkerpop.apache.org/docs/${project.version}/reference/#disjunct-step";
 target="_blank">Reference Documentation - Disjunct Step</a>
+     * @since 4.0.0
+     */
+    public default GraphTraversal<S, Set<?>> disjunct(final GValue<Object> 
values) {
+        this.asAdmin().getBytecode().addStep(GraphTraversal.Symbols.disjunct, 
values);
+        return this.asAdmin().addStep(new DisjunctStep<>(this.asAdmin(), 
values));
+    }
+
     /**
      * Calculates the intersection between the list traverser and list 
argument.
      *
@@ -2169,6 +2227,18 @@ public interface GraphTraversal<S, E> extends 
Traversal<S, E> {
         return this.asAdmin().addStep(new IntersectStep<>(this.asAdmin(), 
values));
     }
 
+    /**
+     * Calculates the intersection between the list traverser and list 
argument.
+     *
+     * @return the traversal with an appended {@link IntersectStep}.
+     * @see <a 
href="http://tinkerpop.apache.org/docs/${project.version}/reference/#intersect-step";
 target="_blank">Reference Documentation - Intersect Step</a>
+     * @since 4.0.0
+     */
+    public default GraphTraversal<S, Set<?>> intersect(final GValue<Object> 
values) {
+        this.asAdmin().getBytecode().addStep(GraphTraversal.Symbols.intersect, 
values);
+        return this.asAdmin().addStep(new IntersectStep<>(this.asAdmin(), 
values));
+    }
+
     /**
      * Joins together the elements of the incoming list traverser together 
with the provided delimiter.
      *
@@ -2181,6 +2251,18 @@ public interface GraphTraversal<S, E> extends 
Traversal<S, E> {
         return this.asAdmin().addStep(new ConjoinStep<>(this.asAdmin(), 
delimiter));
     }
 
+    /**
+     * Joins together the elements of the incoming list traverser together 
with the provided delimiter.
+     *
+     * @return the traversal with an appended {@link ConjoinStep}.
+     * @see <a 
href="http://tinkerpop.apache.org/docs/${project.version}/reference/#conjoin-step";
 target="_blank">Reference Documentation - Conjoin Step</a>
+     * @since 4.0.0
+     */
+    public default GraphTraversal<S, String> conjoin(final GValue<String> 
delimiter) {
+        this.asAdmin().getBytecode().addStep(GraphTraversal.Symbols.conjoin, 
delimiter);
+        return this.asAdmin().addStep(new ConjoinStep<>(this.asAdmin(), 
delimiter));
+    }
+
     /**
      * Merges the list traverser and list argument. Also known as union.
      *
@@ -2193,6 +2275,18 @@ public interface GraphTraversal<S, E> extends 
Traversal<S, E> {
         return this.asAdmin().addStep(new MergeStep<>(this.asAdmin(), values));
     }
 
+    /**
+     * Merges the list traverser and list argument. Also known as union.
+     *
+     * @return the traversal with an appended {@link MergeStep}.
+     * @see <a 
href="http://tinkerpop.apache.org/docs/${project.version}/reference/#merge-step";
 target="_blank">Reference Documentation - Merge Step</a>
+     * @since 4.0.0
+     */
+    public default <E2> GraphTraversal<S, E2> merge(final GValue<Object> 
values) {
+        this.asAdmin().getBytecode().addStep(GraphTraversal.Symbols.merge, 
values);
+        return this.asAdmin().addStep(new MergeStep<>(this.asAdmin(), values));
+    }
+
     /**
      * Combines the list traverser and list argument. Also known as 
concatenation or append.
      *
@@ -2205,6 +2299,18 @@ public interface GraphTraversal<S, E> extends 
Traversal<S, E> {
         return this.asAdmin().addStep(new CombineStep<>(this.asAdmin(), 
values));
     }
 
+    /**
+     * Combines the list traverser and list argument. Also known as 
concatenation or append.
+     *
+     * @return the traversal with an appended {@link CombineStep}.
+     * @see <a 
href="http://tinkerpop.apache.org/docs/${project.version}/reference/#combine-step";
 target="_blank">Reference Documentation - Combine Step</a>
+     * @since 4.0.0
+     */
+    public default GraphTraversal<S, List<?>> combine(final GValue<Object> 
values) {
+        this.asAdmin().getBytecode().addStep(GraphTraversal.Symbols.combine, 
values);
+        return this.asAdmin().addStep(new CombineStep<>(this.asAdmin(), 
values));
+    }
+
     /**
      * Calculates the cartesian product between the list traverser and list 
argument.
      *
@@ -2217,6 +2323,18 @@ public interface GraphTraversal<S, E> extends 
Traversal<S, E> {
         return this.asAdmin().addStep(new ProductStep<>(this.asAdmin(), 
values));
     }
 
+    /**
+     * Calculates the cartesian product between the list traverser and list 
argument.
+     *
+     * @return the traversal with an appended {@link ProductStep}.
+     * @see <a 
href="http://tinkerpop.apache.org/docs/${project.version}/reference/#product-step";
 target="_blank">Reference Documentation - Product Step</a>
+     * @since 4.0.0
+     */
+    public default GraphTraversal<S, List<List<?>>> product(final 
GValue<Object> values) {
+        this.asAdmin().getBytecode().addStep(GraphTraversal.Symbols.product, 
values);
+        return this.asAdmin().addStep(new ProductStep<>(this.asAdmin(), 
values));
+    }
+
     ///////////////////// FILTER STEPS /////////////////////
 
     /**
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
index f6292c47de..467d9d7eb4 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
@@ -588,6 +588,36 @@ public class GraphTraversalSource implements 
TraversalSource {
         return traversal.addStep(step);
     }
 
+    /**
+     * Spawns a {@link GraphTraversal} starting with values produced by the 
specified service call with the specified
+     * static parameters.
+     *
+     * @param service the name of the service call
+     * @param params static parameter map (no nested traversals)
+     * @since 4.0.0
+     */
+    public <S> GraphTraversal<S, S> call(final String service, final 
GValue<Map> params) {
+        final GraphTraversalSource clone = GraphTraversalSource.this.clone();
+        clone.bytecode.addStep(GraphTraversal.Symbols.call, service, params);
+        final GraphTraversal.Admin<S, S> traversal = new 
DefaultGraphTraversal<>(clone);
+        return traversal.addStep(new CallStep<>(traversal, true, service, 
params));
+    }
+
+    /**
+     * Spawns a {@link GraphTraversal} starting with values produced by the 
specified service call with the specified
+     * static parameters.
+     *
+     * @param service the name of the service call
+     * @param params static parameter map (no nested traversals)
+     * @since 4.0.0
+     */
+    public <S> GraphTraversal<S, S> call(final String service, final 
GValue<Map> params, final Traversal<S, Map> childTraversal) {
+        final GraphTraversalSource clone = GraphTraversalSource.this.clone();
+        clone.bytecode.addStep(GraphTraversal.Symbols.call, service, params);
+        final GraphTraversal.Admin<S, S> traversal = new 
DefaultGraphTraversal<>(clone);
+        return traversal.addStep(new CallStep<>(traversal, true, service, 
params, childTraversal.asAdmin()));
+    }
+
     /**
      * Merges the results of an arbitrary number of traversals.
      *
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 a72f31289e..59fdf5f605 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
@@ -899,6 +899,13 @@ public class __ {
         return __.<A>start().difference(values);
     }
 
+    /**
+     * @see GraphTraversal#difference(GValue)
+     */
+    public static <A> GraphTraversal<A, Set<?>> difference(final 
GValue<Object> values) {
+        return __.<A>start().difference(values);
+    }
+
     /**
      * @see GraphTraversal#disjunct(Object)
      */
@@ -906,6 +913,13 @@ public class __ {
         return __.<A>start().disjunct(values);
     }
 
+    /**
+     * @see GraphTraversal#disjunct(GValue)
+     */
+    public static <A> GraphTraversal<A, Set<?>> disjunct(final GValue<Object> 
values) {
+        return __.<A>start().disjunct(values);
+    }
+
     /**
      * @see GraphTraversal#intersect(Object)
      */
@@ -913,6 +927,13 @@ public class __ {
         return __.<A>start().intersect(values);
     }
 
+    /**
+     * @see GraphTraversal#intersect(GValue)
+     */
+    public static <A> GraphTraversal<A, Set<?>> intersect(final GValue<Object> 
values) {
+        return __.<A>start().intersect(values);
+    }
+
     /**
      * @see GraphTraversal#conjoin(String)
      */
@@ -920,6 +941,13 @@ public class __ {
         return __.<A>start().conjoin(values);
     }
 
+    /**
+     * @see GraphTraversal#conjoin(GValue)
+     */
+    public static <A> GraphTraversal<A, String> conjoin(final GValue<String> 
values) {
+        return __.<A>start().conjoin(values);
+    }
+
     /**
      * @see GraphTraversal#merge(Object)
      */
@@ -927,6 +955,13 @@ public class __ {
         return __.<A>start().merge(values);
     }
 
+    /**
+     * @see GraphTraversal#merge(GValue)
+     */
+    public static <A, B> GraphTraversal<A, B> merge(final GValue<Object> 
values) {
+        return __.<A>start().merge(values);
+    }
+
     /**
      * @see GraphTraversal#combine(Object)
      */
@@ -934,6 +969,13 @@ public class __ {
         return __.<A>start().combine(values);
     }
 
+    /**
+     * @see GraphTraversal#combine(GValue)
+     */
+    public static <A> GraphTraversal<A, List<?>> combine(final GValue<Object> 
values) {
+        return __.<A>start().combine(values);
+    }
+
     /**
      * @see GraphTraversal#product(Object)
      */
@@ -941,6 +983,13 @@ public class __ {
         return __.<A>start().product(values);
     }
 
+    /**
+     * @see GraphTraversal#product(GValue)
+     */
+    public static <A> GraphTraversal<A, List<List<?>>> product(final 
GValue<Object> values) {
+        return __.<A>start().product(values);
+    }
+
     ///////////////////// FILTER STEPS /////////////////////
 
     /**
@@ -1631,6 +1680,13 @@ public class __ {
         return __.<A>start().call(service, params);
     }
 
+    /**
+     * @see GraphTraversal#call(String, GValue)
+     */
+    public static <A, B> GraphTraversal<A, B> call(final String service, final 
GValue<Map> params) {
+        return __.<A>start().call(service, params);
+    }
+
     /**
      * @see GraphTraversal#call(String, Traversal)
      */
@@ -1644,4 +1700,11 @@ public class __ {
     public static <A, B> GraphTraversal<A, B> call(final String service, final 
Map params, final Traversal<?, Map<?,?>> childTraversal) {
         return __.<A>start().call(service, params, childTraversal);
     }
+
+    /**
+     * @see GraphTraversal#call(String, GValue, Traversal)
+     */
+    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/sideEffect/InjectStep.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/InjectStep.java
index 59e3909b62..73bf40b199 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/InjectStep.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/InjectStep.java
@@ -60,6 +60,6 @@ public final class InjectStep<S> extends StartStep<S> {
      * Gets the injections of the step but unwraps the {@link GValue}.
      */
     public S[] getInjections() {
-        return (S[]) resolveToValues(this.injections);
+        return (S[]) GValue.resolveToValues(this.injections);
     }
 }
diff --git 
a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ConjoinStepTest.java
 
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ConjoinStepTest.java
index a84c691182..35d9fe29f9 100644
--- 
a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ConjoinStepTest.java
+++ 
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ConjoinStepTest.java
@@ -41,7 +41,7 @@ public class ConjoinStepTest extends StepTest {
     @Test
     public void testReturnTypes() {
         try {
-            __.__(Collections.emptyList()).conjoin(null).next();
+            __.__(Collections.emptyList()).conjoin((String) null).next();
             fail();
         } catch (Exception e) {
             assertTrue(e.getMessage().contains("Input delimiter to conjoin 
step can't be null"));

Reply via email to