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 2025/06/20 00:33:13 UTC
(tinkerpop) 01/01: Updates for TP4
This is an automated email from the ASF dual-hosted git repository.
colegreer pushed a commit to branch grammar_vertex_master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit ce1a5fcec7b070b584ab0f29f72915e9d4e272a3
Merge: 1e6dd6b8a7 9f429b8554
Author: Cole-Greer <Co...@improving.com>
AuthorDate: Thu Jun 19 09:20:05 2025 -0700
Updates for TP4
Treat vertex in GraphTraversal as sugar, convert to id in GremlinLang.
CHANGELOG.asciidoc | 1 +
docs/src/upgrade/release-3.8.x.asciidoc | 33 +++++++-
.../gremlin/language/grammar/ArgumentVisitor.java | 16 ----
.../grammar/DefaultGremlinBaseVisitor.java | 19 ++---
.../language/grammar/GenericLiteralVisitor.java | 5 --
.../language/grammar/GremlinAntlrToJava.java | 6 --
.../language/grammar/StructureElementVisitor.java | 38 ---------
.../language/grammar/TraversalMethodVisitor.java | 40 ++++-----
.../language/translator/GoTranslateVisitor.java | 10 ---
.../translator/GroovyTranslateVisitor.java | 12 ---
.../language/translator/JavaTranslateVisitor.java | 12 ---
.../translator/JavascriptTranslateVisitor.java | 10 ---
.../translator/PythonTranslateVisitor.java | 10 ---
.../gremlin/process/traversal/GremlinLang.java | 2 +-
.../traversal/dsl/graph/GraphTraversal.java | 98 ++++++++++++++++++----
.../traversal/step/map/AddEdgeStartStep.java | 47 +++++++----
.../process/traversal/step/map/AddEdgeStep.java | 47 +++++++----
.../language/grammar/ArgumentVisitorTest.java | 8 --
.../grammar/StructureElementVisitorTest.java | 48 -----------
.../language/translator/GremlinTranslatorTest.java | 9 --
.../gremlin/process/traversal/GremlinLangTest.java | 2 +-
.../Process/Traversal/GraphTraversal.cs | 37 +++++++-
.../Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs | 36 ++++----
gremlin-go/driver/cucumber/gremlin.go | 36 ++++----
.../gremlin-javascript/test/cucumber/gremlin.js | 36 ++++----
gremlin-language/src/main/antlr4/Gremlin.g4 | 22 +----
.../language/corpus/DocumentationReader.java | 4 +-
.../src/test/resources/gremlin-values.txt | 5 --
.../src/test/resources/incorrect-traversals.txt | 1 -
.../python/gremlin_python/process/traversal.py | 2 +-
gremlin-python/src/main/python/radish/gremlin.py | 36 ++++----
.../tests/driver/test_driver_remote_connection.py | 4 +-
.../main/python/tests/process/test_gremlin_lang.py | 2 +-
.../process/traversal/step/filter/WhereTest.java | 11 +--
.../traversal/step/sideEffect/InjectTest.java | 38 ---------
.../gremlin/test/features/branch/Union.feature | 10 +--
.../gremlin/test/features/filter/Has.feature | 12 +--
.../gremlin/test/features/filter/Where.feature | 4 +-
.../gremlin/test/features/map/AddEdge.feature | 72 ++++++++--------
.../gremlin/test/features/map/Element.feature | 12 +--
.../gremlin/test/features/map/Math.feature | 4 +-
.../gremlin/test/features/map/MergeEdge.feature | 60 ++++++-------
.../gremlin/test/features/map/Vertex.feature | 8 +-
.../test/features/sideEffect/Inject.feature | 35 --------
.../tinkergraph/structure/TinkerGraphTest.java | 12 +--
45 files changed, 424 insertions(+), 548 deletions(-)
diff --cc gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/DefaultGremlinBaseVisitor.java
index 87c0a328b6,37752152ff..8648e21659
--- 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
@@@ -414,11 -410,11 +414,14 @@@ public class DefaultGremlinBaseVisitor<
/**
* {@inheritDoc}
*/
- @Override public T visitTraversalMethod_from_Vertex(final GremlinParser.TraversalMethod_from_VertexContext ctx) { notImplemented(ctx); return null; }
- @Override public T visitTraversalMethod_from_Traversal(final GremlinParser.TraversalMethod_from_TraversalContext ctx) { notImplemented(ctx); return null; }
++ @Override public T visitTraversalMethod_from_GenricArgument(GremlinParser.TraversalMethod_from_GenricArgumentContext ctx) { return null; }
/**
* {@inheritDoc}
*/
- @Override public T visitTraversalMethod_from_Traversal(final GremlinParser.TraversalMethod_from_TraversalContext ctx) { notImplemented(ctx); return null; }
- @Override public T visitTraversalMethod_from_GenricArgument(GremlinParser.TraversalMethod_from_GenricArgumentContext ctx) { return null; }
++ @Override
++ public T visitTraversalMethod_from_Traversal(GremlinParser.TraversalMethod_from_TraversalContext ctx) {
++ return null;
++ }
/**
* {@inheritDoc}
*/
diff --cc gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/GremlinAntlrToJava.java
index 2c70def067,ab6dbccb0a..bb50b327b8
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/GremlinAntlrToJava.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/GremlinAntlrToJava.java
@@@ -99,14 -99,9 +99,9 @@@ public class GremlinAntlrToJava extend
*/
final TraversalPredicateVisitor traversalPredicateVisitor;
- /**
- * Parses structure instances like {@link Vertex}.
- */
- final StructureElementVisitor structureVisitor;
-
/**
* Constructs a new instance and is bound to an {@link EmptyGraph}. This form of construction is helpful for
- * generating {@link Bytecode} or for various forms of testing. {@link Traversal} instances constructed from this
+ * generating {@link GremlinLang} or for various forms of testing. {@link Traversal} instances constructed from this
* form will not be capable of iterating. Assumes that "g" is the name of the {@link GraphTraversalSource}.
*/
public GremlinAntlrToJava() {
diff --cc gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/GremlinLang.java
index 8d1e5de5d9,0000000000..54038e925a
mode 100644,000000..100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/GremlinLang.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/GremlinLang.java
@@@ -1,516 -1,0 +1,516 @@@
+/*
+ * 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;
+
+import org.apache.commons.configuration2.Configuration;
+import org.apache.commons.text.StringEscapeUtils;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.step.GValue;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.TraversalStrategyProxy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.OptionsStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP;
+import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal;
+import org.apache.tinkerpop.gremlin.structure.Column;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.util.NumberHelper;
+
+import javax.lang.model.SourceVersion;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.time.OffsetDateTime;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.apache.tinkerpop.gremlin.util.DatetimeHelper.format;
+import static org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils.asIterator;
+
+/**
+ * This class helps to build a gremlin-lang compatible string representation based on a {@link TraversalSource}
+ * and then a {@link Traversal}.
+ */
+public class GremlinLang implements Cloneable, Serializable {
+
+ private static final Object[] EMPTY_ARRAY = new Object[]{};
+
+ private StringBuilder gremlin = new StringBuilder();
+ private Map<String, Object> parameters = new HashMap<>();
+ private static final AtomicInteger paramCount = new AtomicInteger(0);
+ private List<OptionsStrategy> optionsStrategies = new ArrayList<>();
+
+ public GremlinLang() {
+ }
+
+ public GremlinLang(final String sourceName, final Object... arguments) {
+ addToGremlin(sourceName, arguments);
+ }
+
+ private void addToGremlin(final String name, final Object... arguments) {
+ final Object[] flattenedArguments = flattenArguments(arguments);
+
+ // todo: figure out solution for AbstractLambdaTraversal
+ if ("CardinalityValueTraversal".equals(name)) {
+ gremlin.append("Cardinality.").append(flattenedArguments[0])
+ .append("(").append(flattenedArguments[1]).append(")");
+ return;
+ }
+
+ gremlin.append(".").append(name).append('(');
+
+ for (int i = 0; i < flattenedArguments.length; i++) {
+ if (i != 0) {
+ gremlin.append(',');
+ }
+ gremlin.append(argAsString(flattenedArguments[i]));
+ }
+
+ gremlin.append(')');
+ }
+
+ private String argAsString(final Object arg) {
+ if (arg == null)
+ return "null";
+
+ if (arg instanceof String)
+ return String.format("\"%s\"", StringEscapeUtils.escapeJava((String) arg));
+ if (arg instanceof Boolean)
+ return arg.toString();
+
+ if (arg instanceof Byte)
+ return String.format("%sB", arg);
+ if (arg instanceof Short)
+ return String.format("%sS", arg);
+ if (arg instanceof Integer)
+ return arg.toString();
+ if (arg instanceof Long)
+ return String.format("%sL", arg);
+
+ if (arg instanceof BigInteger)
+ return String.format("%sN", arg);
+ if (arg instanceof Float) {
+ if (NumberHelper.isNaN(arg))
+ return "NaN";
+ if (NumberHelper.isPositiveInfinity(arg))
+ return "+Infinity";
+ if (NumberHelper.isNegativeInfinity(arg))
+ return "-Infinity";
+
+ return String.format("%sF", arg);
+ }
+ if (arg instanceof Double) {
+ if (NumberHelper.isNaN(arg))
+ return "NaN";
+ if (NumberHelper.isPositiveInfinity(arg))
+ return "+Infinity";
+ if (NumberHelper.isNegativeInfinity(arg))
+ return "-Infinity";
+ return String.format("%sD", arg);
+ }
+ if (arg instanceof BigDecimal)
+ return String.format("%sM", arg);
+
+ if (arg instanceof OffsetDateTime)
+ return String.format("datetime(\"%s\")", format(((OffsetDateTime) arg).toInstant()));
+
+ if (arg instanceof Enum) {
+ // special handling for enums with additional interfaces
+ if (arg instanceof T)
+ return String.format("T.%s", arg);
+ if (arg instanceof Order)
+ return String.format("Order.%s", arg);
+ if (arg instanceof Column)
+ return String.format("Column.%s", arg);
+ if (arg instanceof Operator)
+ return String.format("Operator.%s", arg);
+ if (arg instanceof SackFunctions.Barrier)
+ return String.format("Barrier.%s", arg);
+
+ return String.format("%s.%s", arg.getClass().getSimpleName(), arg);
+ }
+
+ if (arg instanceof Vertex)
- return String.format("new ReferenceVertex(%s,\"%s\")", argAsString(((Vertex) arg).id()), ((Vertex) arg).label());
++ return argAsString(((Vertex) arg).id());
+
+ if (arg instanceof P) {
+ return asString((P<?>) arg);
+ }
+
+ if (arg instanceof GremlinLang || arg instanceof DefaultTraversal) {
+ final GremlinLang gremlinLang = arg instanceof GremlinLang ? (GremlinLang) arg : ((DefaultTraversal) arg).getGremlinLang();
+ parameters.putAll(gremlinLang.getParameters());
+ return gremlinLang.getGremlin("__");
+ }
+
+ if (arg instanceof GValue) {
+ final GValue gValue = (GValue) arg;
+ String key = gValue.getName();
+
+ if (key == null) {
+ return argAsString(((GValue<?>) arg).get());
+ }
+
+ if (!SourceVersion.isIdentifier(key)) {
+ throw new IllegalArgumentException(String.format("Invalid parameter name [%s].", key));
+ }
+
+ if (parameters.containsKey(key)) {
+ if (!Objects.equals(parameters.get(key), gValue.get())) {
+ throw new IllegalArgumentException(String.format("Parameter with name [%s] already defined.", key));
+ }
+ } else {
+ parameters.put(key, gValue.get());
+ }
+ return key;
+ }
+
+ if (arg instanceof Map) {
+ return asString((Map) arg);
+ }
+
+ if (arg instanceof Set) {
+ return asString((Set) arg);
+ }
+
+ // handle all iterables in similar way
+ if (arg instanceof List || arg instanceof Object[] || arg.getClass().isArray()) {
+ return asString(asIterator(arg));
+ }
+
+ if (arg instanceof Class) {
+ return ((Class) arg).getSimpleName();
+ }
+
+ return asParameter(arg);
+ }
+
+ private String asParameter(final Object arg) {
+ final String paramName = String.format("_%d", paramCount.getAndIncrement());
+ // todo: consider resetting paramCount when it's larger then 1_000_000
+ parameters.put(paramName, arg);
+ return paramName;
+ }
+
+ private String asString(final Iterator itty) {
+ final StringBuilder sb = new StringBuilder().append("[");
+
+ while (itty.hasNext()) {
+ sb.append(argAsString(itty.next()));
+ if (itty.hasNext())
+ sb.append(",");
+ }
+
+ return sb.append("]").toString();
+ }
+
+ private String asString(final Set<?> set) {
+ final StringBuilder sb = new StringBuilder().append("{");
+
+ final Iterator itty = asIterator(set);
+
+ while (itty.hasNext()) {
+ sb.append(argAsString(itty.next()));
+ if (itty.hasNext())
+ sb.append(",");
+ }
+
+ return sb.append("}").toString();
+ }
+
+ // borrowed from Groovy translator
+ private String asString(final P<?> p) {
+ final StringBuilder sb = new StringBuilder();
+ if (p instanceof TextP) {
+ sb.append("TextP.").append(p.getPredicateName()).append("(");
+ sb.append(argAsString(p.getValue()));
+ } else if (p instanceof ConnectiveP) {
+ // ConnectiveP gets some special handling because it's reduced to and(P, P, P) and we want it
+ // generated the way it was written which was P.and(P).and(P)
+ final List<P<?>> list = ((ConnectiveP) p).getPredicates();
+ final String connector = p.getPredicateName();
+ for (int i = 0; i < list.size(); i++) {
+ sb.append(argAsString(list.get(i)));
+
+ // for the first/last P there is no parent to close
+ if (i > 0 && i < list.size() - 1) sb.append(")");
+
+ // add teh connector for all but last P
+ if (i < list.size() - 1) {
+ sb.append(".").append(connector).append("(");
+ }
+ }
+ } else {
+ sb.append("P.").append(p.getPredicateName()).append("(");
+ sb.append(argAsString(p.getValue()));
+ }
+ sb.append(")");
+ return sb.toString();
+ }
+
+ private String asString(final Map<?, ?> map) {
+ final StringBuilder sb = new StringBuilder("[");
+ int size = map.size();
+
+ if (size == 0) {
+ sb.append(":");
+ } else {
+ for (Map.Entry<?, ?> entry : map.entrySet()) {
+ String key = argAsString(entry.getKey());
+ // special handling for non-string keys
+ if (entry.getKey() instanceof Enum && key.contains(".")) {
+ key = String.format("(%s)", key);
+ }
+
+ sb.append(key).append(":").append(argAsString(entry.getValue()));
+ if (--size > 0) {
+ sb.append(',');
+ }
+ }
+ }
+
+ sb.append("]");
+ return sb.toString();
+ }
+
+ /**
+ * Get gremlin-lang compatible representation of Traversal
+ * @return gremlin-lang compatible String
+ */
+ public String getGremlin() {
+ return getGremlin("g");
+ }
+
+ /**
+ * Get gremlin-lang compatible representation of Traversal.
+ * "g" is expected for gremlin-lang.
+ * "__" can be used for an anonymous {@link GraphTraversal}.
+ *
+ * @param g GraphTraversalSource name
+ * @return gremlin-lang compatible String
+ */
+ public String getGremlin(final String g) {
+ // special handling for CardinalityValueTraversal
+ if (gremlin.length() != 0 && gremlin.charAt(0) != '.') {
+ return gremlin.toString();
+ }
+ return g + gremlin;
+ }
+
+ /**
+ * Get parameters used in Traversal.
+ *
+ * @return parameters Map
+ */
+ public Map<String, Object> getParameters() {
+ return parameters;
+ }
+
+ /**
+ * The alias to set.
+ */
+ public void addG(final String g) {
+ parameters.put("g", g);
+ }
+
+ /**
+ * Reset parameter naming counter. Mainly intended to make testing easier
+ */
+ public void reset() {
+ paramCount.set(0);
+ }
+
+ /**
+ * Add a {@link TraversalSource} instruction to the GremlinLang.
+ *
+ * @param sourceName the traversal source method name (e.g. withSack())
+ * @param arguments the traversal source method arguments
+ */
+ public void addSource(final String sourceName, final Object... arguments) {
+ if (sourceName.equals(TraversalSource.Symbols.withStrategies) && arguments.length != 0) {
+ final String args = buildStrategyArgs(arguments);
+
+ // possible to have empty strategies list to send
+ if (!args.isEmpty()) {
+ gremlin.append('.').append(TraversalSource.Symbols.withStrategies).append('(').append(args).append(')');
+ }
+ return;
+ }
+
+ addToGremlin(sourceName, arguments);
+ }
+
+ private String buildStrategyArgs(final Object[] arguments) {
+ final StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < arguments.length; i++) {
+ // special handling for OptionsStrategy
+ if (arguments[i] instanceof OptionsStrategy) {
+ optionsStrategies.add((OptionsStrategy) arguments[i]);
+ break;
+ }
+
+ Configuration configuration;
+ String strategyName;
+
+ // special handling for TraversalStrategyProxy
+ if (arguments[i] instanceof TraversalStrategyProxy) {
+ configuration = ((TraversalStrategy) arguments[i]).getConfiguration();
+ strategyName = ((TraversalStrategyProxy) arguments[i]).getStrategyName();
+ } else {
+ configuration = ((TraversalStrategy) arguments[i]).getConfiguration();
+ strategyName = arguments[i].getClass().getSimpleName();
+ }
+
+ if (configuration.isEmpty()) {
+ sb.append(strategyName);
+ } else {
+ sb.append("new ")
+ .append(strategyName)
+ .append("(");
+
+ configuration.getKeys().forEachRemaining(key -> {
+ if (!key.equals("strategy")) {
+ sb.append(key).append(":").append(argAsString(configuration.getProperty(key))).append(",");
+ }
+ });
+ // remove last comma
+ if (sb.lastIndexOf(",") == sb.length() - 1) {
+ sb.setLength(sb.length() - 1);
+ }
+
+ sb.append(')');
+ }
+
+ if (i != arguments.length - 1)
+ sb.append(',');
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * Add a {@link Traversal} instruction to the GremlinLang.
+ *
+ * @param stepName the traversal method name (e.g. out())
+ * @param arguments the traversal method arguments
+ */
+ public void addStep(final String stepName, final Object... arguments) {
+ addToGremlin(stepName, arguments);
+ }
+
+ /**
+ * Provides a way to get configuration of a Traversal.
+ *
+ * @return list of OptionsStrategy
+ */
+ public List<OptionsStrategy> getOptionsStrategies() {
+ return optionsStrategies;
+ }
+
+ public boolean isEmpty() {
+ return this.gremlin.length() == 0;
+ }
+
+ @Override
+ public String toString() {
+ return gremlin.toString();
+ }
+
+ // todo: clarify equality with parameters
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ final GremlinLang gremlinLang = (GremlinLang) o;
+ return Objects.equals(gremlin.toString(), gremlinLang.gremlin.toString()) &&
+ Objects.equals(parameters, gremlinLang.parameters);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(gremlin, parameters);
+ }
+
+ @Override
+ public GremlinLang clone() {
+ try {
+ final GremlinLang clone = (GremlinLang) super.clone();
+ clone.parameters = new HashMap<>(parameters);
+ clone.gremlin = new StringBuilder(gremlin.length());
+ clone.gremlin.append(gremlin);
+ clone.optionsStrategies = new ArrayList<>(this.optionsStrategies);
+ return clone;
+ } catch (final CloneNotSupportedException e) {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+ }
+
+ private Object[] flattenArguments(final Object... arguments) {
+ if (arguments == null || arguments.length == 0)
+ return EMPTY_ARRAY;
+ final List<Object> flatArguments = new ArrayList<>(arguments.length);
+ for (final Object object : arguments) {
+ if (object instanceof Object[]) {
+ for (final Object nestObject : (Object[]) object) {
+ flatArguments.add(convertArgument(nestObject));
+ }
+ } else
+ flatArguments.add(convertArgument(object));
+ }
+ return flatArguments.toArray();
+ }
+
+ private Object convertArgument(final Object argument) {
+ if (argument instanceof Traversal) {
+ // prevent use of "g" to spawn child traversals
+ if (((Traversal) argument).asAdmin().getTraversalSource().isPresent())
+ throw new IllegalStateException(String.format(
+ "The child traversal of %s was not spawned anonymously - use the __ class rather than a TraversalSource to construct the child traversal", argument));
+
+ return ((Traversal) argument).asAdmin().getGremlinLang();
+ } else if (argument instanceof Map) {
+ final Map<Object, Object> map = new LinkedHashMap<>(((Map) argument).size());
+ for (final Map.Entry<?, ?> entry : ((Map<?, ?>) argument).entrySet()) {
+ map.put(convertArgument(entry.getKey()), convertArgument(entry.getValue()));
+ }
+ return map;
+ } else if (argument instanceof List) {
+ final List<Object> list = new ArrayList<>(((List) argument).size());
+ for (final Object item : (List) argument) {
+ list.add(convertArgument(item));
+ }
+ return list;
+ } else if (argument instanceof Set) {
+ final Set<Object> set = new LinkedHashSet<>(((Set) argument).size());
+ for (final Object item : (Set) argument) {
+ set.add(convertArgument(item));
+ }
+ return set;
+ } else
+ return argument;
+ }
+}
diff --cc gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index 0b7294b389,041888cb22..95663a0f8f
--- 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
@@@ -387,7 -367,7 +387,13 @@@ public interface GraphTraversal<S, E> e
public default GraphTraversal<S, Vertex> V(final Object... vertexIdsOrElements) {
// a single null is [null]
final Object[] ids = null == vertexIdsOrElements ? new Object[] { null } : vertexIdsOrElements;
- this.asAdmin().getBytecode().addStep(Symbols.V, ids);
++ // convert any vertices to ids
++ for (int i = 0; i < ids.length; i++) {
++ if (ids[i] instanceof Vertex) {
++ ids[i] = ((Vertex) ids[i]).id();
++ }
++ }
+ this.asAdmin().getGremlinLang().addStep(Symbols.V, ids);
return this.asAdmin().addStep(new GraphStep<>(this.asAdmin(), Vertex.class, false, ids));
}
@@@ -402,7 -382,7 +408,13 @@@
public default GraphTraversal<S, Edge> E(final Object... edgeIdsOrElements) {
// a single null is [null]
final Object[] ids = null == edgeIdsOrElements ? new Object[] { null } : edgeIdsOrElements;
- this.asAdmin().getBytecode().addStep(Symbols.E, ids);
++ // convert any vertices to ids
++ for (int i = 0; i < ids.length; i++) {
++ if (ids[i] instanceof Edge) {
++ ids[i] = ((Edge) ids[i]).id();
++ }
++ }
+ this.asAdmin().getGremlinLang().addStep(Symbols.E, ids);
return this.asAdmin().addStep(new GraphStep<>(this.asAdmin(), Edge.class, false, ids));
}
@@@ -1455,7 -1200,7 +1467,16 @@@
*/
public default GraphTraversal<S, Edge> mergeE(final Map<Object, Object> searchCreate) {
// get a construction time exception if the Map is bad
- this.asAdmin().getBytecode().addStep(Symbols.mergeE, searchCreate);
++
++ // Replace any vertices with ids for purposes of GremlinLang
++ if (searchCreate != null && searchCreate.get(Direction.OUT) instanceof Vertex) {
++ searchCreate.put(Direction.OUT, ((Vertex) searchCreate.get(Direction.OUT)).id());
++ }
++ if (searchCreate != null && searchCreate.get(Direction.IN) instanceof Vertex) {
++ searchCreate.put(Direction.IN, ((Vertex) searchCreate.get(Direction.IN)).id());
++ }
+ this.asAdmin().getGremlinLang().addStep(Symbols.mergeE, searchCreate);
++
final MergeEdgeStep<S> step = new MergeEdgeStep(this.asAdmin(), false, searchCreate);
return this.asAdmin().addStep(step);
}
@@@ -1475,20 -1220,6 +1496,32 @@@
return this.asAdmin().addStep(step);
}
+ /**
+ * Spawns a {@link GraphTraversal} by doing a merge (i.e. upsert) style operation for an {@link Edge} using a
+ * {@code Map} as an argument.
+ *
+ * @param searchCreate This {@code Map} can have a key of {@link T} {@link Direction} or a {@code String}.
+ * @since 4.0.0
+ */
+ public default GraphTraversal<S, Edge> mergeE(final GValue<Map<Object, Object>> searchCreate) {
+ // get a construction time exception if the Map is bad
++
++ // Replace any vertices with ids for purposes of GremlinLang
++ if (searchCreate != null && !searchCreate.isNull()) {
++ Map<Object, Object> searchCreateMap = searchCreate.get();
++ if (searchCreateMap != null && searchCreateMap.get(Direction.OUT) instanceof Vertex) {
++ searchCreateMap.put(Direction.OUT, ((Vertex) searchCreateMap.get(Direction.OUT)).id());
++ }
++ if (searchCreateMap != null && searchCreateMap.get(Direction.IN) instanceof Vertex) {
++ searchCreateMap.put(Direction.IN, ((Vertex) searchCreateMap.get(Direction.IN)).id());
++ }
++ }
++
+ this.asAdmin().getGremlinLang().addStep(GraphTraversal.Symbols.mergeE, searchCreate);
+ final MergeEdgeStep<S> step = new MergeEdgeStep(this.asAdmin(), false, null == searchCreate ? GValue.ofMap(null, null) : searchCreate);
+ return this.asAdmin().addStep(step);
+ }
+
/**
* Adds an {@link Edge} with the specified edge label.
*
@@@ -1515,28 -1246,14 +1548,28 @@@
}
/**
- * Provide {@code to()}-modulation to respective steps.
+ * Adds an {@link Edge} with the specified edge label.
*
- * @param toStepLabel the step label to modulate to.
- * @return the traversal with the modified {@link FromToModulating} step.
- * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#to-step" target="_blank">Reference Documentation - To Step</a>
+ * @param edgeLabel the label of the newly added edge
+ * @return the traversal with the {@link AddEdgeStep} added
+ * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step" target="_blank">Reference Documentation - AddEdge Step</a>
+ * @since 4.0.0
+ */
+ public default GraphTraversal<S, Edge> addE(final GValue<String> edgeLabel) {
+ this.asAdmin().getGremlinLang().addStep(GraphTraversal.Symbols.addE, edgeLabel);
+ return this.asAdmin().addStep(new AddEdgeStep<>(this.asAdmin(), edgeLabel));
+ }
+
+ /**
+ * When used as a modifier to {@link #addE(String)} this method specifies the traversal to use for selecting the
+ * outgoing vertex of the newly added {@link Edge}.
+ *
+ * @param fromVertex the traversal for selecting the outgoing vertex
+ * @return the traversal with the modified {@link AddEdgeStep}
+ * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step" target="_blank">Reference Documentation - From Step</a>
* @since 3.1.0-incubating
*/
- public default GraphTraversal<S, E> from(final Traversal<?, Vertex> fromVertex) {
- public default GraphTraversal<S, E> to(final String toStepLabel) {
++ public default GraphTraversal<S, E> from(final Traversal<?, Object> fromVertex) {
final Step<?,?> prev = this.asAdmin().getEndStep();
if (!(prev instanceof FromToModulating))
throw new IllegalArgumentException(String.format(
@@@ -1568,21 -1285,21 +1601,29 @@@
/**
* When used as a modifier to {@link #addE(String)} this method specifies the traversal to use for selecting the
- * incoming vertex of the newly added {@link Edge}.
+ * outgoing vertex of the newly added {@link Edge}.
*
- * @param toVertex the traversal for selecting the incoming vertex
+ * @param fromVertex the vertex for selecting the outgoing vertex
* @return the traversal with the modified {@link AddEdgeStep}
* @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step" target="_blank">Reference Documentation - From Step</a>
- * @since 3.1.0-incubating
+ * @since 4.0.0
*/
- public default GraphTraversal<S, E> from(final GValue<Vertex> fromVertex) {
- public default GraphTraversal<S, E> to(final Traversal<?, Object> toVertex) {
++ public default GraphTraversal<S, E> from(final GValue<Object> fromVertexOrId) {
final Step<?,?> prev = this.asAdmin().getEndStep();
if (!(prev instanceof FromToModulating))
throw new IllegalArgumentException(String.format(
- "The to() step cannot follow %s", prev.getClass().getSimpleName()));
+ "The from() step cannot follow %s", prev.getClass().getSimpleName()));
- this.asAdmin().getGremlinLang().addStep(GraphTraversal.Symbols.from, fromVertex);
- ((FromToModulating) prev).addFrom(__.constant(fromVertex).asAdmin());
- this.asAdmin().getBytecode().addStep(Symbols.to, toVertex);
- ((FromToModulating) prev).addTo(toVertex.asAdmin());
++ // Convert vertex to id for the purposes of GremlinLang
++ GValue<Object> fromId;
++ if (fromVertexOrId.get() instanceof Vertex) {
++ fromId = GValue.of(fromVertexOrId.getName(), ((Vertex) fromVertexOrId.get()).id());
++ } else {
++ fromId = fromVertexOrId;
++ }
++ this.asAdmin().getGremlinLang().addStep(GraphTraversal.Symbols.from, fromId);
++
++ ((FromToModulating) prev).addFrom(__.constant(fromId).asAdmin());
return this;
}
@@@ -1590,38 -1307,19 +1631,46 @@@
* When used as a modifier to {@link #addE(String)} this method specifies the traversal to use for selecting the
* outgoing vertex of the newly added {@link Edge}.
*
- * @param fromVertex the vertex for selecting the outgoing vertex
- * @param fromVertex the traversal for selecting the outgoing vertex
++ * @param fromVertexOrId the vertex for selecting the outgoing vertex
* @return the traversal with the modified {@link AddEdgeStep}
* @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step" target="_blank">Reference Documentation - From Step</a>
- * @since 3.1.0-incubating
+ * @since 3.3.0
*/
- public default GraphTraversal<S, E> from(final Vertex fromVertex) {
- public default GraphTraversal<S, E> from(final Traversal<?, Object> fromVertex) {
++ public default GraphTraversal<S, E> from(final Object fromVertexOrId) {
++ if (fromVertexOrId instanceof String) {
++ return this.from((String) fromVertexOrId);
++ } else if (fromVertexOrId instanceof Traversal) {
++ this.from((Traversal<?, Object>)fromVertexOrId);
++ return this;
++ }
final Step<?,?> prev = this.asAdmin().getEndStep();
if (!(prev instanceof FromToModulating))
throw new IllegalArgumentException(String.format(
"The from() step cannot follow %s", prev.getClass().getSimpleName()));
- this.asAdmin().getGremlinLang().addStep(Symbols.from, fromVertex);
- ((FromToModulating) prev).addFrom(__.constant(fromVertex).asAdmin());
- this.asAdmin().getBytecode().addStep(Symbols.from, fromVertex);
- ((FromToModulating) prev).addFrom(fromVertex.asAdmin());
++ // Convert vertex to id for the purposes of GremlinLang
++ Object fromId = fromVertexOrId instanceof Vertex ? ((Vertex) fromVertexOrId).id() : fromVertexOrId;
++ this.asAdmin().getGremlinLang().addStep(Symbols.from, fromId);
++ ((FromToModulating) prev).addFrom(__.constant(fromId).asAdmin());
+ return this;
+ }
+
+ /**
+ * Provide {@code to()}-modulation to respective steps.
+ *
+ * @param toStepLabel the step label to modulate to.
+ * @return the traversal with the modified {@link FromToModulating} step.
+ * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#to-step" target="_blank">Reference Documentation - To Step</a>
+ * @since 3.1.0-incubating
+ */
+ public default GraphTraversal<S, E> to(final String toStepLabel) {
+ final Step<?,?> prev = this.asAdmin().getEndStep();
+ if (!(prev instanceof FromToModulating))
+ throw new IllegalArgumentException(String.format(
+ "The to() step cannot follow %s", prev.getClass().getSimpleName()));
+
+ this.asAdmin().getGremlinLang().addStep(Symbols.to, toStepLabel);
+ ((FromToModulating) prev).addTo(toStepLabel);
return this;
}
@@@ -1629,32 -1327,18 +1678,40 @@@
* When used as a modifier to {@link #addE(String)} this method specifies the traversal to use for selecting the
* incoming vertex of the newly added {@link Edge}.
*
-- * @param toVertex the vertex for selecting the incoming vertex
++ * @param toVertexOrId the vertex for selecting the incoming vertex
* @return the traversal with the modified {@link AddEdgeStep}
* @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step" target="_blank">Reference Documentation - From Step</a>
- * @since 3.3.0
+ * @since 4.0.0
*/
- public default GraphTraversal<S, E> to(final GValue<Vertex> toVertex) {
- public default GraphTraversal<S, E> to(final Object toVertex) {
- if (toVertex instanceof String) {
- return this.to((String) toVertex);
- } else if (toVertex instanceof Traversal) {
- this.to((Traversal<?, Object>)toVertex);
- return this;
++ public default GraphTraversal<S, E> to(final GValue<Object> toVertexOrId) {
+ final Step<?,?> prev = this.asAdmin().getEndStep();
+ if (!(prev instanceof FromToModulating))
+ throw new IllegalArgumentException(String.format(
+ "The to() step cannot follow %s", prev.getClass().getSimpleName()));
+
- this.asAdmin().getGremlinLang().addStep(GraphTraversal.Symbols.to, toVertex);
- ((FromToModulating) prev).addTo(__.constant(toVertex).asAdmin());
++ // Convert vertex to id for the purposes of GremlinLang
++ GValue<Object> toId;
++ if (toVertexOrId.get() instanceof Vertex) {
++ toId = GValue.of(toVertexOrId.getName(), ((Vertex) toVertexOrId.get()).id());
++ } else {
++ toId = toVertexOrId;
+ }
++ this.asAdmin().getGremlinLang().addStep(GraphTraversal.Symbols.to, toId);
++
++ ((FromToModulating) prev).addTo(__.constant(toId).asAdmin());
+ return this;
+ }
+
+ /**
+ * When used as a modifier to {@link #addE(String)} this method specifies the traversal to use for selecting the
+ * incoming vertex of the newly added {@link Edge}.
+ *
+ * @param toVertex the traversal for selecting the incoming vertex
+ * @return the traversal with the modified {@link AddEdgeStep}
+ * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step" target="_blank">Reference Documentation - From Step</a>
+ * @since 3.1.0-incubating
+ */
- public default GraphTraversal<S, E> to(final Traversal<?, Vertex> toVertex) {
++ public default GraphTraversal<S, E> to(final Traversal<?, Object> toVertex) {
final Step<?,?> prev = this.asAdmin().getEndStep();
if (!(prev instanceof FromToModulating))
throw new IllegalArgumentException(String.format(
@@@ -1667,21 -1351,27 +1724,28 @@@
/**
* When used as a modifier to {@link #addE(String)} this method specifies the traversal to use for selecting the
- * outgoing vertex of the newly added {@link Edge}.
+ * incoming vertex of the newly added {@link Edge}.
*
- * @param toVertex the vertex for selecting the incoming vertex
- * @param fromVertex the vertex for selecting the outgoing vertex
++ * @param toVertexOrId the vertex for selecting the incoming vertex
* @return the traversal with the modified {@link AddEdgeStep}
* @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step" target="_blank">Reference Documentation - From Step</a>
* @since 3.3.0
*/
- public default GraphTraversal<S, E> to(final Vertex toVertex) {
- public default GraphTraversal<S, E> from(final Object fromVertex) {
- if (fromVertex instanceof String) {
- return this.from((String) fromVertex);
- } else if (fromVertex instanceof Traversal) {
- this.from((Traversal<?, Object>)fromVertex);
++ public default GraphTraversal<S, E> to(final Object toVertexOrId) {
++ if (toVertexOrId instanceof String) {
++ return this.to((String) toVertexOrId);
++ } else if (toVertexOrId instanceof Traversal) {
++ this.to((Traversal<?, Object>)toVertexOrId);
+ return this;
+ }
final Step<?,?> prev = this.asAdmin().getEndStep();
if (!(prev instanceof FromToModulating))
throw new IllegalArgumentException(String.format(
- "The from() step cannot follow %s", prev.getClass().getSimpleName()));
+ "The to() step cannot follow %s", prev.getClass().getSimpleName()));
- this.asAdmin().getGremlinLang().addStep(Symbols.to, toVertex);
- ((FromToModulating) prev).addTo(__.constant(toVertex).asAdmin());
- this.asAdmin().getBytecode().addStep(Symbols.from, fromVertex);
- ((FromToModulating) prev).addFrom(__.constant(fromVertex).asAdmin());
++ Object toId = toVertexOrId instanceof Vertex ? ((Vertex) toVertexOrId).id() : toVertexOrId;
++ this.asAdmin().getGremlinLang().addStep(Symbols.to, toId);
++ ((FromToModulating) prev).addTo(__.constant(toId).asAdmin());
return this;
}
diff --cc gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddEdgeStartStep.java
index 1c7d5a9051,8eb8bccbed..5677a70f73
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddEdgeStartStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddEdgeStartStep.java
@@@ -42,8 -41,8 +42,9 @@@ import org.apache.tinkerpop.gremlin.str
import org.apache.tinkerpop.gremlin.structure.util.Attachable;
import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
+ import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
diff --cc gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddEdgeStep.java
index d9097f2ffe,dd3b61bbb7..03419e8bcd
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddEdgeStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddEdgeStep.java
@@@ -39,8 -37,8 +39,9 @@@ import org.apache.tinkerpop.gremlin.str
import org.apache.tinkerpop.gremlin.structure.util.Attachable;
import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
+ import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@@ -111,50 -97,65 +112,68 @@@ public class AddEdgeStep<S> extends Sca
@Override
protected Edge map(final Traverser.Admin<S> traverser) {
- final String edgeLabel = this.parameters.get(traverser, T.label, () -> Edge.DEFAULT_LABEL).get(0);
+ Object literalOrVar = this.parameters.get(traverser, T.label, () -> GValue.of(null, Edge.DEFAULT_LABEL)).get(0);
+ final GValue<String> edgeLabel = literalOrVar instanceof String ?
+ GValue.ofString(null, (String) literalOrVar) :
+ (GValue<String>) literalOrVar;
- final Object theTo;
+ Object theTo;
try {
theTo = this.parameters.get(traverser, TO, traverser::get).get(0);
- if (theTo != null && !(theTo instanceof Vertex)) {
++ if (theTo != null && !GValue.instanceOf(theTo, GType.VERTEX)) {
+ theTo = new ReferenceVertex(theTo);
+ }
} catch (IllegalArgumentException e) { // as thrown by TraversalUtil.apply()
throw new IllegalStateException(String.format(
"addE(%s) failed because the to() traversal (which should give a Vertex) failed with: %s",
edgeLabel, e.getMessage()));
}
- if (!GValue.instanceOf(theTo, GType.VERTEX))
+ if (theTo == null)
throw new IllegalStateException(String.format(
- "The value given to addE(%s).to() must resolve to a Vertex but %s was specified instead", edgeLabel,
- null == theTo ? "null" : theTo.getClass().getSimpleName()));
+ "The value given to addE(%s).to() must resolve to a Vertex or the ID of a Vertex present in the graph, but null was specified instead", edgeLabel));
- final Object theFrom;
+ Object theFrom;
try {
theFrom = this.parameters.get(traverser, FROM, traverser::get).get(0);
- if (theFrom != null && !(theFrom instanceof Vertex)) {
++ if (theFrom != null && !GValue.instanceOf(theFrom, GType.VERTEX)) {
+ theFrom = new ReferenceVertex(theFrom);
+ }
} catch (IllegalArgumentException e) { // as thrown by TraversalUtil.apply()
throw new IllegalStateException(String.format(
"addE(%s) failed because the from() traversal (which should give a Vertex) failed with: %s",
edgeLabel, e.getMessage()));
}
- if (!GValue.instanceOf(theFrom, GType.VERTEX))
+ if (theFrom == null)
throw new IllegalStateException(String.format(
- "The value given to addE(%s).to() must resolve to a Vertex but %s was specified instead", edgeLabel,
- null == theFrom ? "null" : theFrom.getClass().getSimpleName()));
+ "The value given to addE(%s).from() must resolve to a Vertex or the ID of a Vertex present in the graph, but null was specified instead", edgeLabel));
- Vertex toVertex = (Vertex) theTo;
- Vertex fromVertex = (Vertex) theFrom;
+ Vertex toVertex = GValue.getFrom(theTo);
+ Vertex fromVertex = GValue.getFrom(theFrom);
- if (toVertex instanceof Attachable)
- toVertex = ((Attachable<Vertex>) toVertex)
- .attach(Attachable.Method.get(this.getTraversal().getGraph().orElse(EmptyGraph.instance())));
- if (fromVertex instanceof Attachable)
- fromVertex = ((Attachable<Vertex>) fromVertex)
- .attach(Attachable.Method.get(this.getTraversal().getGraph().orElse(EmptyGraph.instance())));
+ try {
+ if (toVertex instanceof Attachable)
+ toVertex = ((Attachable<Vertex>) toVertex)
+ .attach(Attachable.Method.get(this.getTraversal().getGraph().orElse(EmptyGraph.instance())));
+ }
+ catch (IllegalArgumentException e) {
+ throw new IllegalStateException(String.format(
+ "The value given to addE(%s).to() must resolve to a Vertex or the ID of a Vertex present in the graph. The provided value does not match any vertices in the graph", edgeLabel));
+ }
+
+ try {
+ if (fromVertex instanceof Attachable)
+ fromVertex = ((Attachable<Vertex>) fromVertex)
+ .attach(Attachable.Method.get(this.getTraversal().getGraph().orElse(EmptyGraph.instance())));
+ }
+ catch (IllegalArgumentException e) {
+ throw new IllegalStateException(String.format(
+ "The value given to addE(%s).from() must resolve to a Vertex or the ID of a Vertex present in the graph. The provided value does not match any vertices in the graph", edgeLabel));
+ }
+
- final Edge edge = fromVertex.addEdge(edgeLabel, toVertex, this.parameters.getKeyValues(traverser, TO, FROM, T.label));
+ final Edge edge = fromVertex.addEdge(edgeLabel.get(), toVertex, this.parameters.getKeyValues(traverser, TO, FROM, T.label));
EventUtil.registerEdgeCreation(callbackRegistry, getTraversal(), edge);
return edge;
}
diff --cc gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/ArgumentVisitorTest.java
index d988a3e76e,a37110d564..164f83316e
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/ArgumentVisitorTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/ArgumentVisitorTest.java
@@@ -114,32 -97,21 +114,29 @@@ public class ArgumentVisitorTest
{Float.class, "0.0d", 0.0, createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", 1000.0)))},
{Float.class, "0d", 0.0, createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", 1000.0)))},
{Float.class, "0F", 0.0F, createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", 1000.0F)))},
- {Float.class, "x", 0.0, createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", 0.0)))},
- {Float.class, "x", 0.0F, createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", 0.0F)))},
+ {Float.class, "x", GValue.of("x", 0.0), createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", 0.0)))},
+ {Float.class, "x", GValue.of("x", 0.0F), createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", 0.0F)))},
+ {Float.class, "x", 0.0, createAntlr(new VariableResolver.DirectVariableResolver(ElementHelper.asMap("x", 0.0)))},
+ {Float.class, "x", 0.0F, createAntlr(new VariableResolver.DirectVariableResolver(ElementHelper.asMap("x", 0.0F)))},
{String.class, "x", new VariableResolverException("x"), createAntlr(VariableResolver.NoVariableResolver.instance())},
{String.class, "'test'", "test", createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", "nope")))},
- {String.class, "x", "test", createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", "test")))},
- {String.class, "x", "graphson", createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", IO.graphson)))},
+ {String.class, "x", GValue.of("x", "test"), createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", "test")))},
+ {String.class, "x", GValue.of("x", "graphson"), createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", IO.graphson)))},
+ {String.class, "x", "test", createAntlr(new VariableResolver.DirectVariableResolver(ElementHelper.asMap("x", "test")))},
+ {String.class, "x", "graphson", createAntlr(new VariableResolver.DirectVariableResolver(ElementHelper.asMap("x", IO.graphson)))},
{StringNullable.class, "x", new VariableResolverException("x"), createAntlr(VariableResolver.NoVariableResolver.instance())},
{StringNullable.class, "null", null, createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", "nope")))},
- {StringNullable.class, "x", null, createAntlr(new VariableResolver.DefaultVariableResolver(nullMap))},
+ {StringNullable.class, "x", GValue.of("x", null), createAntlr(new VariableResolver.DefaultVariableResolver(nullMap))},
+ {StringNullable.class, "x", null, createAntlr(new VariableResolver.DirectVariableResolver(nullMap))},
{Object.class, "x", new VariableResolverException("x"), createAntlr(VariableResolver.NoVariableResolver.instance())},
{Object.class, "'test'", "test", createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", "nope")))},
- {Object.class, "x", "test", createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", "test")))},
- {Object.class, "x", now, createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", now)))},
+ {Object.class, "x", GValue.of("x", "test"), createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", "test")))},
+ {Object.class, "x", GValue.of("x", now), createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", now)))},
+ {Object.class, "x", "test", createAntlr(new VariableResolver.DirectVariableResolver(ElementHelper.asMap("x", "test")))},
+ {Object.class, "x", now, createAntlr(new VariableResolver.DirectVariableResolver(ElementHelper.asMap("x", now)))},
{Object.class, "[1,2,3]", Arrays.asList(1, 2, 3), createAntlr(VariableResolver.NoVariableResolver.instance())},
- {Object.class, "x", P.eq(100), createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", P.eq(100))))},
+ {Object.class, "x", GValue.of("x", P.eq(100)), createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", P.eq(100))))},
+ {Object.class, "x", P.eq(100), createAntlr(new VariableResolver.DirectVariableResolver(ElementHelper.asMap("x", P.eq(100))))},
- {Vertex.class, "x", new VariableResolverException("x"), createAntlr(VariableResolver.NoVariableResolver.instance())},
- {Vertex.class, "new Vertex(1i,'person')", new ReferenceVertex(1, "person"), createAntlr(new VariableResolver.DefaultVariableResolver(ElementHelper.asMap("x", Direction.from)))},
- {Vertex.class, "x", new ReferenceVertex(1, "person"), createAntlr(new VariableResolver.DirectVariableResolver(ElementHelper.asMap("x", new ReferenceVertex(1, "person"))))},
});
}
diff --cc gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/GremlinLangTest.java
index 7911a95ed9,0000000000..a6a6636d9f
mode 100644,000000..100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/GremlinLangTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/GremlinLangTest.java
@@@ -1,167 -1,0 +1,167 @@@
+/*
+ * 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;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.process.traversal.step.GValue;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SeedStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
+import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdge;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
+import org.apache.tinkerpop.gremlin.util.DatetimeHelper;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+
+import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal;
+import static org.apache.tinkerpop.gremlin.process.traversal.Scope.local;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.both;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.hasLabel;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.out;
+import static org.apache.tinkerpop.gremlin.util.CollectionUtil.asMap;
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Parameterized.class)
+public class GremlinLangTest {
+
+ private static final GraphTraversalSource g = traversal().with(EmptyGraph.instance());
+
+ @Parameterized.Parameter(value = 0)
+ public Traversal traversal;
+
+ @Parameterized.Parameter(value = 1)
+ public String expected;
+
+ @Test
+ public void doTest() {
+ final String gremlin = traversal.asAdmin().getGremlinLang().getGremlin();
+ assertEquals(expected, gremlin);
+ }
+
+ private static GraphTraversalSource newG() {
+ final GraphTraversalSource g = traversal().with(EmptyGraph.instance());
+ g.getGremlinLang().reset();
+ return g;
+ }
+
+ @Parameterized.Parameters(name = "{0}")
+ public static Iterable<Object[]> generateTestParameters() {
+ return Arrays.asList(new Object[][]{
+ {g.V().count(), "g.V().count()"},
+ {g.addV("test"), "g.addV(\"test\")"},
+ {g.addV("t\"'est"), "g.addV(\"t\\\"'est\")"},
+ {g.inject(true, (byte) 1, (short) 2, 3, 4L, 5f, 6d, BigInteger.valueOf(7L), BigDecimal.valueOf(8L)),
+ "g.inject(true,1B,2S,3,4L,5.0F,6.0D,7N,8M)"},
+ {g.inject(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY),
+ "g.inject(+Infinity,-Infinity)"},
+ {g.inject(DatetimeHelper.parse("2018-03-21T08:35:44.741Z")),
+ "g.inject(datetime(\"2018-03-21T08:35:44.741Z\"))"},
+ {g.inject(asMap("age", VertexProperty.Cardinality.list(33))),
+ "g.inject([\"age\":Cardinality.list(33)])"},
+ {g.inject(new HashMap<>()), "g.inject([:])"},
+ {g.V(1).out("knows").values("name"), "g.V(1).out(\"knows\").values(\"name\")"},
+ {g.V().has(T.label, "person"), "g.V().has(T.label,\"person\")"},
+ {g.addE("knows").from(new DetachedVertex(1, "test1", Collections.emptyList())).to(new DetachedVertex(6, "test2", Collections.emptyList())),
- "g.addE(\"knows\").from(new ReferenceVertex(1,\"test1\")).to(new ReferenceVertex(6,\"test2\"))"},
++ "g.addE(\"knows\").from(1).to(6)"},
+ {newG().E(new ReferenceEdge(1, "test label", new ReferenceVertex(1, "v1"), new ReferenceVertex(1, "v1"))),
+ "g.E(_0)"},
+ {g.V().hasId(P.within(Collections.emptyList())).count(), "g.V().hasId(P.within([])).count()"},
+ {g.V(1).outE().has("weight", P.inside(0.0, 0.6)), "g.V(1).outE().has(\"weight\",P.gt(0.0D).and(P.lt(0.6D)))"},
+ {g.withSack(1.0, Operator.sum).V(1).local(__.out("knows").barrier(SackFunctions.Barrier.normSack)).in("knows").barrier().sack(),
+ "g.withSack(1.0D,Operator.sum).V(1).local(__.out(\"knows\").barrier(Barrier.normSack)).in(\"knows\").barrier().sack()"},
+ {g.inject(Arrays.asList(1, 2, 3)).skip(local, 1), "g.inject([1,2,3]).skip(Scope.local,1L)"},
+ {g.V().repeat(both()).times(10), "g.V().repeat(__.both()).times(10)"},
+ {g.V().has("name", "marko").
+ project("name", "friendsNames").
+ by("name").
+ by(out("knows").values("name").fold()),
+ "g.V().has(\"name\",\"marko\")." +
+ "project(\"name\",\"friendsNames\")." +
+ "by(\"name\")." +
+ "by(__.out(\"knows\").values(\"name\").fold())"},
+ {g.inject(new int[]{5, 6}).union(__.V(Arrays.asList(1, 2)), __.V(Arrays.asList(3L, new int[]{4}))),
+ "g.inject([5,6]).union(__.V([1,2]),__.V([3L,[4]]))"},
+ {g.with("evaluationTimeout", 1000).V(), "g.V()"},
+ {g.withSideEffect("a", 1).V(), "g.withSideEffect(\"a\",1).V()"},
+ {g.withStrategies(ReadOnlyStrategy.instance()).V(), "g.withStrategies(ReadOnlyStrategy).V()"},
+ {g.withoutStrategies(ReadOnlyStrategy.class).V(), "g.withoutStrategies(ReadOnlyStrategy).V()"},
+ {g.withStrategies(new SeedStrategy(999999)).V().order().by("name").coin(0.5),
+ "g.withStrategies(new SeedStrategy(seed:999999L)).V().order().by(\"name\").coin(0.5D)"},
+ {g.withStrategies(SubgraphStrategy.build().vertices(hasLabel("person")).create()).V(),
+ "g.withStrategies(new SubgraphStrategy(checkAdjacentVertices:true,vertices:__.hasLabel(\"person\"))).V()",},
+ {g.withStrategies(SubgraphStrategy.build().vertices(__.has("name", P.within("josh", "lop", "ripple"))).create()).V(),
+ "g.withStrategies(new SubgraphStrategy(checkAdjacentVertices:true,vertices:__.has(\"name\",P.within([\"josh\",\"lop\",\"ripple\"])))).V()"},
+ {g.inject(GValue.of("x", "x")).V(GValue.of("ids", new int[]{1, 2, 3})), "g.inject(x).V(ids)"},
+ {newG().inject(GValue.of(null, "test1"), GValue.of("xx2", "test2")), "g.inject(\"test1\",xx2)"},
+ {newG().inject(new HashSet<>(Arrays.asList(1, 2))), "g.inject({1,2})"},
+ });
+ }
+
+ public static class ParameterTests {
+
+ @Test(expected = IllegalArgumentException.class)
+ public void shouldCheckParameterNameDontNeedEscaping() {
+ g.V(GValue.of("\"", new int[]{1, 2, 3}));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void shouldCheckParameterNameIsNotNumber() {
+ g.V(GValue.of("1", new int[]{1, 2, 3}));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void shouldCheckParameterNameIsValidIdentifier() {
+ g.V(GValue.of("1a", new int[]{1, 2, 3}));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void shouldCheckParameterNameIsNotReserved() {
+ g.V(GValue.of("_1", new int[]{1, 2, 3}));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void shouldNowAllowParameterNameDuplicates() {
+ final GremlinLang gremlin = g.inject(GValue.of("ids", new int[]{1, 2})).V(GValue.of("ids", new int[]{2, 3}))
+ .asAdmin().getGremlinLang();
+ }
+
+ @Test
+ public void shouldAllowToUseSameParameterTwice() {
+ final int[] value = new int[]{1, 2, 3};
+ final GValue<int[]> gValue = GValue.of("ids", value);
+ final GremlinLang gremlin = g.inject(gValue).V(gValue).asAdmin().getGremlinLang();
+
+ assertEquals("g.inject(ids).V(ids)", gremlin.getGremlin());
+ assertEquals(value, gremlin.getParameters().get("ids"));
+ }
+ }
+}
diff --cc gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
index 13b9beca57,ef645da751..019554eb13
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
@@@ -91,6 -91,6 +91,13 @@@ namespace Gremlin.Net.Process.Traversa
}
else
{
++ for (int i = 0; i < vertexIdsOrElements.Length; i++)
++ {
++ if (vertexIdsOrElements[i] is Vertex vertex)
++ {
++ vertexIdsOrElements[i] = vertex.Id;
++ }
++ }
var args = new List<object?>(vertexIdsOrElements.Length);
args.AddRange(vertexIdsOrElements);
Bytecode.AddStep("V", args.ToArray());
@@@ -871,6 -862,15 +878,15 @@@
return Wrap<TStart, string>(this);
}
+ /// <summary>
+ /// Adds the from step to this <see cref="GraphTraversal{SType, EType}" />.
+ /// </summary>
+ public GraphTraversal<TStart, TEnd> From (object? fromStepVertexIdOrLabel)
+ {
- Bytecode.AddStep("from", fromStepVertexIdOrLabel);
++ Bytecode.AddStep("from", fromStepVertexIdOrLabel is Vertex vertex ? vertex.Id : fromStepVertexIdOrLabel);
+ return Wrap<TStart, TEnd>(this);
+ }
+
/// <summary>
/// Adds the from step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
@@@ -894,7 -894,7 +910,7 @@@
/// </summary>
public GraphTraversal<TStart, TEnd> From (Vertex? fromVertex)
{
-- Bytecode.AddStep("from", fromVertex);
++ Bytecode.AddStep("from", fromVertex?.Id);
return Wrap<TStart, TEnd>(this);
}
@@@ -1441,8 -1441,8 +1457,14 @@@
/// <summary>
/// Adds the mergeE step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
-- public GraphTraversal<TStart, Edge> MergeE (IDictionary<object,object>? m)
++ public GraphTraversal<TStart, Edge> MergeE (IDictionary<object,object?>? m)
{
++ if (m != null && m[Direction.Out] is Vertex outV) {
++ m[Direction.Out] = outV.Id;
++ }
++ if (m != null && m[Direction.In] is Vertex inV) {
++ m[Direction.In] = inV.Id;
++ }
Bytecode.AddStep("mergeE", m);
return Wrap<TStart, Edge>(this);
}
@@@ -2202,6 -2202,15 +2224,15 @@@
Bytecode.AddStep("to", args.ToArray());
return Wrap<TStart, Vertex>(this);
}
+
+ /// <summary>
+ /// Adds the to step to this <see cref="GraphTraversal{SType, EType}" />.
+ /// </summary>
+ public GraphTraversal<TStart, TEnd> To (object? toStepVertexIdOrLabel)
+ {
- Bytecode.AddStep("to", toStepVertexIdOrLabel);
++ Bytecode.AddStep("to", toStepVertexIdOrLabel is Vertex vertex ? vertex.Id : toStepVertexIdOrLabel );
+ return Wrap<TStart, TEnd>(this);
+ }
/// <summary>
/// Adds the to step to this <see cref="GraphTraversal{SType, EType}" />.
@@@ -2226,7 -2235,7 +2257,7 @@@
/// </summary>
public GraphTraversal<TStart, TEnd> To (Vertex? toVertex)
{
-- Bytecode.AddStep("to", toVertex);
++ Bytecode.AddStep("to", toVertex?.Id);
return Wrap<TStart, TEnd>(this);
}
diff --cc gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
index ae2a191a06,5908c0d966..5ed0f046ce
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
@@@ -116,10 -114,13 +116,10 @@@ namespace Gremlin.Net.IntegrationTest.G
{"g_VX3X_repeatXbothX_createdXX_untilXloops_is_40XXemit_repeatXin_knowsXX_emit_loopsXisX1Xdedup_values", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid3"]).Repeat(__.Both("created")).Until(__.Loops().Is(40)).Emit(__.Repeat(__.In("knows")).Emit(__.Loops().Is(1))).Dedup().Values<object>("name")}},
{"g_VX1X_repeatXrepeatXunionXout_uses_out_traversesXX_whereXloops_isX0X_timesX1X_timeX2X_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Repeat(__.Repeat(__.Union<object>(__.Out("uses"), __.Out("traverses")).Where(__.Loops().Is(0))).Times(1)).Times(2).Values<object>("name")}},
{"g_V_repeatXa_outXknows_repeatXb_outXcreatedX_filterXloops_isX0XX_emit_lang", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Repeat("a", __.Out("knows").Repeat("b", __.Out("created").Filter(__.Loops("a").Is(0))).Emit()).Emit().Values<object>("lang")}},
- {"g_VX6X_repeatXa_bothXcreatedX_simplePathX_emitXrepeatXb_bothXknowsXX_untilXloopsXbX_asXb_whereXloopsXaX_asXbX_hasXname_vadasXX_dedup_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid6"]).Repeat("a", __.Both("created").SimplePath()).Emit(__.Repeat("b", __.Both("knows")).Until(__.Loops("b").As("b").Where(__.Loops("a").As("b"))).Has("name", "vadas")).Dedup().Values<object>("name")}},
- {"g_V_emit", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Emit()}},
- {"g_V_untilXidentityX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Until(__.Identity())}},
- {"g_V_timesX5X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Times(5)}},
+ {"g_VX6X_repeatXa_bothXcreatedX_simplePathX_emitXrepeatXb_bothXknowsXX_untilXloopsXbX_asXb_whereXloopsXaX_asXbX_hasXname_vadasXX_dedup_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid6"]).Repeat("a", __.Both("created").SimplePath()).Emit(__.Repeat("b", __.Both("knows")).Until(__.Loops("b").As("b").Where(__.Loops("a").As("b"))).Has("name", "vadas")).Dedup().Values<object>("name")}},
{"g_unionXX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Union<object>()}},
{"g_unionXV_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Union<object>(__.V().Values<object>("name"))}},
- {"g_unionXVXv1X_VX4XX_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Union<object>(__.V((Vertex) p["v1"]), __.V((Vertex) p["v4"])).Values<object>("name")}},
+ {"g_unionXVXv1X_VX4XX_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Union<object>(__.V(p["vid1"]), __.V(p["vid4"])).Values<object>("name")}},
{"g_unionXV_hasLabelXsoftwareX_V_hasLabelXpersonXX_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Union<object>(__.V().HasLabel("software"), __.V().HasLabel("person")).Values<object>("name")}},
{"g_unionXV_out_out_V_hasLabelXsoftwareXX_path", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Union<object>(__.V().Out().Out(), __.V().HasLabel("software")).Path()}},
{"g_unionXV_out_out_V_hasLabelXsoftwareXX_path_byXnameX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Union<object>(__.V().Out().Out(), __.V().HasLabel("software")).Path().By("name")}},
@@@ -236,14 -228,12 +236,14 @@@
{"g_V_hasXlabel_isXsoftwareXX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Has(T.Label, __.Is("software"))}},
{"g_VX1X_hasXage_gt_30X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Has("age", P.Gt(30))}},
{"g_VX4X_hasXage_gt_30X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid4"]).Has("age", P.Gt(30))}},
- {"g_VXv1X_hasXage_gt_30X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V((Vertex) p["v1"]).Has("age", P.Gt(30))}},
- {"g_VXv4X_hasXage_gt_30X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V((Vertex) p["v4"]).Has("age", P.Gt(30))}},
- {"g_VX1X_out_hasXid_2X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V((Vertex) p["v2"]).Has("age", P.Gt(30))}},
+ {"g_VXv1X_hasXage_gt_30X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Has("age", P.Gt(30))}},
+ {"g_VXv4X_hasXage_gt_30X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid4"]).Has("age", P.Gt(30))}},
+ {"g_VX1X_out_hasXid_2X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid2"]).Has("age", P.Gt(30))}},
{"g_V_hasXblahX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Has("blah")}},
{"g_V_hasXperson_name_markoX_age", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Has("person", "name", "marko").Values<object>("age")}},
- {"g_VX1X_outE_hasXweight_inside_0_06X_inV", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).OutE().Has("weight", P.Inside(0.0, 0.6)).InV()}},
+ {"g_V_hasXperson_name_markovarX_age", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Has("person", "name", (object) p["xx1"]).Values<object>("age")}},
+ {"g_V_hasXpersonvar_name_markoX_age", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Has((string) p["xx1"], "name", "marko").Values<object>("age")}},
+ {"g_VX1X_outE_hasXweight_inside_0_06X_inV", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).OutE().Has("weight", P.Inside(0.0, 0.6)).InV()}},
{"g_EX11X_outV_outE_hasXid_10X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.E(p["eid11"]).OutV().OutE().Has(T.Id, (object) p["eid10"])}},
{"g_EX11X_outV_outE_hasXid_10AsStringX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.E(p["eid11"]).OutV().OutE().Has(T.Id, (object) p["eid10"])}},
{"g_V_hasXlocationX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Has("location")}},
@@@ -1631,9 -1618,7 +1631,13 @@@
{"g_V_hasXperson_name_markoX_bothXknowsX_groupCount_byXvaluesXnameX_foldX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Has("person", "name", "marko").Both("knows").GroupCount<object>().By(__.Values<object>("name").Fold())}},
{"g_V_outXcreatedX_groupCount_byXnameX_byXageX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Out("created").GroupCount<object>().By("name").By("age")}},
{"g_V_outXcreatedX_groupCountXxX_byXnameX_byXageX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Out("created").GroupCount("x").By("name").By("age")}},
++<<<<<<< HEAD
+ {"g_VX1X_out_injectXv2X_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Out().Inject((Vertex) p["v2"]).Values<object>("name")}},
+ {"g_VX1X_out_name_injectXdanielX_asXaX_mapXlengthX_path", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>>()}, // skipping as it contains a lambda
+ {"g_VX1X_injectXg_VX4XX_out_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Inject((Vertex) p["v2"]).Out().Values<object>("name")}},
++=======
+ {"g_VX1X_out_name_injectXdanielX_asXaX_mapXlengthX_path", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Out().Values<object>("name").Inject("daniel").As("a").Map<object>(__.Length()).Path()}},
++>>>>>>> grammar_vertexv2
{"g_injectXnull_1_3_nullX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>(null, 1, 3, null)}},
{"g_injectX10_20_null_20_10_10X_groupCountXxX_dedup_asXyX_projectXa_bX_by_byXselectXxX_selectXselectXyXXX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>(10, 20, null, 20, 10, 10).GroupCount("x").Dedup().As("y").Project<object>("a", "b").By().By(__.Select<object>("x").Select<object>(__.Select<object>("y")))}},
{"g_injectXname_marko_age_nullX_selectXname_ageX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>(p["xx1"]).Select<object>("name", "age")}},
diff --cc gremlin-go/driver/cucumber/gremlin.go
index 6f53f5cca9,1574cb18df..70706fa6bd
--- a/gremlin-go/driver/cucumber/gremlin.go
+++ b/gremlin-go/driver/cucumber/gremlin.go
@@@ -210,14 -198,12 +210,14 @@@ var translationMap = map[string][]func(
"g_V_hasXlabel_isXsoftwareXX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Has(gremlingo.T.Label, gremlingo.T__.Is("software"))}},
"g_VX1X_hasXage_gt_30X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid1"]).Has("age", gremlingo.P.Gt(30))}},
"g_VX4X_hasXage_gt_30X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid4"]).Has("age", gremlingo.P.Gt(30))}},
- "g_VXv1X_hasXage_gt_30X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["v1"]).Has("age", gremlingo.P.Gt(30))}},
- "g_VXv4X_hasXage_gt_30X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["v4"]).Has("age", gremlingo.P.Gt(30))}},
- "g_VX1X_out_hasXid_2X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["v2"]).Has("age", gremlingo.P.Gt(30))}},
+ "g_VXv1X_hasXage_gt_30X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid1"]).Has("age", gremlingo.P.Gt(30))}},
+ "g_VXv4X_hasXage_gt_30X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid4"]).Has("age", gremlingo.P.Gt(30))}},
+ "g_VX1X_out_hasXid_2X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid2"]).Has("age", gremlingo.P.Gt(30))}},
"g_V_hasXblahX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Has("blah")}},
"g_V_hasXperson_name_markoX_age": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Has("person", "name", "marko").Values("age")}},
- "g_VX1X_outE_hasXweight_inside_0_06X_inV": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid1"]).OutE().Has("weight", gremlingo.P.Inside(0.0, 0.6)).InV()}},
+ "g_V_hasXperson_name_markovarX_age": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Has("person", "name", p["xx1"]).Values("age")}},
+ "g_V_hasXpersonvar_name_markoX_age": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Has(p["xx1"], "name", "marko").Values("age")}},
+ "g_VX1X_outE_hasXweight_inside_0_06X_inV": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid1"]).OutE().Has("weight", gremlingo.P.Inside(0.0, 0.6)).InV()}},
"g_EX11X_outV_outE_hasXid_10X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.E(p["eid11"]).OutV().OutE().Has(gremlingo.T.Id, p["eid10"])}},
"g_EX11X_outV_outE_hasXid_10AsStringX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.E(p["eid11"]).OutV().OutE().Has(gremlingo.T.Id, p["eid10"])}},
"g_V_hasXlocationX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Has("location")}},
@@@ -1605,9 -1588,7 +1605,13 @@@
"g_V_hasXperson_name_markoX_bothXknowsX_groupCount_byXvaluesXnameX_foldX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Has("person", "name", "marko").Both("knows").GroupCount().By(gremlingo.T__.Values("name").Fold())}},
"g_V_outXcreatedX_groupCount_byXnameX_byXageX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Out("created").GroupCount().By("name").By("age")}},
"g_V_outXcreatedX_groupCountXxX_byXnameX_byXageX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Out("created").GroupCount("x").By("name").By("age")}},
++<<<<<<< HEAD
+ "g_VX1X_out_injectXv2X_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid1"]).Out().Inject(p["v2"]).Values("name")}},
+ "g_VX1X_out_name_injectXdanielX_asXaX_mapXlengthX_path": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return nil}}, // skipping as it contains a lambda
+ "g_VX1X_injectXg_VX4XX_out_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid1"]).Inject(p["v2"]).Out().Values("name")}},
++=======
+ "g_VX1X_out_name_injectXdanielX_asXaX_mapXlengthX_path": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid1"]).Out().Values("name").Inject("daniel").As("a").Map(gremlingo.T__.Length()).Path()}},
++>>>>>>> grammar_vertexv2
"g_injectXnull_1_3_nullX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(nil, 1, 3, nil)}},
"g_injectX10_20_null_20_10_10X_groupCountXxX_dedup_asXyX_projectXa_bX_by_byXselectXxX_selectXselectXyXXX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(10, 20, nil, 20, 10, 10).GroupCount("x").Dedup().As("y").Project("a", "b").By().By(gremlingo.T__.Select("x").Select(gremlingo.T__.Select("y")))}},
"g_injectXname_marko_age_nullX_selectXname_ageX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(p["xx1"]).Select("name", "age")}},
diff --cc gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
index b7eb4c6f5f,aab974e253..d0c71885b7
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
@@@ -238,15 -227,12 +238,15 @@@ const gremlins =
g_V_hasXage_isXgt_30XX: [function({g}) { return g.V().has("age", __.is(P.gt(30))) }],
g_V_hasXlabel_isXsoftwareXX: [function({g}) { return g.V().has(T.label, __.is("software")) }],
g_VX1X_hasXage_gt_30X: [function({g, vid1}) { return g.V(vid1).has("age", P.gt(30)) }],
+ g_V_hasXpersonvar_age_gt_30X: [function({g, xx1}) { return g.V().has(xx1, "age", P.gt(30)) }],
g_VX4X_hasXage_gt_30X: [function({g, vid4}) { return g.V(vid4).has("age", P.gt(30)) }],
- g_VXv1X_hasXage_gt_30X: [function({g, v1}) { return g.V(v1).has("age", P.gt(30)) }],
- g_VXv4X_hasXage_gt_30X: [function({g, v4}) { return g.V(v4).has("age", P.gt(30)) }],
- g_VX1X_out_hasXid_2X: [function({g, v2}) { return g.V(v2).has("age", P.gt(30)) }],
+ g_VXv1X_hasXage_gt_30X: [function({g, vid1}) { return g.V(vid1).has("age", P.gt(30)) }],
+ g_VXv4X_hasXage_gt_30X: [function({g, vid4}) { return g.V(vid4).has("age", P.gt(30)) }],
+ g_VX1X_out_hasXid_2X: [function({g, vid2}) { return g.V(vid2).has("age", P.gt(30)) }],
g_V_hasXblahX: [function({g}) { return g.V().has("blah") }],
g_V_hasXperson_name_markoX_age: [function({g}) { return g.V().has("person", "name", "marko").values("age") }],
+ g_V_hasXperson_name_markovarX_age: [function({g, xx1}) { return g.V().has("person", "name", xx1).values("age") }],
+ g_V_hasXpersonvar_name_markoX_age: [function({g, xx1}) { return g.V().has(xx1, "name", "marko").values("age") }],
g_VX1X_outE_hasXweight_inside_0_06X_inV: [function({g, vid1}) { return g.V(vid1).outE().has("weight", P.inside(0.0, 0.6)).inV() }],
g_EX11X_outV_outE_hasXid_10X: [function({g, eid11, eid10}) { return g.E(eid11).outV().outE().has(T.id, eid10) }],
g_EX11X_outV_outE_hasXid_10AsStringX: [function({g, eid11, eid10}) { return g.E(eid11).outV().outE().has(T.id, eid10) }],
@@@ -616,21 -579,16 +616,21 @@@
g_V_aggregateXxX_asXaX_selectXxX_unfold_addEXexistsWithX_toXaX_propertyXtime_nowX: [function({g, vid1, vid2, vid3, vid4, vid5, vid6}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").prope [...]
g_V_asXaX_outXcreatedX_inXcreatedX_whereXneqXaXX_asXbX_addEXcodeveloperX_fromXaX_toXbX_propertyXyear_2009X: [function({g, vid1, vid2, vid4, vid6}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "r [...]
g_V_asXaX_inXcreatedX_addEXcreatedByX_fromXaX_propertyXyear_2009X_propertyXacl_publicX: [function({g, vid1, vid2, vid3, vid4, vid5, vid6}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple"). [...]
- g_withSideEffectXb_bX_VXaX_addEXknowsX_toXbX_propertyXweight_0_5X: [function({g, v6, v1}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").addV("perso [...]
+ g_withSideEffectXb_bX_VXaX_addEXknowsX_toXbX_propertyXweight_0_5X: [function({g, vid6, vid1}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").addV("p [...]
g_addV_asXfirstX_repeatXaddEXnextX_toXaddVX_inVX_timesX5X_addEXnextX_toXselectXfirstXX: [function({g}) { return g.addV().as("first").repeat(__.addE("next").to(__.addV()).inV()).times(5).addE("next").to(__.select("first")) }, function({g}) { return g.V() }, function({g}) { return g.E() }, function({g}) { return g.E().hasLabel("next") }, function({g}) { return g.V().limit(1).bothE() }, function({g}) { return g.V().limit(1).inE() }, function({g}) { return g.V().limit(1).outE() }],
- g_V_hasXname_markoX_asXaX_outEXcreatedX_asXbX_inV_addEXselectXbX_labelX_toXaX: [function({g, v1}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").add [...]
- g_addEXV_outE_label_groupCount_orderXlocalX_byXvalues_descX_selectXkeysX_unfold_limitX1XX_fromXV_hasXname_vadasXX_toXV_hasXname_lopXX: [function({g, v2}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("na [...]
- g_addEXknowsX_fromXaX_toXbX_propertyXweight_0_1X: [function({g, v6, xx1, v1}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").addV("person").property [...]
- g_addEXknowsvarX_fromXaX_toXbX_propertyXweight_0_1X: [function({g, xx1, v6, xx2, v1}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").addV("person"). [...]
- g_VXaX_addEXknowsX_toXbX_propertyXweight_0_1X: [function({g, v6, xx1, v1}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").addV("person").property("n [...]
+ g_V_hasXname_markoX_asXaX_outEXcreatedX_asXbX_inV_addEXselectXbX_labelX_toXaX: [function({g, vid1}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").a [...]
+ g_addEXV_outE_label_groupCount_orderXlocalX_byXvalues_descX_selectXkeysX_unfold_limitX1XX_fromXV_hasXname_vadasXX_toXV_hasXname_lopXX: [function({g, vid2}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property(" [...]
+ g_addEXknowsX_fromXaX_toXbX_propertyXweight_0_1X: [function({g, xx1, vid6, vid1}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").addV("person").prop [...]
++ g_addEXknowsvarX_fromXaX_toXbX_propertyXweight_0_1X: [function({g, xx1, vid6, xx2, vid1}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").addV("perso [...]
+ g_VXaX_addEXknowsX_toXbX_propertyXweight_0_1X: [function({g, xx1, vid6, vid1}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").addV("person").propert [...]
g_addEXknowsXpropertyXweight_nullXfromXV_hasXname_markoXX_toXV_hasXname_vadasXX: [function({g}) { return g.addV("person").property("name", "marko").property("age", 29).addV("person").property("name", "vadas").property("age", 27) }, function({g}) { return g.addE("knows").property("weight", null).from_(__.V().has("name", "marko")).to(__.V().has("name", "vadas")) }, function({g}) { return g.E().has("knows", "weight", null) }],
+ g_addEXknowsvarXpropertyXweight_nullXfromXV_hasXname_markoXX_toXV_hasXname_vadasXX: [function({g, xx1}) { return g.addV("person").property("name", "marko").property("age", 29).addV("person").property("name", "vadas").property("age", 27) }, function({g, xx1}) { return g.addE(xx1).property("weight", null).from_(__.V().has("name", "marko")).to(__.V().has("name", "vadas")) }, function({g, xx1}) { return g.E().has("knows", "weight", null) }],
+ g_unionXaddEXknowsvarXpropertyXweight_nullXfromXV_hasXname_markoXX_toXV_hasXname_vadasXXX: [function({g, xx1}) { return g.addV("person").property("name", "marko").property("age", 29).addV("person").property("name", "vadas").property("age", 27) }, function({g, xx1}) { return g.union(__.addE(xx1).property("weight", 1).from_(__.V().has("name", "marko")).to(__.V().has("name", "vadas"))) }, function({g, xx1}) { return g.E().has("knows", "weight", 1) }],
g_VX1X_addVXanimalX_propertyXage_selectXaX_byXageXX_propertyXname_puppyX: [function({g, vid1}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").addV(" [...]
g_V_addVXanimalX_propertyXage_0X: [function({g}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").addV("person").property("name", "peter").property("a [...]
+ g_V_addVXanimalvarX_propertyXage_0varX: [function({g, xx1, xx2}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").addV("person").property("name", "pet [...]
g_addVXpersonX_propertyXname_stephenX: [function({g}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").addV("person").property("name", "peter").proper [...]
+ g_addVXpersonvarX_propertyXname_stephenvarX: [function({g, xx1, xx2}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").addV("person").property("name", [...]
g_V_hasLabelXpersonX_propertyXname_nullX: [function({g}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").addV("person").property("name", "peter").pro [...]
g_addVXpersonX_propertyXsingle_name_stephenX_propertyXsingle_name_stephenmX: [function({g}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("ripple").addV("per [...]
get_g_addVXpersonX_propertyXsingle_name_stephenX_propertyXsingle_name_stephenm_since_2010X: [function({g}) { return g.addV("person").property("name", "marko").property("age", 29).as("marko").addV("person").property("name", "vadas").property("age", 27).as("vadas").addV("software").property("name", "lop").property("lang", "java").as("lop").addV("person").property("name", "josh").property("age", 32).as("josh").addV("software").property("name", "ripple").property("lang", "java").as("rip [...]
@@@ -837,19 -788,7 +837,19 @@@
g_V_EXlistXnullXX: [function({g, xx1}) { return g.V().E(xx1) }],
g_injectX1X_EX11_nullX: [function({g, eid11}) { return g.inject(1).E(eid11, null) }],
g_injectX1X_coalesceXEX_hasLabelXtestsX_addEXtestsX_from_V_hasXnameX_XjoshXX_toXV_hasXnameX_XvadasXXX: [function({g}) { return g.addV("person").property("name", "josh").addV("person").property("name", "vadas") }, function({g}) { return g.inject(1).coalesce(__.E().hasLabel("tests"), __.addE("tests").from_(__.V().has("name", "josh")).to(__.V().has("name", "vadas"))) }, function({g}) { return g.E().hasLabel("tests") }],
+ g_VX1X_outE_inV: [function({g, vid1}) { return g.V(vid1).outE().inV() }],
+ g_VX2X_inE_outV: [function({g, vid2}) { return g.V(vid2).inE().outV() }],
+ g_V_outE_hasXweight_1X_outV: [function({g}) { return g.V().outE().has("weight", 1.0).outV() }],
+ g_VX1X_outE_otherV: [function({g, vid1}) { return g.V(vid1).outE().otherV() }],
+ g_VX4X_bothE_otherV: [function({g, vid4}) { return g.V(vid4).bothE().otherV() }],
+ g_VX4X_bothE_hasXweight_lt_1X_otherV: [function({g, vid4}) { return g.V(vid4).bothE().has("weight", P.lt(1.0)).otherV() }],
+ get_g_VX1X_outE_otherV: [function({g, vid1}) { return g.V(vid1).outE().otherV() }],
+ g_VX1X_outEXknowsX_inV: [function({g, vid1}) { return g.V(vid1).outE("knows").inV() }],
+ g_VX1X_outEXknows_createdX_inV: [function({g, vid1}) { return g.V(vid1).outE("knows", "created").inV() }],
+ g_VX1X_outEXknowsX_bothV: [function({g, vid1}) { return g.V(vid1).outE("knows").bothV() }],
+ g_VX1X_outEXknowsX_bothV_name: [function({g, vid1}) { return g.V(vid1).outE("knows").bothV().values("name") }],
+ g_V_toEXout_knowsvarX_valuesXweightX: [function({g, xx1}) { return g.V().toE(Direction.OUT, xx1).values("weight") }],
- g_VX1X_properties_element: [function({g, v2}) { return g.V(v2).properties().element().limit(1) }],
+ g_VX1X_properties_element: [function({g, vid2}) { return g.V(vid2).properties().element().limit(1) }],
g_V_properties_element: [function({g}) { return g.V().properties().element() }],
g_V_propertiesXageX_element: [function({g}) { return g.V().properties("age").element() }],
g_EX_properties_element: [function({g, eid11}) { return g.E(eid11).properties().element().limit(1) }],
diff --cc gremlin-language/src/main/antlr4/Gremlin.g4
index ef4d9a4e4e,a2ae6fea14..c378bc5208
--- a/gremlin-language/src/main/antlr4/Gremlin.g4
+++ b/gremlin-language/src/main/antlr4/Gremlin.g4
@@@ -1502,16 -1489,6 +1494,11 @@@ genericMapNullableArgumen
| variable
;
+nullableGenericLiteralMap
+ : genericMapLiteral
+ | nullLiteral
+ ;
+
- structureVertexArgument
- : structureVertexLiteral
- | variable
- ;
-
traversalStrategyVarargs
: traversalStrategyExpr?
;
diff --cc gremlin-python/src/main/python/gremlin_python/process/traversal.py
index 08ad525252,fb74433348..2f986378b9
--- a/gremlin-python/src/main/python/gremlin_python/process/traversal.py
+++ b/gremlin-python/src/main/python/gremlin_python/process/traversal.py
@@@ -761,258 -734,26 +761,258 @@@ GREMLIN LANGUAG
'''
-class Bytecode(object):
- def __init__(self, bytecode=None):
- self.source_instructions = []
- self.step_instructions = []
- self.bindings = {}
- if bytecode is not None:
- self.source_instructions = list(bytecode.source_instructions)
- self.step_instructions = list(bytecode.step_instructions)
+class GremlinLang(object):
+ conn_p = ['and', 'or']
+
+ def __init__(self, gremlin_lang=None):
+ self.empty_array = []
+
+ self.gremlin = []
+ self.parameters = {}
+ self.options_strategies = []
+ self.param_count = AtomicInteger()
+
+ if gremlin_lang is not None:
+ self.gremlin = list(gremlin_lang.gremlin)
+ self.parameters = dict(gremlin_lang.parameters)
+ self.options_strategies = list(gremlin_lang.options_strategies)
+ self.param_count = gremlin_lang.param_count
+
+ def _add_to_gremlin(self, string_name, *args):
+
+ if string_name == 'CardinalityValueTraversal':
+ self.gremlin.append(
+ f'{self._arg_as_string(args[0][0])}({self._arg_as_string(args[0][1])})')
+ return
+
+ self.gremlin.extend(['.', string_name, '('])
+
+ c = 0
+ while len(args[0]) > c:
+ if c != 0:
+ self.gremlin.append(',')
+ self.gremlin.append(self._arg_as_string(self._convert_argument(args[0][c])))
+ c += 1
+
+ self.gremlin.append(')')
+
+ def _arg_as_string(self, arg):
+
+ if arg is None:
+ return 'null'
+
+ if isinstance(arg, str):
+ return f'{arg!r}' # use repr() format for canonical string rep
+ # return f'"{arg}"'
+ if isinstance(arg, bool):
+ return 'true' if arg else 'false'
+
+ if isinstance(arg, SingleByte):
+ return f'{arg}B'
+ if isinstance(arg, short):
+ return f'{arg}S'
+ if isinstance(arg, long):
+ return f'{arg}L'
+ if isinstance(arg, bigint):
+ return f'{arg}N'
+ if isinstance(arg, int):
+ return f'{arg}'
+ if isinstance(arg, float):
+ # converting floats into doubles for script since python doesn't distinguish and java defaults to double
+ if math.isnan(arg):
+ return "NaN"
+ elif math.isinf(arg) and arg > 0:
+ return "+Infinity"
+ elif math.isinf(arg) and arg < 0:
+ return "-Infinity"
+ else:
+ return f'{arg}D'
+ if isinstance(arg, BigDecimal):
+ return f'{arg.value}M'
+
+ if isinstance(arg, datetime):
+ return f'datetime("{arg.isoformat()}")'
+
+ if isinstance(arg, Enum):
+ tmp = str(arg)
+ if tmp.endswith('_'):
+ return tmp[0:-1]
+ elif '_' in tmp:
+ return f'{tmp.split("_")[0]}{tmp.split("_")[1].capitalize()}'
+ else:
+ return tmp
+
+ if isinstance(arg, Vertex):
- return f'new ReferenceVertex({self._arg_as_string(arg.id)},\'{arg.label}\')'
++ return f'{self._arg_as_string(arg.id)}'
+
+ if isinstance(arg, P):
+ return self._process_predicate(arg)
+
+ if isinstance(arg, GremlinLang) or isinstance(arg, Traversal):
+ gremlin_lang = arg if isinstance(arg, GremlinLang) else arg.gremlin_lang
+ self.parameters.update(gremlin_lang.parameters)
+ return gremlin_lang.get_gremlin('__')
+
+ if isinstance(arg, GValue):
+ key = arg.get_name()
+
+ if not key.isidentifier():
+ raise Exception(f'invalid parameter name {key}.')
+
+ if key in self.parameters:
+ if self.parameters[key] != arg.value:
+ raise Exception(f'parameter with name {key} already exists.')
+ else:
+ self.parameters[key] = arg.value
+ return key
+
+ if isinstance(arg, dict):
+ return self._process_dict(arg)
+
+ if isinstance(arg, set):
+ return self._process_set(arg)
+
+ if isinstance(arg, list):
+ return self._process_list(arg)
+
+ if hasattr(arg, '__class__'):
+ try:
+ return arg.__name__
+ except AttributeError:
+ pass
+
+ return self._as_parameter(arg)
+
+ def _as_parameter(self, arg):
+ param_name = f'_{self.param_count.get_and_increment()}'
+ self.parameters[param_name] = arg
+ return param_name
+
+ # Do special processing needed to format predicates that come in
+ # such as "gt(a)" correctly.
+ def _process_predicate(self, p):
+ res = []
+ if p.operator in self.conn_p:
+ res.append(f'{self._process_predicate(p.value)}.{p.operator}({self._process_predicate(p.other)})')
+ else:
+ res.append(f'{self._process_p_value(p)}')
+ return ''.join(res)
+
+ # process the value of the predicates
+ def _process_p_value(self, p):
+ c = 0
+ res = [str(p).split('(')[0] + '(']
+ if isinstance(p.value, list):
+ res.append('[')
+ for v in p.value:
+ if c > 0:
+ res.append(',')
+ res.append(self._arg_as_string(v))
+ c += 1
+ res.append(']')
+ else:
+ res.append(self._arg_as_string(p.value))
+ if p.other is not None:
+ res.append(f',{self._arg_as_string(p.other)}')
+ res.append(')')
+ return ''.join(res)
+
+ def _process_dict(self, d):
+ c = 0
+ res = ['[']
+ if len(d) == 0:
+ res.append(':')
+ else:
+ for k, v in d.items():
+ wrap = not isinstance(k, str)
+ if c > 0:
+ res.append(',')
+ res.append(f'({self._arg_as_string(k)})') if wrap else res.append(self._arg_as_string(k))
+ res.append(f':{self._arg_as_string(v)}')
+ c += 1
+ res.append(']')
+ return ''.join(res)
+
+ def _process_set(self, s):
+ c = 0
+ res = ['{']
+ for i in s:
+ if c > 0:
+ res.append(',')
+ res.append(self._arg_as_string(i))
+ c += 1
+ res.append('}')
+ return ''.join(res)
+
+ def _process_list(self, lst):
+ c = 0
+ res = ['[']
+ for i in lst:
+ if c > 0:
+ res.append(',')
+ res.append(self._arg_as_string(i))
+ c += 1
+ res.append(']')
+ return ''.join(res)
+
+ def get_gremlin(self, g='g'):
+ # special handling for CardinalityValueTraversal
+ if len(self.gremlin) != 0 and self.gremlin[0] != '.':
+ return ''.join(self.gremlin)
+
+ return g + ''.join(self.gremlin)
+
+ def get_parameters(self):
+ return self.parameters
+
+ def add_g(self, g):
+ self.parameters['g'] = g
+
+ def reset(self):
+ self.param_count.set(0)
def add_source(self, source_name, *args):
- instruction = [source_name]
+
+ if source_name == 'withStrategies' and len(args) != 0:
+ args = self.build_strategy_args(args)
+ if len(args) != 0:
+ self.gremlin.append('.')
+ self.gremlin.append(f'withStrategies({args})')
+ return
+ self._add_to_gremlin(source_name, args)
+
+ def build_strategy_args(self, args):
+ res = []
+ c = 0
for arg in args:
- instruction.append(self.__convertArgument(arg))
- self.source_instructions.append(instruction)
+ if c > 0:
+ res.append(',')
+ # special handling for OptionsStrategy
+ from gremlin_python.process.strategies import OptionsStrategy
+ if isinstance(arg, OptionsStrategy):
+ self.options_strategies.append(arg)
+ break
+ if not arg.configuration:
+ res.append(arg.strategy_name)
+ else:
+ res.append(f'new {str(arg)}(')
+ ct = 0
+ for key in arg.configuration:
+ if ct > 0:
+ res.append(',')
+ res.append(f'{key}:')
+ val = arg.configuration[key]
+ if isinstance(val, Traversal):
+ res.append(self._arg_as_string(val.gremlin_lang))
+ else:
+ res.append(self._arg_as_string(val))
+ ct += 1
+ res.append(')')
+ c += 1
+ return ''.join(res)
def add_step(self, step_name, *args):
- instruction = [step_name]
- for arg in args:
- instruction.append(self.__convertArgument(arg))
- self.step_instructions.append(instruction)
+ self._add_to_gremlin(step_name, args)
def __eq__(self, other):
if isinstance(other, self.__class__):
diff --cc gremlin-python/src/main/python/radish/gremlin.py
index c03cc54a58,27a45da568..edf5d5e9f4
--- a/gremlin-python/src/main/python/radish/gremlin.py
+++ b/gremlin-python/src/main/python/radish/gremlin.py
@@@ -211,15 -200,12 +211,15 @@@ world.gremlins =
'g_V_hasXage_isXgt_30XX': [(lambda g:g.V().has('age', __.is_(P.gt(30))))],
'g_V_hasXlabel_isXsoftwareXX': [(lambda g:g.V().has(T.label, __.is_('software')))],
'g_VX1X_hasXage_gt_30X': [(lambda g, vid1=None:g.V(vid1).has('age', P.gt(30)))],
+ 'g_V_hasXpersonvar_age_gt_30X': [(lambda g, xx1=None:g.V().has(xx1, 'age', P.gt(30)))],
'g_VX4X_hasXage_gt_30X': [(lambda g, vid4=None:g.V(vid4).has('age', P.gt(30)))],
- 'g_VXv1X_hasXage_gt_30X': [(lambda g, v1=None:g.V(v1).has('age', P.gt(30)))],
- 'g_VXv4X_hasXage_gt_30X': [(lambda g, v4=None:g.V(v4).has('age', P.gt(30)))],
- 'g_VX1X_out_hasXid_2X': [(lambda g, v2=None:g.V(v2).has('age', P.gt(30)))],
+ 'g_VXv1X_hasXage_gt_30X': [(lambda g, vid1=None:g.V(vid1).has('age', P.gt(30)))],
+ 'g_VXv4X_hasXage_gt_30X': [(lambda g, vid4=None:g.V(vid4).has('age', P.gt(30)))],
+ 'g_VX1X_out_hasXid_2X': [(lambda g, vid2=None:g.V(vid2).has('age', P.gt(30)))],
'g_V_hasXblahX': [(lambda g:g.V().has('blah'))],
'g_V_hasXperson_name_markoX_age': [(lambda g:g.V().has('person', 'name', 'marko').values('age'))],
+ 'g_V_hasXperson_name_markovarX_age': [(lambda g, xx1=None:g.V().has('person', 'name', xx1).values('age'))],
+ 'g_V_hasXpersonvar_name_markoX_age': [(lambda g, xx1=None:g.V().has(xx1, 'name', 'marko').values('age'))],
'g_VX1X_outE_hasXweight_inside_0_06X_inV': [(lambda g, vid1=None:g.V(vid1).out_e().has('weight', P.inside(0.0, 0.6)).in_v())],
'g_EX11X_outV_outE_hasXid_10X': [(lambda g, eid11=None,eid10=None:g.E(eid11).out_v().out_e().has(T.id_, eid10))],
'g_EX11X_outV_outE_hasXid_10AsStringX': [(lambda g, eid11=None,eid10=None:g.E(eid11).out_v().out_e().has(T.id_, eid10))],
@@@ -589,21 -552,16 +589,21 @@@
'g_V_aggregateXxX_asXaX_selectXxX_unfold_addEXexistsWithX_toXaX_propertyXtime_nowX': [(lambda g, vid1=None,vid2=None,vid3=None,vid4=None,vid5=None,vid6=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property( [...]
'g_V_asXaX_outXcreatedX_inXcreatedX_whereXneqXaXX_asXbX_addEXcodeveloperX_fromXaX_toXbX_propertyXyear_2009X': [(lambda g, vid1=None,vid2=None,vid4=None,vid6=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').prop [...]
'g_V_asXaX_inXcreatedX_addEXcreatedByX_fromXaX_propertyXyear_2009X_propertyXacl_publicX': [(lambda g, vid1=None,vid2=None,vid3=None,vid4=None,vid5=None,vid6=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').prop [...]
- 'g_withSideEffectXb_bX_VXaX_addEXknowsX_toXbX_propertyXweight_0_5X': [(lambda g, v6=None,v1=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripple').add [...]
+ 'g_withSideEffectXb_bX_VXaX_addEXknowsX_toXbX_propertyXweight_0_5X': [(lambda g, vid6=None,vid1=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripple') [...]
'g_addV_asXfirstX_repeatXaddEXnextX_toXaddVX_inVX_timesX5X_addEXnextX_toXselectXfirstXX': [(lambda g:g.add_v().as_('first').repeat(__.add_e('next').to(__.add_v()).in_v()).times(5).add_e('next').to(__.select('first'))), (lambda g:g.V()), (lambda g:g.E()), (lambda g:g.E().has_label('next')), (lambda g:g.V().limit(1).both_e()), (lambda g:g.V().limit(1).in_e()), (lambda g:g.V().limit(1).out_e())],
- 'g_V_hasXname_markoX_asXaX_outEXcreatedX_asXbX_inV_addEXselectXbX_labelX_toXaX': [(lambda g, v1=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripple') [...]
- 'g_addEXV_outE_label_groupCount_orderXlocalX_byXvalues_descX_selectXkeysX_unfold_limitX1XX_fromXV_hasXname_vadasXX_toXV_hasXname_lopXX': [(lambda g, v2=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property( [...]
- 'g_addEXknowsX_fromXaX_toXbX_propertyXweight_0_1X': [(lambda g, v6=None,xx1=None,v1=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripple').add_v('pers [...]
- 'g_addEXknowsvarX_fromXaX_toXbX_propertyXweight_0_1X': [(lambda g, xx1=None,v6=None,xx2=None,v1=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripple') [...]
- 'g_VXaX_addEXknowsX_toXbX_propertyXweight_0_1X': [(lambda g, v6=None,xx1=None,v1=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripple').add_v('person' [...]
+ 'g_V_hasXname_markoX_asXaX_outEXcreatedX_asXbX_inV_addEXselectXbX_labelX_toXaX': [(lambda g, vid1=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripple [...]
+ 'g_addEXV_outE_label_groupCount_orderXlocalX_byXvalues_descX_selectXkeysX_unfold_limitX1XX_fromXV_hasXname_vadasXX_toXV_hasXname_lopXX': [(lambda g, vid2=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').propert [...]
+ 'g_addEXknowsX_fromXaX_toXbX_propertyXweight_0_1X': [(lambda g, xx1=None,vid6=None,vid1=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripple').add_v(' [...]
++ 'g_addEXknowsvarX_fromXaX_toXbX_propertyXweight_0_1X': [(lambda g, xx1=None,vid6=None,xx2=None,vid1=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripp [...]
+ 'g_VXaX_addEXknowsX_toXbX_propertyXweight_0_1X': [(lambda g, xx1=None,vid6=None,vid1=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripple').add_v('per [...]
'g_addEXknowsXpropertyXweight_nullXfromXV_hasXname_markoXX_toXV_hasXname_vadasXX': [(lambda g:g.add_v('person').property('name', 'marko').property('age', 29).add_v('person').property('name', 'vadas').property('age', 27)), (lambda g:g.add_e('knows').property('weight', None).from_(__.V().has('name', 'marko')).to(__.V().has('name', 'vadas'))), (lambda g:g.E().has('knows', 'weight', None))],
+ 'g_addEXknowsvarXpropertyXweight_nullXfromXV_hasXname_markoXX_toXV_hasXname_vadasXX': [(lambda g, xx1=None:g.add_v('person').property('name', 'marko').property('age', 29).add_v('person').property('name', 'vadas').property('age', 27)), (lambda g, xx1=None:g.add_e(xx1).property('weight', None).from_(__.V().has('name', 'marko')).to(__.V().has('name', 'vadas'))), (lambda g, xx1=None:g.E().has('knows', 'weight', None))],
+ 'g_unionXaddEXknowsvarXpropertyXweight_nullXfromXV_hasXname_markoXX_toXV_hasXname_vadasXXX': [(lambda g, xx1=None:g.add_v('person').property('name', 'marko').property('age', 29).add_v('person').property('name', 'vadas').property('age', 27)), (lambda g, xx1=None:g.union(__.add_e(xx1).property('weight', 1).from_(__.V().has('name', 'marko')).to(__.V().has('name', 'vadas')))), (lambda g, xx1=None:g.E().has('knows', 'weight', 1))],
'g_VX1X_addVXanimalX_propertyXage_selectXaX_byXageXX_propertyXname_puppyX': [(lambda g, vid1=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripple').ad [...]
'g_V_addVXanimalX_propertyXage_0X': [(lambda g:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripple').add_v('person').property('name', 'peter').property('a [...]
+ 'g_V_addVXanimalvarX_propertyXage_0varX': [(lambda g, xx1=None,xx2=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripple').add_v('person').property('na [...]
'g_addVXpersonX_propertyXname_stephenX': [(lambda g:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripple').add_v('person').property('name', 'peter').proper [...]
+ 'g_addVXpersonvarX_propertyXname_stephenvarX': [(lambda g, xx1=None,xx2=None:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripple').add_v('person').propert [...]
'g_V_hasLabelXpersonX_propertyXname_nullX': [(lambda g:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripple').add_v('person').property('name', 'peter').pro [...]
'g_addVXpersonX_propertyXsingle_name_stephenX_propertyXsingle_name_stephenmX': [(lambda g:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripple').add_v('per [...]
'get_g_addVXpersonX_propertyXsingle_name_stephenX_propertyXsingle_name_stephenm_since_2010X': [(lambda g:g.add_v('person').property('name', 'marko').property('age', 29).as_('marko').add_v('person').property('name', 'vadas').property('age', 27).as_('vadas').add_v('software').property('name', 'lop').property('lang', 'java').as_('lop').add_v('person').property('name', 'josh').property('age', 32).as_('josh').add_v('software').property('name', 'ripple').property('lang', 'java').as_('ripp [...]
@@@ -810,19 -761,7 +810,19 @@@
'g_V_EXlistXnullXX': [(lambda g, xx1=None:g.V().E(xx1))],
'g_injectX1X_EX11_nullX': [(lambda g, eid11=None:g.inject(1).E(eid11, None))],
'g_injectX1X_coalesceXEX_hasLabelXtestsX_addEXtestsX_from_V_hasXnameX_XjoshXX_toXV_hasXnameX_XvadasXXX': [(lambda g:g.add_v('person').property('name', 'josh').add_v('person').property('name', 'vadas')), (lambda g:g.inject(1).coalesce(__.E().has_label('tests'), __.add_e('tests').from_(__.V().has('name', 'josh')).to(__.V().has('name', 'vadas')))), (lambda g:g.E().has_label('tests'))],
+ 'g_VX1X_outE_inV': [(lambda g, vid1=None:g.V(vid1).out_e().in_v())],
+ 'g_VX2X_inE_outV': [(lambda g, vid2=None:g.V(vid2).in_e().out_v())],
+ 'g_V_outE_hasXweight_1X_outV': [(lambda g:g.V().out_e().has('weight', 1.0).out_v())],
+ 'g_VX1X_outE_otherV': [(lambda g, vid1=None:g.V(vid1).out_e().other_v())],
+ 'g_VX4X_bothE_otherV': [(lambda g, vid4=None:g.V(vid4).both_e().other_v())],
+ 'g_VX4X_bothE_hasXweight_lt_1X_otherV': [(lambda g, vid4=None:g.V(vid4).both_e().has('weight', P.lt(1.0)).other_v())],
+ 'get_g_VX1X_outE_otherV': [(lambda g, vid1=None:g.V(vid1).out_e().other_v())],
+ 'g_VX1X_outEXknowsX_inV': [(lambda g, vid1=None:g.V(vid1).out_e('knows').in_v())],
+ 'g_VX1X_outEXknows_createdX_inV': [(lambda g, vid1=None:g.V(vid1).out_e('knows', 'created').in_v())],
+ 'g_VX1X_outEXknowsX_bothV': [(lambda g, vid1=None:g.V(vid1).out_e('knows').both_v())],
+ 'g_VX1X_outEXknowsX_bothV_name': [(lambda g, vid1=None:g.V(vid1).out_e('knows').both_v().values('name'))],
+ 'g_V_toEXout_knowsvarX_valuesXweightX': [(lambda g, xx1=None:g.V().to_e(Direction.OUT, xx1).values('weight'))],
- 'g_VX1X_properties_element': [(lambda g, v2=None:g.V(v2).properties().element().limit(1))],
+ 'g_VX1X_properties_element': [(lambda g, vid2=None:g.V(vid2).properties().element().limit(1))],
'g_V_properties_element': [(lambda g:g.V().properties().element())],
'g_V_propertiesXageX_element': [(lambda g:g.V().properties('age').element())],
'g_EX_properties_element': [(lambda g, eid11=None:g.E(eid11).properties().element().limit(1))],
diff --cc gremlin-python/src/main/python/tests/driver/test_driver_remote_connection.py
index 471a7a375d,eb6beee5c6..bce31840bd
--- a/gremlin-python/src/main/python/tests/driver/test_driver_remote_connection.py
+++ b/gremlin-python/src/main/python/tests/driver/test_driver_remote_connection.py
@@@ -27,106 -29,18 +27,106 @@@ from gremlin_python.process.traversal i
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.anonymous_traversal import traversal
from gremlin_python.structure.graph import Vertex
-from gremlin_python.process.strategies import SubgraphStrategy, ReservedKeysVerificationStrategy, SeedStrategy
+from gremlin_python.process.strategies import SubgraphStrategy, SeedStrategy, ReservedKeysVerificationStrategy
from gremlin_python.structure.io.util import HashableDict
-from gremlin_python.driver.serializer import GraphSONSerializersV2d0
-
-__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
-
-from tests.conftest import anonymous_url
+from gremlin_python.driver.protocol import GremlinServerError
+from gremlin_python.driver import serializer
-gremlin_server_url = os.environ.get('GREMLIN_SERVER_URL', 'ws://localhost:{}/gremlin')
+gremlin_server_url = os.environ.get('GREMLIN_SERVER_URL', 'http://localhost:{}/')
test_no_auth_url = gremlin_server_url.format(45940)
+
class TestDriverRemoteConnection(object):
+
+ # this is a temporary test for basic graphSONV4 connectivity, once all types are implemented, enable graphSON testing
+ # in conftest.py and remove this
+ def test_graphSONV4_temp(self):
+ remote_conn = DriverRemoteConnection(test_no_auth_url, 'gmodern',
+ request_serializer=serializer.GraphSONSerializersV4(),
+ response_serializer=serializer.GraphSONSerializersV4())
+ g = traversal().with_(remote_conn)
+ assert long(6) == g.V().count().to_list()[0]
+ # #
+ assert Vertex(1) == g.V(1).next()
+ assert Vertex(1) == g.V(Vertex(1)).next()
+ assert 1 == g.V(1).id_().next()
+ # assert Traverser(Vertex(1)) == g.V(1).nextTraverser() # TODO check back after bulking added back
+ assert 1 == len(g.V(1).to_list())
+ assert isinstance(g.V(1).to_list(), list)
+ results = g.V().repeat(__.out()).times(2).name
+ results = results.to_list()
+ assert 2 == len(results)
+ assert "lop" in results
+ assert "ripple" in results
+ # #
+ assert 10 == g.V().repeat(__.both()).times(5)[0:10].count().next()
+ assert 1 == g.V().repeat(__.both()).times(5)[0:1].count().next()
+ assert 0 == g.V().repeat(__.both()).times(5)[0:0].count().next()
+ assert 4 == g.V()[2:].count().next()
+ assert 2 == g.V()[:2].count().next()
+ # #
+ results = g.with_side_effect('a', ['josh', 'peter']).V(1).out('created').in_('created').values('name').where(
+ P.within('a')).to_list()
+ assert 2 == len(results)
+ assert 'josh' in results
+ assert 'peter' in results
+ # #
+ results = g.V().has('name', 'peter').as_('a').out('created').as_('b').select('a', 'b').by(
+ __.value_map()).to_list()
+ assert 1 == len(results)
+ assert 'peter' == results[0]['a']['name'][0]
+ assert 35 == results[0]['a']['age'][0]
+ assert 'lop' == results[0]['b']['name'][0]
+ assert 'java' == results[0]['b']['lang'][0]
+ assert 2 == len(results[0]['a'])
+ assert 2 == len(results[0]['b'])
+ # #
- results = g.V(1).inject(g.V(2).next()).values('name').to_list()
++ results = g.V(1, 2).inject().values('name').to_list()
+ assert 2 == len(results)
+ assert 'marko' in results
+ assert 'vadas' in results
+ # #
+ # this test just validates that the underscored versions of steps conflicting with Gremlin work
+ # properly and can be removed when the old steps are removed - TINKERPOP-2272
+ results = g.V().filter_(__.values('age').sum_().and_(
+ __.max_().is_(P.gt(0)), __.min_().is_(P.gt(0)))).range_(0, 1).id_().next()
+ assert 1 == results
+ # #
+ # test dict keys
+ # types for dict
+ results = g.V().has('person', 'name', 'marko').element_map("name").group_count().next()
+ assert {HashableDict.of({T.id: 1, T.label: 'person', 'name': 'marko'}): 1} == results
+ results = g.V().has('person', 'name', 'marko').both('knows').group_count().by(__.values('name').fold()).next()
+ assert {tuple(['vadas']): 1, tuple(['josh']): 1} == results
+
+ def test_bulk_request_option(self, remote_connection):
+ g = traversal().with_(remote_connection)
+ result = g.inject(1,2,3,2,1).to_list()
+ assert 5 == len(result)
+ bulked_results = g.with_("language", "gremlin-lang").with_("bulkResults", True).inject(1,2,3,2,1).to_list()
+ assert 5 == len(bulked_results)
+
+ def test_extract_request_options(self, remote_connection):
+ g = traversal().with_(remote_connection)
+ t = g.with_("evaluationTimeout", 1000).with_("batchSize", 100).V().count()
+ assert remote_connection.extract_request_options(t.gremlin_lang) == {'batchSize': 100,
+ 'evaluationTimeout': 1000,
+ 'bulkResults': True}
+ assert 6 == t.to_list()[0]
+
+ @pytest.mark.skip(reason="investigate why 'ids' parameter name fails to parse in gremlin-lang")
+ def test_extract_request_options_with_params(self, remote_connection):
+ g = traversal().with_(remote_connection)
+ t = g.with_("evaluationTimeout",
+ 1000).with_("batchSize", 100).with_("userAgent",
+ "test").V(GValue('ids', [1, 2, 3])).count()
+ assert remote_connection.extract_request_options(t.gremlin_lang) == {'batchSize': 100,
+ 'evaluationTimeout': 1000,
+ 'userAgent': 'test',
+ 'bulkResults': True,
+ 'params': {'ids': [1, 2, 3]}}
+ assert 3 == t.to_list()[0]
+
def test_traversals(self, remote_connection):
statics.load_statics(globals())
g = traversal().with_(remote_connection)
@@@ -173,7 -85,7 +173,7 @@@
assert 2 == len(results[0]['a'])
assert 2 == len(results[0]['b'])
# #
- results = g.V(1).inject(g.V(2).next()).values('name').to_list()
- results = g.V(1).inject(g.V(2).next()).values('name').toList()
++ results = g.V(1, 2).values('name').to_list()
assert 2 == len(results)
assert 'marko' in results
assert 'vadas' in results
diff --cc gremlin-python/src/main/python/tests/process/test_gremlin_lang.py
index e4c60c8bc8,9c5a74da9e..e71d65d62c
--- a/gremlin-python/src/main/python/tests/process/test_gremlin_lang.py
+++ b/gremlin-python/src/main/python/tests/process/test_gremlin_lang.py
@@@ -410,12 -388,12 +410,12 @@@ class TestGremlinLang(object)
tests.append([g.V().has("p1", None),
"g.V().has('p1',null)"])
- # 104
+ # 106
vertex = Vertex(0, "person")
tests.append([g.V(vertex),
-- "g.V(new ReferenceVertex(0,'person'))"])
++ "g.V(0)"])
- # 105
+ # 107
outVertex = Vertex(0, "person")
inVertex = Vertex(1, "person")
edge = Edge(2, outVertex, "knows", inVertex)
diff --cc gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereTest.java
index 0dc5d10091,0dc5d10091..5564d331bb
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereTest.java
@@@ -46,6 -46,6 +46,7 @@@ import static org.apache.tinkerpop.grem
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.and;
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.as;
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.bothE;
++import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.id;
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.in;
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.not;
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.or;
@@@ -91,7 -91,7 +92,7 @@@ public abstract class WhereTest extend
public abstract Traversal<Vertex, Vertex> get_g_VX1X_out_aggregateXxX_out_whereXnotXwithinXaXXX(final Object v1Id);
-- public abstract Traversal<Vertex, Vertex> get_g_withSideEffectXa_graph_verticesX2XX_VX1X_out_whereXneqXaXX(final Object v1Id, final Object v2Id);
++ public abstract Traversal<Vertex, Vertex> get_g_withSideEffectXa_graph_verticesX2XX_VX1X_out_whereXid_whereXneqXaXXX(final Object v1Id, final Object v2Id);
public abstract Traversal<Vertex, Path> get_g_VX1X_repeatXbothEXcreatedX_whereXwithoutXeXX_aggregateXeX_otherVX_emit_path(final Object v1Id);
@@@ -276,8 -276,8 +277,8 @@@
@Test
@LoadGraphWith(MODERN)
-- public void g_withSideEffectXa_g_VX2XX_VX1X_out_whereXneqXaXX() {
-- final Traversal<Vertex, Vertex> traversal = get_g_withSideEffectXa_graph_verticesX2XX_VX1X_out_whereXneqXaXX(convertToVertexId("marko"), convertToVertex(graph,"vadas"));
++ public void g_withSideEffectXa_graph_verticesX2XX_VX1X_out_whereXid_whereXneqXaXXX() {
++ final Traversal<Vertex, Vertex> traversal = get_g_withSideEffectXa_graph_verticesX2XX_VX1X_out_whereXid_whereXneqXaXXX(convertToVertexId("marko"), convertToVertexId("vadas"));
printTraversalForm(traversal);
int counter = 0;
final Set<Vertex> vertices = new HashSet<>();
@@@ -483,8 -483,8 +484,8 @@@
}
@Override
-- public Traversal<Vertex, Vertex> get_g_withSideEffectXa_graph_verticesX2XX_VX1X_out_whereXneqXaXX(final Object v1Id, final Object v2) {
-- return g.withSideEffect("a", v2).V(v1Id).out().where(neq("a"));
++ public Traversal<Vertex, Vertex> get_g_withSideEffectXa_graph_verticesX2XX_VX1X_out_whereXid_whereXneqXaXXX(final Object v1Id, final Object v2Id) {
++ return g.withSideEffect("a", v2Id).V(v1Id).out().where(id().where(neq("a")));
}
@Override
diff --cc gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/InjectTest.java
index a5151bec76,a5151bec76..854d7cfada
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/InjectTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/InjectTest.java
@@@ -43,10 -43,10 +43,6 @@@ import static org.junit.Assert.assertFa
@RunWith(GremlinProcessRunner.class)
public abstract class InjectTest extends AbstractGremlinProcessTest {
-- public abstract Traversal<Vertex, String> get_g_VX1X_out_injectXv2X_name(final Object v1Id, final Object v2Id);
--
-- public abstract Traversal<Vertex, String> get_g_VX1X_injectXg_VX4XX_out_name(final Object v1Id, final Object v4Id);
--
public abstract Traversal<Integer, Integer> get_g_injectXnull_1_3_nullX();
public abstract Traversal<Integer, Integer> get_g_injectXnull_nullX();
@@@ -67,22 -67,22 +63,6 @@@
public abstract Traversal<Integer, Integer> get_g_injectXnull_1_3_nullX_asXaX_selectXaX();
-- @Test
-- @LoadGraphWith(MODERN)
-- public void g_VX1X_out_injectXv2X_name() {
-- final Traversal<Vertex, String> traversal = get_g_VX1X_out_injectXv2X_name(convertToVertexId("marko"), convertToVertexId("vadas"));
-- printTraversalForm(traversal);
-- final Map<String, Long> counter = new HashMap<>();
-- while (traversal.hasNext()) {
-- MapHelper.incr(counter, traversal.next(), 1l);
-- }
-- assertEquals(3, counter.size());
-- assertEquals(1l, counter.get("josh").longValue());
-- assertEquals(1l, counter.get("lop").longValue());
-- assertEquals(2l, counter.get("vadas").longValue());
-- assertFalse(traversal.hasNext());
-- }
--
@Test
public void g_injectXnull_1_3_nullX() {
final Traversal<Integer, Integer> traversal = get_g_injectXnull_1_3_nullX();
@@@ -152,14 -152,14 +132,6 @@@
checkResults(makeMapList(2, "name", "marko", "age", null), traversal);
}
-- @Test
-- @LoadGraphWith(MODERN)
-- public void g_VX1X_injectXg_VX4XX_out_name() {
-- final Traversal<Vertex, String> traversal = get_g_VX1X_injectXg_VX4XX_out_name(convertToVertexId("marko"), convertToVertexId("josh"));
-- printTraversalForm(traversal);
-- checkResults(Arrays.asList("ripple", "lop", "lop", "vadas", "josh"), traversal);
-- }
--
@Test
public void g_injectXnull_1_3_nullX_asXaX_selectXaX() {
final Traversal<Integer, Integer> traversal = get_g_injectXnull_1_3_nullX_asXaX_selectXaX();
@@@ -170,16 -170,16 +142,6 @@@
public static class Traversals extends InjectTest {
@Override
-- public Traversal<Vertex, String> get_g_VX1X_out_injectXv2X_name(final Object v1Id, final Object v2Id) {
-- return g.V(v1Id).out().inject(g.V(v2Id).next()).values("name");
-- }
--
-- @Override
-- public Traversal<Vertex, String> get_g_VX1X_injectXg_VX4XX_out_name(final Object v1Id, final Object v4Id) {
-- return g.V(v1Id).inject(g.V(v4Id).next()).out().values("name");
-- }
--
-- @Override
public Traversal<Integer, Integer> get_g_injectXnull_1_3_nullX() {
return g.inject(null, 1, 3, null);
}
diff --cc gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/map/AddEdge.feature
index 016d6495e1,2fa02fd1c4..31984d4598
--- a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/map/AddEdge.feature
+++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/map/AddEdge.feature
@@@ -385,40 -385,9 +385,40 @@@ Feature: Step - addE(
When iterated to list
Then the result should have a count of 1
And the graph should return 7 for count of "g.E()"
- And the graph should return 3 for count of "g.V(v1).outE(\"knows\")"
- And the graph should return 1 for count of "g.V(v1).out(\"knows\").has(\"name\",\"peter\")"
+ And the graph should return 3 for count of "g.V(vid1).outE(\"knows\")"
+ And the graph should return 1 for count of "g.V(vid1).out(\"knows\").has(\"name\",\"peter\")"
+ Scenario: g_addEXknowsvarX_fromXaX_toXbX_propertyXweight_0_1X
+ Given the empty graph
+ And the graph initializer of
+ """
+ g.addV("person").property("name", "marko").property("age", 29).as("marko").
+ addV("person").property("name", "vadas").property("age", 27).as("vadas").
+ addV("software").property("name", "lop").property("lang", "java").as("lop").
+ addV("person").property("name","josh").property("age", 32).as("josh").
+ addV("software").property("name", "ripple").property("lang", "java").as("ripple").
+ addV("person").property("name", "peter").property("age", 35).as('peter').
+ addE("knows").from("marko").to("vadas").property("weight", 0.5d).
+ addE("knows").from("marko").to("josh").property("weight", 1.0d).
+ addE("created").from("marko").to("lop").property("weight", 0.4d).
+ addE("created").from("josh").to("ripple").property("weight", 1.0d).
+ addE("created").from("josh").to("lop").property("weight", 0.4d).
+ addE("created").from("peter").to("lop").property("weight", 0.2d)
+ """
- And using the parameter v1 defined as "v[marko]"
- And using the parameter v6 defined as "v[peter]"
++ And using the parameter vid1 defined as "v[marko].id"
++ And using the parameter vid6 defined as "v[peter].id"
+ And using the parameter xx1 defined as "knows"
+ And using the parameter xx2 defined as "d[0.1].d"
+ And the traversal of
+ """
- g.addE(xx1).from(v1).to(v6).property("weight", xx2)
++ g.addE(xx1).from(vid1).to(vid6).property("weight", xx2)
+ """
+ When iterated to list
+ Then the result should have a count of 1
+ And the graph should return 7 for count of "g.E()"
- And the graph should return 3 for count of "g.V(v1).outE(\"knows\")"
- And the graph should return 1 for count of "g.V(v1).out(\"knows\").has(\"name\",\"peter\")"
++ And the graph should return 3 for count of "g.V(vid1).outE(\"knows\")"
++ And the graph should return 1 for count of "g.V(vid1).out(\"knows\").has(\"name\",\"peter\")"
+
Scenario: g_VXaX_addEXknowsX_toXbX_propertyXweight_0_1X
Given the empty graph
And the graph initializer of