You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by fl...@apache.org on 2018/03/18 12:03:34 UTC

[01/18] tinkerpop git commit: TINKERPOP-1919 Add Lambda support to Gremlin.Net

Repository: tinkerpop
Updated Branches:
  refs/heads/master 04b7d4ddc -> f7da641d3
  refs/heads/tp32 d3d1ccfa6 -> eeea8696e
  refs/heads/tp33 b8eb8a02f -> 2fd0f2558


TINKERPOP-1919 Add Lambda support to Gremlin.Net

This adds a Lambda class that can be used to construct Groovy or Python
lambdas. The Lambda class implements all interfaces that mirror Javas
functional interfaces like Function.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/0cdaa3a2
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/0cdaa3a2
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/0cdaa3a2

Branch: refs/heads/master
Commit: 0cdaa3a2114670a34999aa56e0487a2e7ef998e1
Parents: 0bf9b2f
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Wed Mar 14 18:56:47 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Thu Mar 15 18:16:05 2018 +0100

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 docs/src/reference/gremlin-variants.asciidoc    | 29 ++++++--
 .../upgrade/release-3.2.x-incubating.asciidoc   |  7 ++
 gremlin-dotnet/glv/generate.groovy              |  4 +-
 .../Process/Traversal/GraphTraversalSource.cs   | 52 +++++++++++++-
 .../Gremlin.Net/Process/Traversal/ISupplier.cs  | 32 +++++++++
 .../Process/Traversal/IUnaryOperator.cs         | 33 +++++++++
 .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 72 ++++++++++++++++++++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  3 +-
 .../Structure/IO/GraphSON/LambdaSerializer.cs   | 43 ++++++++++++
 .../Gherkin/CommonSteps.cs                      |  2 +-
 .../Gherkin/IgnoreException.cs                  |  4 --
 .../TraversalEvaluation/TraversalParser.cs      |  2 +-
 .../IO/GraphSON/GraphSONWriterTests.cs          | 13 ++++
 14 files changed, 282 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 94ee24f..8fcbe1a 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -23,6 +23,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 [[release-3-2-8]]
 === TinkerPop 3.2.8 (Release Date: NOT OFFICIALLY RELEASED YET)
 
+* Added a `Lambda` class to Gremlin.Net that makes it possible to use Groovy and Python lambdas with Gremlin.Net.
 * Enums are now represented as classes in Gremlin.Net which allows to use them as arguments in more steps.
 * Bumped to Groovy 2.4.14.
 * Added `checkAdjacentVertices` option to `SubgraphStrategy`.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index ace8119..bf8c8b1 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -46,7 +46,7 @@ implementation of Gremlin and serves as the foundation by which all other Gremli
 === The Lambda Solution
 
 Supporting link:https://en.wikipedia.org/wiki/Anonymous_function[anonymous functions] across languages is difficult as
-most language do not support lambda introspection and thus, code analysis. In Gremlin-Java, Java8 lambdas can be leveraged.
+most languages do not support lambda introspection and thus, code analysis. In Gremlin-Java, Java8 lambdas can be leveraged.
 
 [source,java]
 g.V().out("knows").map(t -> t.get().value("name") + " is the friend name") <1>
@@ -281,7 +281,7 @@ re-construction machine-side.
 === The Lambda Solution
 
 Supporting link:https://en.wikipedia.org/wiki/Anonymous_function[anonymous functions] across languages is difficult as
-most language do not support lambda introspection and thus, code analysis. In Gremlin-Python,
+most languages do not support lambda introspection and thus, code analysis. In Gremlin-Python,
 a link:https://docs.python.org/2/reference/expressions.html#lambda[Python lambda] should be represented as a zero-arg callable
 that returns a string representation of a lambda. The default lambda language is `gremlin-python` and can be changed via
 `gremlin_python.statics.default_lambda_language`. When the lambda is represented in `Bytecode` its language is encoded
@@ -343,8 +343,10 @@ var g = graph.Traversal().WithRemote(new DriverRemoteConnection(new GremlinClien
 
 When a traversal from the `GraphTraversalSource` is iterated, the traversal’s `Bytecode` is sent over the wire via the registered
 `IRemoteConnection`. The bytecode is used to construct the equivalent traversal at the remote traversal source.
-Since Gremlin.Net currently doesn't support lambda expressions, all traversals can be translated to Gremlin-Java on the remote
-location (e.g. Gremlin Server).
+Moreover, typically the bytecode is analyzed to determine which language the bytecode should be translated to. If the traversal
+does not contain lambdas, the remote location (e.g. Gremlin Server) will typically
+use Gremlin-Java. If it has lambdas written in Groovy, it will use Gremlin-Groovy (e.g. `GremlinGroovyScriptEngine`).
+Likewise, if it has lambdas represented in Python, it will use Gremlin-Python (e.g. `GremlinJythonScriptEngine`).
 
 IMPORTANT: Gremlin.Net’s `ITraversal` interface supports the standard Gremlin methods such as `Next()`, `NextTraverser()`, `ToSet()`,
 `ToList()`, etc. Such "terminal" methods trigger the evaluation of the traversal.
@@ -433,6 +435,25 @@ NOTE: Many of the TraversalStrategy classes in Gremlin.Net are proxies to the re
 JVM-based Gremlin traversal machine. As such, their `Apply(ITraversal)` method does nothing. However, the strategy is
 encoded in the Gremlin.Net bytecode and transmitted to the Gremlin traversal machine for re-construction machine-side.
 
+=== The Lambda Solution
+
+Supporting link:https://en.wikipedia.org/wiki/Anonymous_function[anonymous functions] across languages is difficult as
+most languages do not support lambda introspection and thus, code analysis. While Gremlin.Net doesn't support C# lambdas, it
+is still able to represent lambdas in other languages. When the lambda is represented in `Bytecode` its language is encoded
+such that the remote connection host can infer which translator and ultimate execution engine to use.
+
+[source,csharp]
+----
+g.V().Out().Map<int>(Lambda.Groovy("it.get().value('name').length()")).Sum<int>().ToList();      <1>
+g.V().Out().Map<int>(Lambda.Python("lambda x: len(x.get().value('name'))")).Sum<int>().ToList(); <2>
+----
+
+<1> `Lambda.Groovy()` can be used to create a Groovy lambda. 
+<2> `Lambda.Python()` can be used to create a Python lambda.
+
+The `Lambda` class implements interfaces like `IFunction` and `IPredicate` that mirror their Java counterparts which makes it possible
+to use lambdas with Gremlin.Net for the same steps as in Gremlin-Java.
+
 [[gremlin-javascript]]
 == Gremlin-JavaScript
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 0848843..edc7f79 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -42,6 +42,13 @@ by clients that might mysteriously disappear without properly closing their conn
 
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1726[TINKERPOP-1726]
 
+==== Gremlin.Net Lambdas
+
+Gremlin.Net now has a `Lambda` class that can be used to construct Groovy or Java lambdas which will be evaluated on the
+server.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1854[TINKERPOP-1854], link:http://tinkerpop.apache.org/docs/3.2.8/reference/#_the_lambda_solution_3[Reference Documentation - Gremlin.Net - The Lambda Solution].
+
 ==== Gremlin.Net Tokens Improved
 
 The various Gremlin tokens (e.g. `T`, `Order`, `Operator`, etc.) that were implemented as Enums before in Gremlin.Net

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy
index 5057ff8..10b1008 100644
--- a/gremlin-dotnet/glv/generate.groovy
+++ b/gremlin-dotnet/glv/generate.groovy
@@ -54,10 +54,10 @@ def toCSharpTypeMap = ["Long": "long",
                        "TraversalStrategy[]": "ITraversalStrategy[]",
                        "Function": "IFunction",
                        "BiFunction": "IBiFunction",
-                       "UnaryOperator": "object",
+                       "UnaryOperator": "IUnaryOperator",
                        "BinaryOperator": "IBinaryOperator",
                        "Consumer": "IConsumer",
-                       "Supplier": "object",
+                       "Supplier": "ISupplier",
                        "Comparator": "IComparator",
                        "VertexProgram": "object"]
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
index 9c32559..7115016 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
@@ -104,7 +104,7 @@ namespace Gremlin.Net.Process.Traversal
             return source;
         }
 
-        public GraphTraversalSource WithSack(object initialValue, object splitOperator)
+        public GraphTraversalSource WithSack(object initialValue, IUnaryOperator splitOperator)
         {
             var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
                                                   new Bytecode(Bytecode));
@@ -112,7 +112,39 @@ namespace Gremlin.Net.Process.Traversal
             return source;
         }
 
-        public GraphTraversalSource WithSack(object initialValue, object splitOperator, IBinaryOperator mergeOperator)
+        public GraphTraversalSource WithSack(object initialValue, IUnaryOperator splitOperator, IBinaryOperator mergeOperator)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSack", initialValue, splitOperator, mergeOperator);
+            return source;
+        }
+
+        public GraphTraversalSource WithSack(ISupplier initialValue)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSack", initialValue);
+            return source;
+        }
+
+        public GraphTraversalSource WithSack(ISupplier initialValue, IBinaryOperator mergeOperator)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSack", initialValue, mergeOperator);
+            return source;
+        }
+
+        public GraphTraversalSource WithSack(ISupplier initialValue, IUnaryOperator splitOperator)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSack", initialValue, splitOperator);
+            return source;
+        }
+
+        public GraphTraversalSource WithSack(ISupplier initialValue, IUnaryOperator splitOperator, IBinaryOperator mergeOperator)
         {
             var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
                                                   new Bytecode(Bytecode));
@@ -136,6 +168,22 @@ namespace Gremlin.Net.Process.Traversal
             return source;
         }
 
+        public GraphTraversalSource WithSideEffect(string key, ISupplier initialValue)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSideEffect", key, initialValue);
+            return source;
+        }
+
+        public GraphTraversalSource WithSideEffect(string key, ISupplier initialValue, IBinaryOperator reducer)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSideEffect", key, initialValue, reducer);
+            return source;
+        }
+
         public GraphTraversalSource WithStrategies(params ITraversalStrategy[] traversalStrategies)
         {
             var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ISupplier.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ISupplier.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ISupplier.cs
new file mode 100644
index 0000000..b1dda13
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ISupplier.cs
@@ -0,0 +1,32 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+namespace Gremlin.Net.Process.Traversal
+{
+    /// <summary>
+    ///     Represents a supplier of results
+    /// </summary>
+    public interface ISupplier
+    {
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IUnaryOperator.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IUnaryOperator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IUnaryOperator.cs
new file mode 100644
index 0000000..b57be02
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IUnaryOperator.cs
@@ -0,0 +1,33 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+namespace Gremlin.Net.Process.Traversal
+{
+    /// <summary>
+    ///     Represents an operation on a single operand that produces a result of the same type as its operand. This is a
+    ///     specialization of Function for the case where the operand and result are of the same type.
+    /// </summary>
+    public interface IUnaryOperator : IFunction
+    {
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
new file mode 100644
index 0000000..21849ef
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
@@ -0,0 +1,72 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+namespace Gremlin.Net.Process.Traversal
+{
+    /// <summary>
+    ///     Represents a lambda.
+    /// </summary>
+    public class Lambda : IFunction, IBiFunction, IPredicate, IUnaryOperator, IBinaryOperator, IComparator, IConsumer,
+        ISupplier
+    {
+        private const int DefaultArgument = -1;
+
+        private Lambda(string expression, string language)
+        {
+            LambdaExpression = expression;
+            Language = language;
+        }
+
+        /// <summary>
+        ///     Gets the lambda expression.
+        /// </summary>
+        public string LambdaExpression { get; }
+
+        /// <summary>
+        ///     Gets the language of this lambda.
+        /// </summary>
+        public string Language { get; }
+
+        internal object Arguments => DefaultArgument;
+
+        /// <summary>
+        ///     Creates a new Groovy <see cref="Lambda"/>.
+        /// </summary>
+        /// <param name="expression">The lambda expression.</param>
+        /// <returns>The created <see cref="Lambda"/>.</returns>
+        public static Lambda Groovy(string expression)
+        {
+            return new Lambda(expression, "gremlin-groovy");
+        }
+
+        /// <summary>
+        ///     Creates a new Python <see cref="Lambda"/>.
+        /// </summary>
+        /// <param name="expression">The lambda expression.</param>
+        /// <returns>The created <see cref="Lambda"/>.</returns>
+        public static Lambda Python(string expression)
+        {
+            return new Lambda(expression, "gremlin-python");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
index f23d80d..826d608 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -59,7 +59,8 @@ namespace Gremlin.Net.Structure.IO.GraphSON
                 {typeof(Edge), new EdgeSerializer()},
                 {typeof(Property), new PropertySerializer()},
                 {typeof(VertexProperty), new VertexPropertySerializer()},
-                {typeof(AbstractTraversalStrategy), new TraversalStrategySerializer()}
+                {typeof(AbstractTraversalStrategy), new TraversalStrategySerializer()},
+                {typeof(Lambda), new LambdaSerializer()}
             };
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
new file mode 100644
index 0000000..fa739fd
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
@@ -0,0 +1,43 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+using System.Collections.Generic;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.Structure.IO.GraphSON
+{
+    internal class LambdaSerializer : IGraphSONSerializer
+    {
+        public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
+        {
+            Lambda lambda = objectData;
+            var valueDict = new Dictionary<string, dynamic>
+            {
+                {"script", lambda.LambdaExpression},
+                {"language", lambda.Language},
+                {"arguments", lambda.Arguments}
+            };
+            return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
index 0abc247..dd96474 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
@@ -233,7 +233,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
 
         private static object ToLambda(string stringLambda, string graphName)
         {
-            throw new IgnoreException(IgnoreReason.LambdaNotSupported);
+            return Lambda.Groovy(stringLambda);
         }
 
         private static object ToNumber(string stringNumber, string graphName)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
index fd226bf..9aa5213 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
@@ -40,9 +40,6 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
             string reasonSuffix = null;
             switch (reason)
             {
-                case IgnoreReason.LambdaNotSupported:
-                    reasonSuffix = " because lambdas are not supported in Gremlin.NET (TINKERPOP-1854)";
-                    break;
                 case IgnoreReason.PWithinWrapsArgumentsInArray:
                     reasonSuffix = " because P.Within() arguments are incorrectly wrapped in an array (TINKERPOP-1920)";
                     break;
@@ -56,7 +53,6 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
     
     public enum IgnoreReason
     {
-        LambdaNotSupported,
         PWithinWrapsArgumentsInArray,
         PNotDeserializationProblem
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
index 11145da..7e1486c 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
@@ -398,7 +398,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
             {
                 return ParseNumber(text, ref i);
             }
-            if (text.Substring(i, 3).StartsWith("__."))
+            if (text.Length >= i + 3 && text.Substring(i, 3).StartsWith("__."))
             {
                 var startIndex = i;
                 var tokens = ParseTokens(text, ref i);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
index 3e2d307..54dc8f3 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
@@ -333,6 +333,19 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             const string expected = "{\"@type\":\"g:SubgraphStrategy\",\"@value\":{}}";
             Assert.Equal(expected, graphSon);
         }
+
+        [Fact]
+        public void ShouldSerializeLambda()
+        {
+            var writer = CreateStandardGraphSONWriter();
+            var lambda = Lambda.Groovy("{ it.get() }");
+
+            var graphSon = writer.WriteObject(lambda);
+
+            const string expected =
+                "{\"@type\":\"g:Lambda\",\"@value\":{\"script\":\"{ it.get() }\",\"language\":\"gremlin-groovy\",\"arguments\":-1}}";
+            Assert.Equal(expected, graphSon);
+        }
     }
 
     internal class TestGraphSONSerializer : IGraphSONSerializer


[12/18] tinkerpop git commit: TINKERPOP-1854 Replace StartsWith check with an equality check

Posted by fl...@apache.org.
TINKERPOP-1854 Replace StartsWith check with an equality check


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/4ebc68e8
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/4ebc68e8
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/4ebc68e8

Branch: refs/heads/tp32
Commit: 4ebc68e89e0ba1606e06b42a32ec0bebe14fbdf5
Parents: 820adc4
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Sat Mar 17 16:24:09 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Sat Mar 17 16:24:09 2018 +0100

----------------------------------------------------------------------
 .../Gherkin/TraversalEvaluation/TraversalParser.cs                 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4ebc68e8/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
index 7e1486c..e3f6a3f 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
@@ -398,7 +398,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
             {
                 return ParseNumber(text, ref i);
             }
-            if (text.Length >= i + 3 && text.Substring(i, 3).StartsWith("__."))
+            if (text.Length >= i + 3 && text.Substring(i, 3) == "__.")
             {
                 var startIndex = i;
                 var tokens = ParseTokens(text, ref i);


[02/18] tinkerpop git commit: TINKERPOP-1919 Add Lambda support to Gremlin.Net

Posted by fl...@apache.org.
TINKERPOP-1919 Add Lambda support to Gremlin.Net

This adds a Lambda class that can be used to construct Groovy or Python
lambdas. The Lambda class implements all interfaces that mirror Javas
functional interfaces like Function.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/0cdaa3a2
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/0cdaa3a2
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/0cdaa3a2

Branch: refs/heads/tp32
Commit: 0cdaa3a2114670a34999aa56e0487a2e7ef998e1
Parents: 0bf9b2f
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Wed Mar 14 18:56:47 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Thu Mar 15 18:16:05 2018 +0100

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 docs/src/reference/gremlin-variants.asciidoc    | 29 ++++++--
 .../upgrade/release-3.2.x-incubating.asciidoc   |  7 ++
 gremlin-dotnet/glv/generate.groovy              |  4 +-
 .../Process/Traversal/GraphTraversalSource.cs   | 52 +++++++++++++-
 .../Gremlin.Net/Process/Traversal/ISupplier.cs  | 32 +++++++++
 .../Process/Traversal/IUnaryOperator.cs         | 33 +++++++++
 .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 72 ++++++++++++++++++++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  3 +-
 .../Structure/IO/GraphSON/LambdaSerializer.cs   | 43 ++++++++++++
 .../Gherkin/CommonSteps.cs                      |  2 +-
 .../Gherkin/IgnoreException.cs                  |  4 --
 .../TraversalEvaluation/TraversalParser.cs      |  2 +-
 .../IO/GraphSON/GraphSONWriterTests.cs          | 13 ++++
 14 files changed, 282 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 94ee24f..8fcbe1a 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -23,6 +23,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 [[release-3-2-8]]
 === TinkerPop 3.2.8 (Release Date: NOT OFFICIALLY RELEASED YET)
 
+* Added a `Lambda` class to Gremlin.Net that makes it possible to use Groovy and Python lambdas with Gremlin.Net.
 * Enums are now represented as classes in Gremlin.Net which allows to use them as arguments in more steps.
 * Bumped to Groovy 2.4.14.
 * Added `checkAdjacentVertices` option to `SubgraphStrategy`.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index ace8119..bf8c8b1 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -46,7 +46,7 @@ implementation of Gremlin and serves as the foundation by which all other Gremli
 === The Lambda Solution
 
 Supporting link:https://en.wikipedia.org/wiki/Anonymous_function[anonymous functions] across languages is difficult as
-most language do not support lambda introspection and thus, code analysis. In Gremlin-Java, Java8 lambdas can be leveraged.
+most languages do not support lambda introspection and thus, code analysis. In Gremlin-Java, Java8 lambdas can be leveraged.
 
 [source,java]
 g.V().out("knows").map(t -> t.get().value("name") + " is the friend name") <1>
@@ -281,7 +281,7 @@ re-construction machine-side.
 === The Lambda Solution
 
 Supporting link:https://en.wikipedia.org/wiki/Anonymous_function[anonymous functions] across languages is difficult as
-most language do not support lambda introspection and thus, code analysis. In Gremlin-Python,
+most languages do not support lambda introspection and thus, code analysis. In Gremlin-Python,
 a link:https://docs.python.org/2/reference/expressions.html#lambda[Python lambda] should be represented as a zero-arg callable
 that returns a string representation of a lambda. The default lambda language is `gremlin-python` and can be changed via
 `gremlin_python.statics.default_lambda_language`. When the lambda is represented in `Bytecode` its language is encoded
@@ -343,8 +343,10 @@ var g = graph.Traversal().WithRemote(new DriverRemoteConnection(new GremlinClien
 
 When a traversal from the `GraphTraversalSource` is iterated, the traversal’s `Bytecode` is sent over the wire via the registered
 `IRemoteConnection`. The bytecode is used to construct the equivalent traversal at the remote traversal source.
-Since Gremlin.Net currently doesn't support lambda expressions, all traversals can be translated to Gremlin-Java on the remote
-location (e.g. Gremlin Server).
+Moreover, typically the bytecode is analyzed to determine which language the bytecode should be translated to. If the traversal
+does not contain lambdas, the remote location (e.g. Gremlin Server) will typically
+use Gremlin-Java. If it has lambdas written in Groovy, it will use Gremlin-Groovy (e.g. `GremlinGroovyScriptEngine`).
+Likewise, if it has lambdas represented in Python, it will use Gremlin-Python (e.g. `GremlinJythonScriptEngine`).
 
 IMPORTANT: Gremlin.Net’s `ITraversal` interface supports the standard Gremlin methods such as `Next()`, `NextTraverser()`, `ToSet()`,
 `ToList()`, etc. Such "terminal" methods trigger the evaluation of the traversal.
@@ -433,6 +435,25 @@ NOTE: Many of the TraversalStrategy classes in Gremlin.Net are proxies to the re
 JVM-based Gremlin traversal machine. As such, their `Apply(ITraversal)` method does nothing. However, the strategy is
 encoded in the Gremlin.Net bytecode and transmitted to the Gremlin traversal machine for re-construction machine-side.
 
+=== The Lambda Solution
+
+Supporting link:https://en.wikipedia.org/wiki/Anonymous_function[anonymous functions] across languages is difficult as
+most languages do not support lambda introspection and thus, code analysis. While Gremlin.Net doesn't support C# lambdas, it
+is still able to represent lambdas in other languages. When the lambda is represented in `Bytecode` its language is encoded
+such that the remote connection host can infer which translator and ultimate execution engine to use.
+
+[source,csharp]
+----
+g.V().Out().Map<int>(Lambda.Groovy("it.get().value('name').length()")).Sum<int>().ToList();      <1>
+g.V().Out().Map<int>(Lambda.Python("lambda x: len(x.get().value('name'))")).Sum<int>().ToList(); <2>
+----
+
+<1> `Lambda.Groovy()` can be used to create a Groovy lambda. 
+<2> `Lambda.Python()` can be used to create a Python lambda.
+
+The `Lambda` class implements interfaces like `IFunction` and `IPredicate` that mirror their Java counterparts which makes it possible
+to use lambdas with Gremlin.Net for the same steps as in Gremlin-Java.
+
 [[gremlin-javascript]]
 == Gremlin-JavaScript
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 0848843..edc7f79 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -42,6 +42,13 @@ by clients that might mysteriously disappear without properly closing their conn
 
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1726[TINKERPOP-1726]
 
+==== Gremlin.Net Lambdas
+
+Gremlin.Net now has a `Lambda` class that can be used to construct Groovy or Java lambdas which will be evaluated on the
+server.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1854[TINKERPOP-1854], link:http://tinkerpop.apache.org/docs/3.2.8/reference/#_the_lambda_solution_3[Reference Documentation - Gremlin.Net - The Lambda Solution].
+
 ==== Gremlin.Net Tokens Improved
 
 The various Gremlin tokens (e.g. `T`, `Order`, `Operator`, etc.) that were implemented as Enums before in Gremlin.Net

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy
index 5057ff8..10b1008 100644
--- a/gremlin-dotnet/glv/generate.groovy
+++ b/gremlin-dotnet/glv/generate.groovy
@@ -54,10 +54,10 @@ def toCSharpTypeMap = ["Long": "long",
                        "TraversalStrategy[]": "ITraversalStrategy[]",
                        "Function": "IFunction",
                        "BiFunction": "IBiFunction",
-                       "UnaryOperator": "object",
+                       "UnaryOperator": "IUnaryOperator",
                        "BinaryOperator": "IBinaryOperator",
                        "Consumer": "IConsumer",
-                       "Supplier": "object",
+                       "Supplier": "ISupplier",
                        "Comparator": "IComparator",
                        "VertexProgram": "object"]
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
index 9c32559..7115016 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
@@ -104,7 +104,7 @@ namespace Gremlin.Net.Process.Traversal
             return source;
         }
 
-        public GraphTraversalSource WithSack(object initialValue, object splitOperator)
+        public GraphTraversalSource WithSack(object initialValue, IUnaryOperator splitOperator)
         {
             var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
                                                   new Bytecode(Bytecode));
@@ -112,7 +112,39 @@ namespace Gremlin.Net.Process.Traversal
             return source;
         }
 
-        public GraphTraversalSource WithSack(object initialValue, object splitOperator, IBinaryOperator mergeOperator)
+        public GraphTraversalSource WithSack(object initialValue, IUnaryOperator splitOperator, IBinaryOperator mergeOperator)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSack", initialValue, splitOperator, mergeOperator);
+            return source;
+        }
+
+        public GraphTraversalSource WithSack(ISupplier initialValue)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSack", initialValue);
+            return source;
+        }
+
+        public GraphTraversalSource WithSack(ISupplier initialValue, IBinaryOperator mergeOperator)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSack", initialValue, mergeOperator);
+            return source;
+        }
+
+        public GraphTraversalSource WithSack(ISupplier initialValue, IUnaryOperator splitOperator)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSack", initialValue, splitOperator);
+            return source;
+        }
+
+        public GraphTraversalSource WithSack(ISupplier initialValue, IUnaryOperator splitOperator, IBinaryOperator mergeOperator)
         {
             var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
                                                   new Bytecode(Bytecode));
@@ -136,6 +168,22 @@ namespace Gremlin.Net.Process.Traversal
             return source;
         }
 
+        public GraphTraversalSource WithSideEffect(string key, ISupplier initialValue)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSideEffect", key, initialValue);
+            return source;
+        }
+
+        public GraphTraversalSource WithSideEffect(string key, ISupplier initialValue, IBinaryOperator reducer)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSideEffect", key, initialValue, reducer);
+            return source;
+        }
+
         public GraphTraversalSource WithStrategies(params ITraversalStrategy[] traversalStrategies)
         {
             var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ISupplier.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ISupplier.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ISupplier.cs
new file mode 100644
index 0000000..b1dda13
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ISupplier.cs
@@ -0,0 +1,32 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+namespace Gremlin.Net.Process.Traversal
+{
+    /// <summary>
+    ///     Represents a supplier of results
+    /// </summary>
+    public interface ISupplier
+    {
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IUnaryOperator.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IUnaryOperator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IUnaryOperator.cs
new file mode 100644
index 0000000..b57be02
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IUnaryOperator.cs
@@ -0,0 +1,33 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+namespace Gremlin.Net.Process.Traversal
+{
+    /// <summary>
+    ///     Represents an operation on a single operand that produces a result of the same type as its operand. This is a
+    ///     specialization of Function for the case where the operand and result are of the same type.
+    /// </summary>
+    public interface IUnaryOperator : IFunction
+    {
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
new file mode 100644
index 0000000..21849ef
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
@@ -0,0 +1,72 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+namespace Gremlin.Net.Process.Traversal
+{
+    /// <summary>
+    ///     Represents a lambda.
+    /// </summary>
+    public class Lambda : IFunction, IBiFunction, IPredicate, IUnaryOperator, IBinaryOperator, IComparator, IConsumer,
+        ISupplier
+    {
+        private const int DefaultArgument = -1;
+
+        private Lambda(string expression, string language)
+        {
+            LambdaExpression = expression;
+            Language = language;
+        }
+
+        /// <summary>
+        ///     Gets the lambda expression.
+        /// </summary>
+        public string LambdaExpression { get; }
+
+        /// <summary>
+        ///     Gets the language of this lambda.
+        /// </summary>
+        public string Language { get; }
+
+        internal object Arguments => DefaultArgument;
+
+        /// <summary>
+        ///     Creates a new Groovy <see cref="Lambda"/>.
+        /// </summary>
+        /// <param name="expression">The lambda expression.</param>
+        /// <returns>The created <see cref="Lambda"/>.</returns>
+        public static Lambda Groovy(string expression)
+        {
+            return new Lambda(expression, "gremlin-groovy");
+        }
+
+        /// <summary>
+        ///     Creates a new Python <see cref="Lambda"/>.
+        /// </summary>
+        /// <param name="expression">The lambda expression.</param>
+        /// <returns>The created <see cref="Lambda"/>.</returns>
+        public static Lambda Python(string expression)
+        {
+            return new Lambda(expression, "gremlin-python");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
index f23d80d..826d608 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -59,7 +59,8 @@ namespace Gremlin.Net.Structure.IO.GraphSON
                 {typeof(Edge), new EdgeSerializer()},
                 {typeof(Property), new PropertySerializer()},
                 {typeof(VertexProperty), new VertexPropertySerializer()},
-                {typeof(AbstractTraversalStrategy), new TraversalStrategySerializer()}
+                {typeof(AbstractTraversalStrategy), new TraversalStrategySerializer()},
+                {typeof(Lambda), new LambdaSerializer()}
             };
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
new file mode 100644
index 0000000..fa739fd
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
@@ -0,0 +1,43 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+using System.Collections.Generic;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.Structure.IO.GraphSON
+{
+    internal class LambdaSerializer : IGraphSONSerializer
+    {
+        public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
+        {
+            Lambda lambda = objectData;
+            var valueDict = new Dictionary<string, dynamic>
+            {
+                {"script", lambda.LambdaExpression},
+                {"language", lambda.Language},
+                {"arguments", lambda.Arguments}
+            };
+            return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
index 0abc247..dd96474 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
@@ -233,7 +233,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
 
         private static object ToLambda(string stringLambda, string graphName)
         {
-            throw new IgnoreException(IgnoreReason.LambdaNotSupported);
+            return Lambda.Groovy(stringLambda);
         }
 
         private static object ToNumber(string stringNumber, string graphName)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
index fd226bf..9aa5213 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
@@ -40,9 +40,6 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
             string reasonSuffix = null;
             switch (reason)
             {
-                case IgnoreReason.LambdaNotSupported:
-                    reasonSuffix = " because lambdas are not supported in Gremlin.NET (TINKERPOP-1854)";
-                    break;
                 case IgnoreReason.PWithinWrapsArgumentsInArray:
                     reasonSuffix = " because P.Within() arguments are incorrectly wrapped in an array (TINKERPOP-1920)";
                     break;
@@ -56,7 +53,6 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
     
     public enum IgnoreReason
     {
-        LambdaNotSupported,
         PWithinWrapsArgumentsInArray,
         PNotDeserializationProblem
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
index 11145da..7e1486c 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
@@ -398,7 +398,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
             {
                 return ParseNumber(text, ref i);
             }
-            if (text.Substring(i, 3).StartsWith("__."))
+            if (text.Length >= i + 3 && text.Substring(i, 3).StartsWith("__."))
             {
                 var startIndex = i;
                 var tokens = ParseTokens(text, ref i);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
index 3e2d307..54dc8f3 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
@@ -333,6 +333,19 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             const string expected = "{\"@type\":\"g:SubgraphStrategy\",\"@value\":{}}";
             Assert.Equal(expected, graphSon);
         }
+
+        [Fact]
+        public void ShouldSerializeLambda()
+        {
+            var writer = CreateStandardGraphSONWriter();
+            var lambda = Lambda.Groovy("{ it.get() }");
+
+            var graphSon = writer.WriteObject(lambda);
+
+            const string expected =
+                "{\"@type\":\"g:Lambda\",\"@value\":{\"script\":\"{ it.get() }\",\"language\":\"gremlin-groovy\",\"arguments\":-1}}";
+            Assert.Equal(expected, graphSon);
+        }
     }
 
     internal class TestGraphSONSerializer : IGraphSONSerializer


[03/18] tinkerpop git commit: TINKERPOP-1919 Add Lambda support to Gremlin.Net

Posted by fl...@apache.org.
TINKERPOP-1919 Add Lambda support to Gremlin.Net

This adds a Lambda class that can be used to construct Groovy or Python
lambdas. The Lambda class implements all interfaces that mirror Javas
functional interfaces like Function.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/0cdaa3a2
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/0cdaa3a2
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/0cdaa3a2

Branch: refs/heads/tp33
Commit: 0cdaa3a2114670a34999aa56e0487a2e7ef998e1
Parents: 0bf9b2f
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Wed Mar 14 18:56:47 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Thu Mar 15 18:16:05 2018 +0100

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 docs/src/reference/gremlin-variants.asciidoc    | 29 ++++++--
 .../upgrade/release-3.2.x-incubating.asciidoc   |  7 ++
 gremlin-dotnet/glv/generate.groovy              |  4 +-
 .../Process/Traversal/GraphTraversalSource.cs   | 52 +++++++++++++-
 .../Gremlin.Net/Process/Traversal/ISupplier.cs  | 32 +++++++++
 .../Process/Traversal/IUnaryOperator.cs         | 33 +++++++++
 .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 72 ++++++++++++++++++++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  3 +-
 .../Structure/IO/GraphSON/LambdaSerializer.cs   | 43 ++++++++++++
 .../Gherkin/CommonSteps.cs                      |  2 +-
 .../Gherkin/IgnoreException.cs                  |  4 --
 .../TraversalEvaluation/TraversalParser.cs      |  2 +-
 .../IO/GraphSON/GraphSONWriterTests.cs          | 13 ++++
 14 files changed, 282 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 94ee24f..8fcbe1a 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -23,6 +23,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 [[release-3-2-8]]
 === TinkerPop 3.2.8 (Release Date: NOT OFFICIALLY RELEASED YET)
 
+* Added a `Lambda` class to Gremlin.Net that makes it possible to use Groovy and Python lambdas with Gremlin.Net.
 * Enums are now represented as classes in Gremlin.Net which allows to use them as arguments in more steps.
 * Bumped to Groovy 2.4.14.
 * Added `checkAdjacentVertices` option to `SubgraphStrategy`.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index ace8119..bf8c8b1 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -46,7 +46,7 @@ implementation of Gremlin and serves as the foundation by which all other Gremli
 === The Lambda Solution
 
 Supporting link:https://en.wikipedia.org/wiki/Anonymous_function[anonymous functions] across languages is difficult as
-most language do not support lambda introspection and thus, code analysis. In Gremlin-Java, Java8 lambdas can be leveraged.
+most languages do not support lambda introspection and thus, code analysis. In Gremlin-Java, Java8 lambdas can be leveraged.
 
 [source,java]
 g.V().out("knows").map(t -> t.get().value("name") + " is the friend name") <1>
@@ -281,7 +281,7 @@ re-construction machine-side.
 === The Lambda Solution
 
 Supporting link:https://en.wikipedia.org/wiki/Anonymous_function[anonymous functions] across languages is difficult as
-most language do not support lambda introspection and thus, code analysis. In Gremlin-Python,
+most languages do not support lambda introspection and thus, code analysis. In Gremlin-Python,
 a link:https://docs.python.org/2/reference/expressions.html#lambda[Python lambda] should be represented as a zero-arg callable
 that returns a string representation of a lambda. The default lambda language is `gremlin-python` and can be changed via
 `gremlin_python.statics.default_lambda_language`. When the lambda is represented in `Bytecode` its language is encoded
@@ -343,8 +343,10 @@ var g = graph.Traversal().WithRemote(new DriverRemoteConnection(new GremlinClien
 
 When a traversal from the `GraphTraversalSource` is iterated, the traversal’s `Bytecode` is sent over the wire via the registered
 `IRemoteConnection`. The bytecode is used to construct the equivalent traversal at the remote traversal source.
-Since Gremlin.Net currently doesn't support lambda expressions, all traversals can be translated to Gremlin-Java on the remote
-location (e.g. Gremlin Server).
+Moreover, typically the bytecode is analyzed to determine which language the bytecode should be translated to. If the traversal
+does not contain lambdas, the remote location (e.g. Gremlin Server) will typically
+use Gremlin-Java. If it has lambdas written in Groovy, it will use Gremlin-Groovy (e.g. `GremlinGroovyScriptEngine`).
+Likewise, if it has lambdas represented in Python, it will use Gremlin-Python (e.g. `GremlinJythonScriptEngine`).
 
 IMPORTANT: Gremlin.Net’s `ITraversal` interface supports the standard Gremlin methods such as `Next()`, `NextTraverser()`, `ToSet()`,
 `ToList()`, etc. Such "terminal" methods trigger the evaluation of the traversal.
@@ -433,6 +435,25 @@ NOTE: Many of the TraversalStrategy classes in Gremlin.Net are proxies to the re
 JVM-based Gremlin traversal machine. As such, their `Apply(ITraversal)` method does nothing. However, the strategy is
 encoded in the Gremlin.Net bytecode and transmitted to the Gremlin traversal machine for re-construction machine-side.
 
+=== The Lambda Solution
+
+Supporting link:https://en.wikipedia.org/wiki/Anonymous_function[anonymous functions] across languages is difficult as
+most languages do not support lambda introspection and thus, code analysis. While Gremlin.Net doesn't support C# lambdas, it
+is still able to represent lambdas in other languages. When the lambda is represented in `Bytecode` its language is encoded
+such that the remote connection host can infer which translator and ultimate execution engine to use.
+
+[source,csharp]
+----
+g.V().Out().Map<int>(Lambda.Groovy("it.get().value('name').length()")).Sum<int>().ToList();      <1>
+g.V().Out().Map<int>(Lambda.Python("lambda x: len(x.get().value('name'))")).Sum<int>().ToList(); <2>
+----
+
+<1> `Lambda.Groovy()` can be used to create a Groovy lambda. 
+<2> `Lambda.Python()` can be used to create a Python lambda.
+
+The `Lambda` class implements interfaces like `IFunction` and `IPredicate` that mirror their Java counterparts which makes it possible
+to use lambdas with Gremlin.Net for the same steps as in Gremlin-Java.
+
 [[gremlin-javascript]]
 == Gremlin-JavaScript
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 0848843..edc7f79 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -42,6 +42,13 @@ by clients that might mysteriously disappear without properly closing their conn
 
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1726[TINKERPOP-1726]
 
+==== Gremlin.Net Lambdas
+
+Gremlin.Net now has a `Lambda` class that can be used to construct Groovy or Java lambdas which will be evaluated on the
+server.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1854[TINKERPOP-1854], link:http://tinkerpop.apache.org/docs/3.2.8/reference/#_the_lambda_solution_3[Reference Documentation - Gremlin.Net - The Lambda Solution].
+
 ==== Gremlin.Net Tokens Improved
 
 The various Gremlin tokens (e.g. `T`, `Order`, `Operator`, etc.) that were implemented as Enums before in Gremlin.Net

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy
index 5057ff8..10b1008 100644
--- a/gremlin-dotnet/glv/generate.groovy
+++ b/gremlin-dotnet/glv/generate.groovy
@@ -54,10 +54,10 @@ def toCSharpTypeMap = ["Long": "long",
                        "TraversalStrategy[]": "ITraversalStrategy[]",
                        "Function": "IFunction",
                        "BiFunction": "IBiFunction",
-                       "UnaryOperator": "object",
+                       "UnaryOperator": "IUnaryOperator",
                        "BinaryOperator": "IBinaryOperator",
                        "Consumer": "IConsumer",
-                       "Supplier": "object",
+                       "Supplier": "ISupplier",
                        "Comparator": "IComparator",
                        "VertexProgram": "object"]
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
index 9c32559..7115016 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
@@ -104,7 +104,7 @@ namespace Gremlin.Net.Process.Traversal
             return source;
         }
 
-        public GraphTraversalSource WithSack(object initialValue, object splitOperator)
+        public GraphTraversalSource WithSack(object initialValue, IUnaryOperator splitOperator)
         {
             var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
                                                   new Bytecode(Bytecode));
@@ -112,7 +112,39 @@ namespace Gremlin.Net.Process.Traversal
             return source;
         }
 
-        public GraphTraversalSource WithSack(object initialValue, object splitOperator, IBinaryOperator mergeOperator)
+        public GraphTraversalSource WithSack(object initialValue, IUnaryOperator splitOperator, IBinaryOperator mergeOperator)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSack", initialValue, splitOperator, mergeOperator);
+            return source;
+        }
+
+        public GraphTraversalSource WithSack(ISupplier initialValue)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSack", initialValue);
+            return source;
+        }
+
+        public GraphTraversalSource WithSack(ISupplier initialValue, IBinaryOperator mergeOperator)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSack", initialValue, mergeOperator);
+            return source;
+        }
+
+        public GraphTraversalSource WithSack(ISupplier initialValue, IUnaryOperator splitOperator)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSack", initialValue, splitOperator);
+            return source;
+        }
+
+        public GraphTraversalSource WithSack(ISupplier initialValue, IUnaryOperator splitOperator, IBinaryOperator mergeOperator)
         {
             var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
                                                   new Bytecode(Bytecode));
@@ -136,6 +168,22 @@ namespace Gremlin.Net.Process.Traversal
             return source;
         }
 
+        public GraphTraversalSource WithSideEffect(string key, ISupplier initialValue)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSideEffect", key, initialValue);
+            return source;
+        }
+
+        public GraphTraversalSource WithSideEffect(string key, ISupplier initialValue, IBinaryOperator reducer)
+        {
+            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
+                                                  new Bytecode(Bytecode));
+            source.Bytecode.AddSource("withSideEffect", key, initialValue, reducer);
+            return source;
+        }
+
         public GraphTraversalSource WithStrategies(params ITraversalStrategy[] traversalStrategies)
         {
             var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ISupplier.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ISupplier.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ISupplier.cs
new file mode 100644
index 0000000..b1dda13
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ISupplier.cs
@@ -0,0 +1,32 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+namespace Gremlin.Net.Process.Traversal
+{
+    /// <summary>
+    ///     Represents a supplier of results
+    /// </summary>
+    public interface ISupplier
+    {
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IUnaryOperator.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IUnaryOperator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IUnaryOperator.cs
new file mode 100644
index 0000000..b57be02
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IUnaryOperator.cs
@@ -0,0 +1,33 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+namespace Gremlin.Net.Process.Traversal
+{
+    /// <summary>
+    ///     Represents an operation on a single operand that produces a result of the same type as its operand. This is a
+    ///     specialization of Function for the case where the operand and result are of the same type.
+    /// </summary>
+    public interface IUnaryOperator : IFunction
+    {
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
new file mode 100644
index 0000000..21849ef
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
@@ -0,0 +1,72 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+namespace Gremlin.Net.Process.Traversal
+{
+    /// <summary>
+    ///     Represents a lambda.
+    /// </summary>
+    public class Lambda : IFunction, IBiFunction, IPredicate, IUnaryOperator, IBinaryOperator, IComparator, IConsumer,
+        ISupplier
+    {
+        private const int DefaultArgument = -1;
+
+        private Lambda(string expression, string language)
+        {
+            LambdaExpression = expression;
+            Language = language;
+        }
+
+        /// <summary>
+        ///     Gets the lambda expression.
+        /// </summary>
+        public string LambdaExpression { get; }
+
+        /// <summary>
+        ///     Gets the language of this lambda.
+        /// </summary>
+        public string Language { get; }
+
+        internal object Arguments => DefaultArgument;
+
+        /// <summary>
+        ///     Creates a new Groovy <see cref="Lambda"/>.
+        /// </summary>
+        /// <param name="expression">The lambda expression.</param>
+        /// <returns>The created <see cref="Lambda"/>.</returns>
+        public static Lambda Groovy(string expression)
+        {
+            return new Lambda(expression, "gremlin-groovy");
+        }
+
+        /// <summary>
+        ///     Creates a new Python <see cref="Lambda"/>.
+        /// </summary>
+        /// <param name="expression">The lambda expression.</param>
+        /// <returns>The created <see cref="Lambda"/>.</returns>
+        public static Lambda Python(string expression)
+        {
+            return new Lambda(expression, "gremlin-python");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
index f23d80d..826d608 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -59,7 +59,8 @@ namespace Gremlin.Net.Structure.IO.GraphSON
                 {typeof(Edge), new EdgeSerializer()},
                 {typeof(Property), new PropertySerializer()},
                 {typeof(VertexProperty), new VertexPropertySerializer()},
-                {typeof(AbstractTraversalStrategy), new TraversalStrategySerializer()}
+                {typeof(AbstractTraversalStrategy), new TraversalStrategySerializer()},
+                {typeof(Lambda), new LambdaSerializer()}
             };
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
new file mode 100644
index 0000000..fa739fd
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
@@ -0,0 +1,43 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+using System.Collections.Generic;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.Structure.IO.GraphSON
+{
+    internal class LambdaSerializer : IGraphSONSerializer
+    {
+        public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
+        {
+            Lambda lambda = objectData;
+            var valueDict = new Dictionary<string, dynamic>
+            {
+                {"script", lambda.LambdaExpression},
+                {"language", lambda.Language},
+                {"arguments", lambda.Arguments}
+            };
+            return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
index 0abc247..dd96474 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
@@ -233,7 +233,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
 
         private static object ToLambda(string stringLambda, string graphName)
         {
-            throw new IgnoreException(IgnoreReason.LambdaNotSupported);
+            return Lambda.Groovy(stringLambda);
         }
 
         private static object ToNumber(string stringNumber, string graphName)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
index fd226bf..9aa5213 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
@@ -40,9 +40,6 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
             string reasonSuffix = null;
             switch (reason)
             {
-                case IgnoreReason.LambdaNotSupported:
-                    reasonSuffix = " because lambdas are not supported in Gremlin.NET (TINKERPOP-1854)";
-                    break;
                 case IgnoreReason.PWithinWrapsArgumentsInArray:
                     reasonSuffix = " because P.Within() arguments are incorrectly wrapped in an array (TINKERPOP-1920)";
                     break;
@@ -56,7 +53,6 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
     
     public enum IgnoreReason
     {
-        LambdaNotSupported,
         PWithinWrapsArgumentsInArray,
         PNotDeserializationProblem
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
index 11145da..7e1486c 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
@@ -398,7 +398,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
             {
                 return ParseNumber(text, ref i);
             }
-            if (text.Substring(i, 3).StartsWith("__."))
+            if (text.Length >= i + 3 && text.Substring(i, 3).StartsWith("__."))
             {
                 var startIndex = i;
                 var tokens = ParseTokens(text, ref i);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0cdaa3a2/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
index 3e2d307..54dc8f3 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
@@ -333,6 +333,19 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
             const string expected = "{\"@type\":\"g:SubgraphStrategy\",\"@value\":{}}";
             Assert.Equal(expected, graphSon);
         }
+
+        [Fact]
+        public void ShouldSerializeLambda()
+        {
+            var writer = CreateStandardGraphSONWriter();
+            var lambda = Lambda.Groovy("{ it.get() }");
+
+            var graphSon = writer.WriteObject(lambda);
+
+            const string expected =
+                "{\"@type\":\"g:Lambda\",\"@value\":{\"script\":\"{ it.get() }\",\"language\":\"gremlin-groovy\",\"arguments\":-1}}";
+            Assert.Equal(expected, graphSon);
+        }
     }
 
     internal class TestGraphSONSerializer : IGraphSONSerializer


[10/18] tinkerpop git commit: TINKERPOP-1854 Replace StartsWith check with an equality check

Posted by fl...@apache.org.
TINKERPOP-1854 Replace StartsWith check with an equality check


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/4ebc68e8
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/4ebc68e8
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/4ebc68e8

Branch: refs/heads/tp33
Commit: 4ebc68e89e0ba1606e06b42a32ec0bebe14fbdf5
Parents: 820adc4
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Sat Mar 17 16:24:09 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Sat Mar 17 16:24:09 2018 +0100

----------------------------------------------------------------------
 .../Gherkin/TraversalEvaluation/TraversalParser.cs                 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4ebc68e8/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
index 7e1486c..e3f6a3f 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
@@ -398,7 +398,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
             {
                 return ParseNumber(text, ref i);
             }
-            if (text.Length >= i + 3 && text.Substring(i, 3).StartsWith("__."))
+            if (text.Length >= i + 3 && text.Substring(i, 3) == "__.")
             {
                 var startIndex = i;
                 var tokens = ParseTokens(text, ref i);


[17/18] tinkerpop git commit: Merge branch 'tp32' into tp33

Posted by fl...@apache.org.
Merge branch 'tp32' into tp33


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/2fd0f255
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/2fd0f255
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/2fd0f255

Branch: refs/heads/master
Commit: 2fd0f2558ddb37304628bdcf0637bb7a8ae5bf6a
Parents: b8eb8a0 eeea869
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Sun Mar 18 12:53:12 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Sun Mar 18 12:53:12 2018 +0100

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 docs/src/reference/gremlin-variants.asciidoc    | 29 ++++++--
 .../upgrade/release-3.2.x-incubating.asciidoc   |  7 ++
 gremlin-dotnet/glv/generate.groovy              |  4 +-
 .../Process/Traversal/GraphTraversalSource.cs   | 52 +++++++++++++-
 .../Gremlin.Net/Process/Traversal/ISupplier.cs  | 32 +++++++++
 .../Process/Traversal/IUnaryOperator.cs         | 33 +++++++++
 .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 73 ++++++++++++++++++++
 .../Process/Traversal/StringBasedLambda.cs      | 42 +++++++++++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  3 +-
 .../Structure/IO/GraphSON/LambdaSerializer.cs   | 43 ++++++++++++
 .../Gherkin/CommonSteps.cs                      |  2 +-
 .../Gherkin/IgnoreException.cs                  |  9 ---
 .../TraversalEvaluation/TraversalParser.cs      |  2 +-
 .../IO/GraphSON/GraphSONWriterTests.cs          | 13 ++++
 15 files changed, 325 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/CHANGELOG.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
----------------------------------------------------------------------
diff --cc gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
index 7e793ca,dd96474..4bb83ae
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
@@@ -234,14 -233,9 +234,14 @@@ namespace Gremlin.Net.IntegrationTest.G
  
          private static object ToLambda(string stringLambda, string graphName)
          {
-             throw new IgnoreException(IgnoreReason.LambdaNotSupported);
+             return Lambda.Groovy(stringLambda);
          }
  
 +        private static object ToT(string enumName, string graphName)
 +        {
 +            return Enum.Parse(typeof(T), TraversalParser.GetCsharpName(enumName));
 +        }
 +
          private static object ToNumber(string stringNumber, string graphName)
          {
              return NumericParsers[stringNumber[stringNumber.Length - 1]](

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
----------------------------------------------------------------------
diff --cc gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
index 56984d9,9aa5213..9bcb860
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
@@@ -40,12 -40,6 +40,9 @@@ namespace Gremlin.Net.IntegrationTest.G
              string reasonSuffix = null;
              switch (reason)
              {
-                 case IgnoreReason.LambdaNotSupported:
-                     reasonSuffix = " because lambdas are not supported in Gremlin.NET (TINKERPOP-1854)";
-                     break;
 +                case IgnoreReason.TraversalTDeserializationNotSupported:
 +                    reasonSuffix = " as deserialization of g:T on GraphSON3 is not supported";
 +                    break;
                  case IgnoreReason.PWithinWrapsArgumentsInArray:
                      reasonSuffix = " because P.Within() arguments are incorrectly wrapped in an array (TINKERPOP-1920)";
                      break;
@@@ -59,16 -53,6 +56,10 @@@
      
      public enum IgnoreReason
      {
 +        /// <summary>
-         /// Lambdas are not supported on Gremlin.NET yet.
-         /// </summary>
-         LambdaNotSupported,
- 
-         /// <summary>
 +        /// Deserialization of g:T on GraphSON3 is not supported.
 +        /// </summary>
 +        TraversalTDeserializationNotSupported,
- 
          PWithinWrapsArgumentsInArray,
          PNotDeserializationProblem
      }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
----------------------------------------------------------------------
diff --cc gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
index 0898c1c,54dc8f3..9f62abe
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
@@@ -393,6 -333,19 +393,19 @@@ namespace Gremlin.Net.UnitTest.Structur
              const string expected = "{\"@type\":\"g:SubgraphStrategy\",\"@value\":{}}";
              Assert.Equal(expected, graphSon);
          }
+ 
 -        [Fact]
 -        public void ShouldSerializeLambda()
++        [Theory, MemberData(nameof(Versions))]
++        public void ShouldSerializeLambda(int version)
+         {
 -            var writer = CreateStandardGraphSONWriter();
++            var writer = CreateGraphSONWriter(version);
+             var lambda = Lambda.Groovy("{ it.get() }");
+ 
+             var graphSon = writer.WriteObject(lambda);
+ 
+             const string expected =
+                 "{\"@type\":\"g:Lambda\",\"@value\":{\"script\":\"{ it.get() }\",\"language\":\"gremlin-groovy\",\"arguments\":-1}}";
+             Assert.Equal(expected, graphSon);
+         }
      }
  
      internal class TestGraphSONSerializer : IGraphSONSerializer


[13/18] tinkerpop git commit: Merge branch 'TINKERPOP-1854' into tp32

Posted by fl...@apache.org.
Merge branch 'TINKERPOP-1854' into tp32


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/eeea8696
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/eeea8696
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/eeea8696

Branch: refs/heads/tp32
Commit: eeea8696e1de69dd6c918feed6ac4fc531ea61dc
Parents: d3d1ccf 4ebc68e
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Sun Mar 18 12:27:55 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Sun Mar 18 12:27:55 2018 +0100

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 docs/src/reference/gremlin-variants.asciidoc    | 29 ++++++--
 .../upgrade/release-3.2.x-incubating.asciidoc   |  7 ++
 gremlin-dotnet/glv/generate.groovy              |  4 +-
 .../Process/Traversal/GraphTraversalSource.cs   | 52 +++++++++++++-
 .../Gremlin.Net/Process/Traversal/ISupplier.cs  | 32 +++++++++
 .../Process/Traversal/IUnaryOperator.cs         | 33 +++++++++
 .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 73 ++++++++++++++++++++
 .../Process/Traversal/StringBasedLambda.cs      | 42 +++++++++++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  3 +-
 .../Structure/IO/GraphSON/LambdaSerializer.cs   | 43 ++++++++++++
 .../Gherkin/CommonSteps.cs                      |  2 +-
 .../Gherkin/IgnoreException.cs                  |  4 --
 .../TraversalEvaluation/TraversalParser.cs      |  2 +-
 .../IO/GraphSON/GraphSONWriterTests.cs          | 13 ++++
 15 files changed, 325 insertions(+), 15 deletions(-)
----------------------------------------------------------------------



[09/18] tinkerpop git commit: TINKERPOP-1854 Add lambda properties to ILambda interface

Posted by fl...@apache.org.
TINKERPOP-1854 Add lambda properties to ILambda interface


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/820adc44
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/820adc44
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/820adc44

Branch: refs/heads/tp33
Commit: 820adc44f3e2c3359f9f345f554d2b936642e7f0
Parents: 7fbb779
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Fri Mar 16 18:52:49 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Fri Mar 16 18:52:49 2018 +0100

----------------------------------------------------------------------
 .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 14 +++++++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  2 +-
 .../Structure/IO/GraphSON/LambdaSerializer.cs   | 43 ++++++++++++++++++++
 .../IO/GraphSON/StringBasedLambdaSerializer.cs  | 43 --------------------
 4 files changed, 58 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/820adc44/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
index 12eb016..c1a0e44 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
@@ -29,6 +29,20 @@ namespace Gremlin.Net.Process.Traversal
     public interface ILambda : IFunction, IBiFunction, IPredicate, IUnaryOperator, IBinaryOperator, IComparator,
         IConsumer, ISupplier
     {
+        /// <summary>
+        ///     Gets the lambda expression.
+        /// </summary>
+        string LambdaExpression { get; }
+
+        /// <summary>
+        ///     Gets the language of this lambda.
+        /// </summary>
+        string Language { get; }
+
+        /// <summary>
+        ///     Gets the arguments of this lambda.
+        /// </summary>
+        object Arguments { get;  }
     }
 
     /// <summary>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/820adc44/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
index 0ef2bde..7185868 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -60,7 +60,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
                 {typeof(Property), new PropertySerializer()},
                 {typeof(VertexProperty), new VertexPropertySerializer()},
                 {typeof(AbstractTraversalStrategy), new TraversalStrategySerializer()},
-                {typeof(ILambda), new StringBasedLambdaSerializer()}
+                {typeof(ILambda), new LambdaSerializer()}
             };
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/820adc44/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
new file mode 100644
index 0000000..45e4632
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
@@ -0,0 +1,43 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+using System.Collections.Generic;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.Structure.IO.GraphSON
+{
+    internal class LambdaSerializer : IGraphSONSerializer
+    {
+        public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
+        {
+            ILambda lambda = objectData;
+            var valueDict = new Dictionary<string, dynamic>
+            {
+                {"script", lambda.LambdaExpression},
+                {"language", lambda.Language},
+                {"arguments", lambda.Arguments}
+            };
+            return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/820adc44/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
deleted file mode 100644
index 2e66367..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-#region License
-
-/*
- * 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.
- */
-
-#endregion
-
-using System.Collections.Generic;
-using Gremlin.Net.Process.Traversal;
-
-namespace Gremlin.Net.Structure.IO.GraphSON
-{
-    internal class StringBasedLambdaSerializer : IGraphSONSerializer
-    {
-        public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
-        {
-            StringBasedLambda lambda = objectData;
-            var valueDict = new Dictionary<string, dynamic>
-            {
-                {"script", lambda.LambdaExpression},
-                {"language", lambda.Language},
-                {"arguments", lambda.Arguments}
-            };
-            return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict);
-        }
-    }
-}
\ No newline at end of file


[15/18] tinkerpop git commit: Merge branch 'TINKERPOP-1854' into tp32

Posted by fl...@apache.org.
Merge branch 'TINKERPOP-1854' into tp32


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/eeea8696
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/eeea8696
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/eeea8696

Branch: refs/heads/master
Commit: eeea8696e1de69dd6c918feed6ac4fc531ea61dc
Parents: d3d1ccf 4ebc68e
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Sun Mar 18 12:27:55 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Sun Mar 18 12:27:55 2018 +0100

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 docs/src/reference/gremlin-variants.asciidoc    | 29 ++++++--
 .../upgrade/release-3.2.x-incubating.asciidoc   |  7 ++
 gremlin-dotnet/glv/generate.groovy              |  4 +-
 .../Process/Traversal/GraphTraversalSource.cs   | 52 +++++++++++++-
 .../Gremlin.Net/Process/Traversal/ISupplier.cs  | 32 +++++++++
 .../Process/Traversal/IUnaryOperator.cs         | 33 +++++++++
 .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 73 ++++++++++++++++++++
 .../Process/Traversal/StringBasedLambda.cs      | 42 +++++++++++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  3 +-
 .../Structure/IO/GraphSON/LambdaSerializer.cs   | 43 ++++++++++++
 .../Gherkin/CommonSteps.cs                      |  2 +-
 .../Gherkin/IgnoreException.cs                  |  4 --
 .../TraversalEvaluation/TraversalParser.cs      |  2 +-
 .../IO/GraphSON/GraphSONWriterTests.cs          | 13 ++++
 15 files changed, 325 insertions(+), 15 deletions(-)
----------------------------------------------------------------------



[06/18] tinkerpop git commit: TINKERPOP-1854 Make Lambda implementation internal

Posted by fl...@apache.org.
TINKERPOP-1854 Make Lambda implementation internal


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7fbb7790
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7fbb7790
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7fbb7790

Branch: refs/heads/tp33
Commit: 7fbb779010f028c8f3df6935969d29afefe0fb0f
Parents: 0cdaa3a
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Thu Mar 15 18:26:40 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Thu Mar 15 18:26:40 2018 +0100

----------------------------------------------------------------------
 docs/src/reference/gremlin-variants.asciidoc    |  4 +-
 .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 45 +++++++-------------
 .../Process/Traversal/StringBasedLambda.cs      | 42 ++++++++++++++++++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  2 +-
 .../Structure/IO/GraphSON/LambdaSerializer.cs   | 43 -------------------
 .../IO/GraphSON/StringBasedLambdaSerializer.cs  | 43 +++++++++++++++++++
 6 files changed, 104 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index bf8c8b1..c19160a 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -451,8 +451,8 @@ g.V().Out().Map<int>(Lambda.Python("lambda x: len(x.get().value('name'))")).Sum<
 <1> `Lambda.Groovy()` can be used to create a Groovy lambda. 
 <2> `Lambda.Python()` can be used to create a Python lambda.
 
-The `Lambda` class implements interfaces like `IFunction` and `IPredicate` that mirror their Java counterparts which makes it possible
-to use lambdas with Gremlin.Net for the same steps as in Gremlin-Java.
+The `ILambda` interface returned by these two methods inherits interfaces like `IFunction` and `IPredicate` that mirror
+their Java counterparts which makes it possible to use lambdas with Gremlin.Net for the same steps as in Gremlin-Java.
 
 [[gremlin-javascript]]
 == Gremlin-JavaScript

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
index 21849ef..12eb016 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
@@ -26,47 +26,34 @@ namespace Gremlin.Net.Process.Traversal
     /// <summary>
     ///     Represents a lambda.
     /// </summary>
-    public class Lambda : IFunction, IBiFunction, IPredicate, IUnaryOperator, IBinaryOperator, IComparator, IConsumer,
-        ISupplier
+    public interface ILambda : IFunction, IBiFunction, IPredicate, IUnaryOperator, IBinaryOperator, IComparator,
+        IConsumer, ISupplier
     {
-        private const int DefaultArgument = -1;
-
-        private Lambda(string expression, string language)
-        {
-            LambdaExpression = expression;
-            Language = language;
-        }
-
-        /// <summary>
-        ///     Gets the lambda expression.
-        /// </summary>
-        public string LambdaExpression { get; }
-
-        /// <summary>
-        ///     Gets the language of this lambda.
-        /// </summary>
-        public string Language { get; }
-
-        internal object Arguments => DefaultArgument;
+    }
 
+    /// <summary>
+    ///     Provides methods to create lambdas.
+    /// </summary>
+    public static class Lambda
+    {
         /// <summary>
-        ///     Creates a new Groovy <see cref="Lambda"/>.
+        ///     Creates a new Groovy lambda.
         /// </summary>
         /// <param name="expression">The lambda expression.</param>
-        /// <returns>The created <see cref="Lambda"/>.</returns>
-        public static Lambda Groovy(string expression)
+        /// <returns>The created lambda.</returns>
+        public static ILambda Groovy(string expression)
         {
-            return new Lambda(expression, "gremlin-groovy");
+            return new StringBasedLambda(expression, "gremlin-groovy");
         }
 
         /// <summary>
-        ///     Creates a new Python <see cref="Lambda"/>.
+        ///     Creates a new Python lambda.
         /// </summary>
         /// <param name="expression">The lambda expression.</param>
-        /// <returns>The created <see cref="Lambda"/>.</returns>
-        public static Lambda Python(string expression)
+        /// <returns>The created lambda.</returns>
+        public static ILambda Python(string expression)
         {
-            return new Lambda(expression, "gremlin-python");
+            return new StringBasedLambda(expression, "gremlin-python");
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs
new file mode 100644
index 0000000..e27b474
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs
@@ -0,0 +1,42 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+namespace Gremlin.Net.Process.Traversal
+{
+    internal class StringBasedLambda : ILambda
+    {
+        private const int DefaultArgument = -1;
+
+        public StringBasedLambda(string expression, string language)
+        {
+            LambdaExpression = expression;
+            Language = language;
+        }
+
+        public string LambdaExpression { get; }
+
+        public string Language { get; }
+
+        public object Arguments => DefaultArgument;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
index 826d608..0ef2bde 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -60,7 +60,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
                 {typeof(Property), new PropertySerializer()},
                 {typeof(VertexProperty), new VertexPropertySerializer()},
                 {typeof(AbstractTraversalStrategy), new TraversalStrategySerializer()},
-                {typeof(Lambda), new LambdaSerializer()}
+                {typeof(ILambda), new StringBasedLambdaSerializer()}
             };
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
deleted file mode 100644
index fa739fd..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-#region License
-
-/*
- * 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.
- */
-
-#endregion
-
-using System.Collections.Generic;
-using Gremlin.Net.Process.Traversal;
-
-namespace Gremlin.Net.Structure.IO.GraphSON
-{
-    internal class LambdaSerializer : IGraphSONSerializer
-    {
-        public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
-        {
-            Lambda lambda = objectData;
-            var valueDict = new Dictionary<string, dynamic>
-            {
-                {"script", lambda.LambdaExpression},
-                {"language", lambda.Language},
-                {"arguments", lambda.Arguments}
-            };
-            return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
new file mode 100644
index 0000000..2e66367
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
@@ -0,0 +1,43 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+using System.Collections.Generic;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.Structure.IO.GraphSON
+{
+    internal class StringBasedLambdaSerializer : IGraphSONSerializer
+    {
+        public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
+        {
+            StringBasedLambda lambda = objectData;
+            var valueDict = new Dictionary<string, dynamic>
+            {
+                {"script", lambda.LambdaExpression},
+                {"language", lambda.Language},
+                {"arguments", lambda.Arguments}
+            };
+            return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict);
+        }
+    }
+}
\ No newline at end of file


[04/18] tinkerpop git commit: TINKERPOP-1854 Make Lambda implementation internal

Posted by fl...@apache.org.
TINKERPOP-1854 Make Lambda implementation internal


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7fbb7790
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7fbb7790
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7fbb7790

Branch: refs/heads/master
Commit: 7fbb779010f028c8f3df6935969d29afefe0fb0f
Parents: 0cdaa3a
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Thu Mar 15 18:26:40 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Thu Mar 15 18:26:40 2018 +0100

----------------------------------------------------------------------
 docs/src/reference/gremlin-variants.asciidoc    |  4 +-
 .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 45 +++++++-------------
 .../Process/Traversal/StringBasedLambda.cs      | 42 ++++++++++++++++++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  2 +-
 .../Structure/IO/GraphSON/LambdaSerializer.cs   | 43 -------------------
 .../IO/GraphSON/StringBasedLambdaSerializer.cs  | 43 +++++++++++++++++++
 6 files changed, 104 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index bf8c8b1..c19160a 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -451,8 +451,8 @@ g.V().Out().Map<int>(Lambda.Python("lambda x: len(x.get().value('name'))")).Sum<
 <1> `Lambda.Groovy()` can be used to create a Groovy lambda. 
 <2> `Lambda.Python()` can be used to create a Python lambda.
 
-The `Lambda` class implements interfaces like `IFunction` and `IPredicate` that mirror their Java counterparts which makes it possible
-to use lambdas with Gremlin.Net for the same steps as in Gremlin-Java.
+The `ILambda` interface returned by these two methods inherits interfaces like `IFunction` and `IPredicate` that mirror
+their Java counterparts which makes it possible to use lambdas with Gremlin.Net for the same steps as in Gremlin-Java.
 
 [[gremlin-javascript]]
 == Gremlin-JavaScript

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
index 21849ef..12eb016 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
@@ -26,47 +26,34 @@ namespace Gremlin.Net.Process.Traversal
     /// <summary>
     ///     Represents a lambda.
     /// </summary>
-    public class Lambda : IFunction, IBiFunction, IPredicate, IUnaryOperator, IBinaryOperator, IComparator, IConsumer,
-        ISupplier
+    public interface ILambda : IFunction, IBiFunction, IPredicate, IUnaryOperator, IBinaryOperator, IComparator,
+        IConsumer, ISupplier
     {
-        private const int DefaultArgument = -1;
-
-        private Lambda(string expression, string language)
-        {
-            LambdaExpression = expression;
-            Language = language;
-        }
-
-        /// <summary>
-        ///     Gets the lambda expression.
-        /// </summary>
-        public string LambdaExpression { get; }
-
-        /// <summary>
-        ///     Gets the language of this lambda.
-        /// </summary>
-        public string Language { get; }
-
-        internal object Arguments => DefaultArgument;
+    }
 
+    /// <summary>
+    ///     Provides methods to create lambdas.
+    /// </summary>
+    public static class Lambda
+    {
         /// <summary>
-        ///     Creates a new Groovy <see cref="Lambda"/>.
+        ///     Creates a new Groovy lambda.
         /// </summary>
         /// <param name="expression">The lambda expression.</param>
-        /// <returns>The created <see cref="Lambda"/>.</returns>
-        public static Lambda Groovy(string expression)
+        /// <returns>The created lambda.</returns>
+        public static ILambda Groovy(string expression)
         {
-            return new Lambda(expression, "gremlin-groovy");
+            return new StringBasedLambda(expression, "gremlin-groovy");
         }
 
         /// <summary>
-        ///     Creates a new Python <see cref="Lambda"/>.
+        ///     Creates a new Python lambda.
         /// </summary>
         /// <param name="expression">The lambda expression.</param>
-        /// <returns>The created <see cref="Lambda"/>.</returns>
-        public static Lambda Python(string expression)
+        /// <returns>The created lambda.</returns>
+        public static ILambda Python(string expression)
         {
-            return new Lambda(expression, "gremlin-python");
+            return new StringBasedLambda(expression, "gremlin-python");
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs
new file mode 100644
index 0000000..e27b474
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs
@@ -0,0 +1,42 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+namespace Gremlin.Net.Process.Traversal
+{
+    internal class StringBasedLambda : ILambda
+    {
+        private const int DefaultArgument = -1;
+
+        public StringBasedLambda(string expression, string language)
+        {
+            LambdaExpression = expression;
+            Language = language;
+        }
+
+        public string LambdaExpression { get; }
+
+        public string Language { get; }
+
+        public object Arguments => DefaultArgument;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
index 826d608..0ef2bde 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -60,7 +60,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
                 {typeof(Property), new PropertySerializer()},
                 {typeof(VertexProperty), new VertexPropertySerializer()},
                 {typeof(AbstractTraversalStrategy), new TraversalStrategySerializer()},
-                {typeof(Lambda), new LambdaSerializer()}
+                {typeof(ILambda), new StringBasedLambdaSerializer()}
             };
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
deleted file mode 100644
index fa739fd..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-#region License
-
-/*
- * 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.
- */
-
-#endregion
-
-using System.Collections.Generic;
-using Gremlin.Net.Process.Traversal;
-
-namespace Gremlin.Net.Structure.IO.GraphSON
-{
-    internal class LambdaSerializer : IGraphSONSerializer
-    {
-        public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
-        {
-            Lambda lambda = objectData;
-            var valueDict = new Dictionary<string, dynamic>
-            {
-                {"script", lambda.LambdaExpression},
-                {"language", lambda.Language},
-                {"arguments", lambda.Arguments}
-            };
-            return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
new file mode 100644
index 0000000..2e66367
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
@@ -0,0 +1,43 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+using System.Collections.Generic;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.Structure.IO.GraphSON
+{
+    internal class StringBasedLambdaSerializer : IGraphSONSerializer
+    {
+        public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
+        {
+            StringBasedLambda lambda = objectData;
+            var valueDict = new Dictionary<string, dynamic>
+            {
+                {"script", lambda.LambdaExpression},
+                {"language", lambda.Language},
+                {"arguments", lambda.Arguments}
+            };
+            return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict);
+        }
+    }
+}
\ No newline at end of file


[11/18] tinkerpop git commit: TINKERPOP-1854 Replace StartsWith check with an equality check

Posted by fl...@apache.org.
TINKERPOP-1854 Replace StartsWith check with an equality check


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/4ebc68e8
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/4ebc68e8
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/4ebc68e8

Branch: refs/heads/master
Commit: 4ebc68e89e0ba1606e06b42a32ec0bebe14fbdf5
Parents: 820adc4
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Sat Mar 17 16:24:09 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Sat Mar 17 16:24:09 2018 +0100

----------------------------------------------------------------------
 .../Gherkin/TraversalEvaluation/TraversalParser.cs                 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4ebc68e8/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
index 7e1486c..e3f6a3f 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
@@ -398,7 +398,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
             {
                 return ParseNumber(text, ref i);
             }
-            if (text.Length >= i + 3 && text.Substring(i, 3).StartsWith("__."))
+            if (text.Length >= i + 3 && text.Substring(i, 3) == "__.")
             {
                 var startIndex = i;
                 var tokens = ParseTokens(text, ref i);


[05/18] tinkerpop git commit: TINKERPOP-1854 Make Lambda implementation internal

Posted by fl...@apache.org.
TINKERPOP-1854 Make Lambda implementation internal


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7fbb7790
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7fbb7790
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7fbb7790

Branch: refs/heads/tp32
Commit: 7fbb779010f028c8f3df6935969d29afefe0fb0f
Parents: 0cdaa3a
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Thu Mar 15 18:26:40 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Thu Mar 15 18:26:40 2018 +0100

----------------------------------------------------------------------
 docs/src/reference/gremlin-variants.asciidoc    |  4 +-
 .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 45 +++++++-------------
 .../Process/Traversal/StringBasedLambda.cs      | 42 ++++++++++++++++++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  2 +-
 .../Structure/IO/GraphSON/LambdaSerializer.cs   | 43 -------------------
 .../IO/GraphSON/StringBasedLambdaSerializer.cs  | 43 +++++++++++++++++++
 6 files changed, 104 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index bf8c8b1..c19160a 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -451,8 +451,8 @@ g.V().Out().Map<int>(Lambda.Python("lambda x: len(x.get().value('name'))")).Sum<
 <1> `Lambda.Groovy()` can be used to create a Groovy lambda. 
 <2> `Lambda.Python()` can be used to create a Python lambda.
 
-The `Lambda` class implements interfaces like `IFunction` and `IPredicate` that mirror their Java counterparts which makes it possible
-to use lambdas with Gremlin.Net for the same steps as in Gremlin-Java.
+The `ILambda` interface returned by these two methods inherits interfaces like `IFunction` and `IPredicate` that mirror
+their Java counterparts which makes it possible to use lambdas with Gremlin.Net for the same steps as in Gremlin-Java.
 
 [[gremlin-javascript]]
 == Gremlin-JavaScript

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
index 21849ef..12eb016 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
@@ -26,47 +26,34 @@ namespace Gremlin.Net.Process.Traversal
     /// <summary>
     ///     Represents a lambda.
     /// </summary>
-    public class Lambda : IFunction, IBiFunction, IPredicate, IUnaryOperator, IBinaryOperator, IComparator, IConsumer,
-        ISupplier
+    public interface ILambda : IFunction, IBiFunction, IPredicate, IUnaryOperator, IBinaryOperator, IComparator,
+        IConsumer, ISupplier
     {
-        private const int DefaultArgument = -1;
-
-        private Lambda(string expression, string language)
-        {
-            LambdaExpression = expression;
-            Language = language;
-        }
-
-        /// <summary>
-        ///     Gets the lambda expression.
-        /// </summary>
-        public string LambdaExpression { get; }
-
-        /// <summary>
-        ///     Gets the language of this lambda.
-        /// </summary>
-        public string Language { get; }
-
-        internal object Arguments => DefaultArgument;
+    }
 
+    /// <summary>
+    ///     Provides methods to create lambdas.
+    /// </summary>
+    public static class Lambda
+    {
         /// <summary>
-        ///     Creates a new Groovy <see cref="Lambda"/>.
+        ///     Creates a new Groovy lambda.
         /// </summary>
         /// <param name="expression">The lambda expression.</param>
-        /// <returns>The created <see cref="Lambda"/>.</returns>
-        public static Lambda Groovy(string expression)
+        /// <returns>The created lambda.</returns>
+        public static ILambda Groovy(string expression)
         {
-            return new Lambda(expression, "gremlin-groovy");
+            return new StringBasedLambda(expression, "gremlin-groovy");
         }
 
         /// <summary>
-        ///     Creates a new Python <see cref="Lambda"/>.
+        ///     Creates a new Python lambda.
         /// </summary>
         /// <param name="expression">The lambda expression.</param>
-        /// <returns>The created <see cref="Lambda"/>.</returns>
-        public static Lambda Python(string expression)
+        /// <returns>The created lambda.</returns>
+        public static ILambda Python(string expression)
         {
-            return new Lambda(expression, "gremlin-python");
+            return new StringBasedLambda(expression, "gremlin-python");
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs
new file mode 100644
index 0000000..e27b474
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs
@@ -0,0 +1,42 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+namespace Gremlin.Net.Process.Traversal
+{
+    internal class StringBasedLambda : ILambda
+    {
+        private const int DefaultArgument = -1;
+
+        public StringBasedLambda(string expression, string language)
+        {
+            LambdaExpression = expression;
+            Language = language;
+        }
+
+        public string LambdaExpression { get; }
+
+        public string Language { get; }
+
+        public object Arguments => DefaultArgument;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
index 826d608..0ef2bde 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -60,7 +60,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
                 {typeof(Property), new PropertySerializer()},
                 {typeof(VertexProperty), new VertexPropertySerializer()},
                 {typeof(AbstractTraversalStrategy), new TraversalStrategySerializer()},
-                {typeof(Lambda), new LambdaSerializer()}
+                {typeof(ILambda), new StringBasedLambdaSerializer()}
             };
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
deleted file mode 100644
index fa739fd..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-#region License
-
-/*
- * 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.
- */
-
-#endregion
-
-using System.Collections.Generic;
-using Gremlin.Net.Process.Traversal;
-
-namespace Gremlin.Net.Structure.IO.GraphSON
-{
-    internal class LambdaSerializer : IGraphSONSerializer
-    {
-        public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
-        {
-            Lambda lambda = objectData;
-            var valueDict = new Dictionary<string, dynamic>
-            {
-                {"script", lambda.LambdaExpression},
-                {"language", lambda.Language},
-                {"arguments", lambda.Arguments}
-            };
-            return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fbb7790/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
new file mode 100644
index 0000000..2e66367
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
@@ -0,0 +1,43 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+using System.Collections.Generic;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.Structure.IO.GraphSON
+{
+    internal class StringBasedLambdaSerializer : IGraphSONSerializer
+    {
+        public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
+        {
+            StringBasedLambda lambda = objectData;
+            var valueDict = new Dictionary<string, dynamic>
+            {
+                {"script", lambda.LambdaExpression},
+                {"language", lambda.Language},
+                {"arguments", lambda.Arguments}
+            };
+            return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict);
+        }
+    }
+}
\ No newline at end of file


[14/18] tinkerpop git commit: Merge branch 'TINKERPOP-1854' into tp32

Posted by fl...@apache.org.
Merge branch 'TINKERPOP-1854' into tp32


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/eeea8696
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/eeea8696
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/eeea8696

Branch: refs/heads/tp33
Commit: eeea8696e1de69dd6c918feed6ac4fc531ea61dc
Parents: d3d1ccf 4ebc68e
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Sun Mar 18 12:27:55 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Sun Mar 18 12:27:55 2018 +0100

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 docs/src/reference/gremlin-variants.asciidoc    | 29 ++++++--
 .../upgrade/release-3.2.x-incubating.asciidoc   |  7 ++
 gremlin-dotnet/glv/generate.groovy              |  4 +-
 .../Process/Traversal/GraphTraversalSource.cs   | 52 +++++++++++++-
 .../Gremlin.Net/Process/Traversal/ISupplier.cs  | 32 +++++++++
 .../Process/Traversal/IUnaryOperator.cs         | 33 +++++++++
 .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 73 ++++++++++++++++++++
 .../Process/Traversal/StringBasedLambda.cs      | 42 +++++++++++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  3 +-
 .../Structure/IO/GraphSON/LambdaSerializer.cs   | 43 ++++++++++++
 .../Gherkin/CommonSteps.cs                      |  2 +-
 .../Gherkin/IgnoreException.cs                  |  4 --
 .../TraversalEvaluation/TraversalParser.cs      |  2 +-
 .../IO/GraphSON/GraphSONWriterTests.cs          | 13 ++++
 15 files changed, 325 insertions(+), 15 deletions(-)
----------------------------------------------------------------------



[16/18] tinkerpop git commit: Merge branch 'tp32' into tp33

Posted by fl...@apache.org.
Merge branch 'tp32' into tp33


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/2fd0f255
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/2fd0f255
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/2fd0f255

Branch: refs/heads/tp33
Commit: 2fd0f2558ddb37304628bdcf0637bb7a8ae5bf6a
Parents: b8eb8a0 eeea869
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Sun Mar 18 12:53:12 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Sun Mar 18 12:53:12 2018 +0100

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 docs/src/reference/gremlin-variants.asciidoc    | 29 ++++++--
 .../upgrade/release-3.2.x-incubating.asciidoc   |  7 ++
 gremlin-dotnet/glv/generate.groovy              |  4 +-
 .../Process/Traversal/GraphTraversalSource.cs   | 52 +++++++++++++-
 .../Gremlin.Net/Process/Traversal/ISupplier.cs  | 32 +++++++++
 .../Process/Traversal/IUnaryOperator.cs         | 33 +++++++++
 .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 73 ++++++++++++++++++++
 .../Process/Traversal/StringBasedLambda.cs      | 42 +++++++++++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  3 +-
 .../Structure/IO/GraphSON/LambdaSerializer.cs   | 43 ++++++++++++
 .../Gherkin/CommonSteps.cs                      |  2 +-
 .../Gherkin/IgnoreException.cs                  |  9 ---
 .../TraversalEvaluation/TraversalParser.cs      |  2 +-
 .../IO/GraphSON/GraphSONWriterTests.cs          | 13 ++++
 15 files changed, 325 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/CHANGELOG.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
----------------------------------------------------------------------
diff --cc gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
index 7e793ca,dd96474..4bb83ae
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
@@@ -234,14 -233,9 +234,14 @@@ namespace Gremlin.Net.IntegrationTest.G
  
          private static object ToLambda(string stringLambda, string graphName)
          {
-             throw new IgnoreException(IgnoreReason.LambdaNotSupported);
+             return Lambda.Groovy(stringLambda);
          }
  
 +        private static object ToT(string enumName, string graphName)
 +        {
 +            return Enum.Parse(typeof(T), TraversalParser.GetCsharpName(enumName));
 +        }
 +
          private static object ToNumber(string stringNumber, string graphName)
          {
              return NumericParsers[stringNumber[stringNumber.Length - 1]](

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
----------------------------------------------------------------------
diff --cc gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
index 56984d9,9aa5213..9bcb860
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
@@@ -40,12 -40,6 +40,9 @@@ namespace Gremlin.Net.IntegrationTest.G
              string reasonSuffix = null;
              switch (reason)
              {
-                 case IgnoreReason.LambdaNotSupported:
-                     reasonSuffix = " because lambdas are not supported in Gremlin.NET (TINKERPOP-1854)";
-                     break;
 +                case IgnoreReason.TraversalTDeserializationNotSupported:
 +                    reasonSuffix = " as deserialization of g:T on GraphSON3 is not supported";
 +                    break;
                  case IgnoreReason.PWithinWrapsArgumentsInArray:
                      reasonSuffix = " because P.Within() arguments are incorrectly wrapped in an array (TINKERPOP-1920)";
                      break;
@@@ -59,16 -53,6 +56,10 @@@
      
      public enum IgnoreReason
      {
 +        /// <summary>
-         /// Lambdas are not supported on Gremlin.NET yet.
-         /// </summary>
-         LambdaNotSupported,
- 
-         /// <summary>
 +        /// Deserialization of g:T on GraphSON3 is not supported.
 +        /// </summary>
 +        TraversalTDeserializationNotSupported,
- 
          PWithinWrapsArgumentsInArray,
          PNotDeserializationProblem
      }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fd0f255/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
----------------------------------------------------------------------
diff --cc gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
index 0898c1c,54dc8f3..9f62abe
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
@@@ -393,6 -333,19 +393,19 @@@ namespace Gremlin.Net.UnitTest.Structur
              const string expected = "{\"@type\":\"g:SubgraphStrategy\",\"@value\":{}}";
              Assert.Equal(expected, graphSon);
          }
+ 
 -        [Fact]
 -        public void ShouldSerializeLambda()
++        [Theory, MemberData(nameof(Versions))]
++        public void ShouldSerializeLambda(int version)
+         {
 -            var writer = CreateStandardGraphSONWriter();
++            var writer = CreateGraphSONWriter(version);
+             var lambda = Lambda.Groovy("{ it.get() }");
+ 
+             var graphSon = writer.WriteObject(lambda);
+ 
+             const string expected =
+                 "{\"@type\":\"g:Lambda\",\"@value\":{\"script\":\"{ it.get() }\",\"language\":\"gremlin-groovy\",\"arguments\":-1}}";
+             Assert.Equal(expected, graphSon);
+         }
      }
  
      internal class TestGraphSONSerializer : IGraphSONSerializer


[08/18] tinkerpop git commit: TINKERPOP-1854 Add lambda properties to ILambda interface

Posted by fl...@apache.org.
TINKERPOP-1854 Add lambda properties to ILambda interface


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/820adc44
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/820adc44
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/820adc44

Branch: refs/heads/tp32
Commit: 820adc44f3e2c3359f9f345f554d2b936642e7f0
Parents: 7fbb779
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Fri Mar 16 18:52:49 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Fri Mar 16 18:52:49 2018 +0100

----------------------------------------------------------------------
 .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 14 +++++++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  2 +-
 .../Structure/IO/GraphSON/LambdaSerializer.cs   | 43 ++++++++++++++++++++
 .../IO/GraphSON/StringBasedLambdaSerializer.cs  | 43 --------------------
 4 files changed, 58 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/820adc44/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
index 12eb016..c1a0e44 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
@@ -29,6 +29,20 @@ namespace Gremlin.Net.Process.Traversal
     public interface ILambda : IFunction, IBiFunction, IPredicate, IUnaryOperator, IBinaryOperator, IComparator,
         IConsumer, ISupplier
     {
+        /// <summary>
+        ///     Gets the lambda expression.
+        /// </summary>
+        string LambdaExpression { get; }
+
+        /// <summary>
+        ///     Gets the language of this lambda.
+        /// </summary>
+        string Language { get; }
+
+        /// <summary>
+        ///     Gets the arguments of this lambda.
+        /// </summary>
+        object Arguments { get;  }
     }
 
     /// <summary>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/820adc44/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
index 0ef2bde..7185868 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -60,7 +60,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
                 {typeof(Property), new PropertySerializer()},
                 {typeof(VertexProperty), new VertexPropertySerializer()},
                 {typeof(AbstractTraversalStrategy), new TraversalStrategySerializer()},
-                {typeof(ILambda), new StringBasedLambdaSerializer()}
+                {typeof(ILambda), new LambdaSerializer()}
             };
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/820adc44/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
new file mode 100644
index 0000000..45e4632
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
@@ -0,0 +1,43 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+using System.Collections.Generic;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.Structure.IO.GraphSON
+{
+    internal class LambdaSerializer : IGraphSONSerializer
+    {
+        public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
+        {
+            ILambda lambda = objectData;
+            var valueDict = new Dictionary<string, dynamic>
+            {
+                {"script", lambda.LambdaExpression},
+                {"language", lambda.Language},
+                {"arguments", lambda.Arguments}
+            };
+            return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/820adc44/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
deleted file mode 100644
index 2e66367..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-#region License
-
-/*
- * 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.
- */
-
-#endregion
-
-using System.Collections.Generic;
-using Gremlin.Net.Process.Traversal;
-
-namespace Gremlin.Net.Structure.IO.GraphSON
-{
-    internal class StringBasedLambdaSerializer : IGraphSONSerializer
-    {
-        public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
-        {
-            StringBasedLambda lambda = objectData;
-            var valueDict = new Dictionary<string, dynamic>
-            {
-                {"script", lambda.LambdaExpression},
-                {"language", lambda.Language},
-                {"arguments", lambda.Arguments}
-            };
-            return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict);
-        }
-    }
-}
\ No newline at end of file


[18/18] tinkerpop git commit: Merge branch 'tp33'

Posted by fl...@apache.org.
Merge branch 'tp33'


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/f7da641d
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f7da641d
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f7da641d

Branch: refs/heads/master
Commit: f7da641d3d35a79ef0d45a9458acad54fc8a5565
Parents: 04b7d4d 2fd0f25
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Sun Mar 18 12:53:34 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Sun Mar 18 12:53:34 2018 +0100

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 docs/src/reference/gremlin-variants.asciidoc    | 29 ++++++--
 .../upgrade/release-3.2.x-incubating.asciidoc   |  7 ++
 gremlin-dotnet/glv/generate.groovy              |  4 +-
 .../Process/Traversal/GraphTraversalSource.cs   | 52 +++++++++++++-
 .../Gremlin.Net/Process/Traversal/ISupplier.cs  | 32 +++++++++
 .../Process/Traversal/IUnaryOperator.cs         | 33 +++++++++
 .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 73 ++++++++++++++++++++
 .../Process/Traversal/StringBasedLambda.cs      | 42 +++++++++++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  3 +-
 .../Structure/IO/GraphSON/LambdaSerializer.cs   | 43 ++++++++++++
 .../Gherkin/CommonSteps.cs                      |  2 +-
 .../Gherkin/IgnoreException.cs                  |  9 ---
 .../TraversalEvaluation/TraversalParser.cs      |  2 +-
 .../IO/GraphSON/GraphSONWriterTests.cs          | 13 ++++
 15 files changed, 325 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f7da641d/CHANGELOG.asciidoc
----------------------------------------------------------------------


[07/18] tinkerpop git commit: TINKERPOP-1854 Add lambda properties to ILambda interface

Posted by fl...@apache.org.
TINKERPOP-1854 Add lambda properties to ILambda interface


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/820adc44
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/820adc44
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/820adc44

Branch: refs/heads/master
Commit: 820adc44f3e2c3359f9f345f554d2b936642e7f0
Parents: 7fbb779
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Fri Mar 16 18:52:49 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Fri Mar 16 18:52:49 2018 +0100

----------------------------------------------------------------------
 .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 14 +++++++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  2 +-
 .../Structure/IO/GraphSON/LambdaSerializer.cs   | 43 ++++++++++++++++++++
 .../IO/GraphSON/StringBasedLambdaSerializer.cs  | 43 --------------------
 4 files changed, 58 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/820adc44/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
index 12eb016..c1a0e44 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
@@ -29,6 +29,20 @@ namespace Gremlin.Net.Process.Traversal
     public interface ILambda : IFunction, IBiFunction, IPredicate, IUnaryOperator, IBinaryOperator, IComparator,
         IConsumer, ISupplier
     {
+        /// <summary>
+        ///     Gets the lambda expression.
+        /// </summary>
+        string LambdaExpression { get; }
+
+        /// <summary>
+        ///     Gets the language of this lambda.
+        /// </summary>
+        string Language { get; }
+
+        /// <summary>
+        ///     Gets the arguments of this lambda.
+        /// </summary>
+        object Arguments { get;  }
     }
 
     /// <summary>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/820adc44/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
index 0ef2bde..7185868 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -60,7 +60,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
                 {typeof(Property), new PropertySerializer()},
                 {typeof(VertexProperty), new VertexPropertySerializer()},
                 {typeof(AbstractTraversalStrategy), new TraversalStrategySerializer()},
-                {typeof(ILambda), new StringBasedLambdaSerializer()}
+                {typeof(ILambda), new LambdaSerializer()}
             };
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/820adc44/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
new file mode 100644
index 0000000..45e4632
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
@@ -0,0 +1,43 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+using System.Collections.Generic;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.Structure.IO.GraphSON
+{
+    internal class LambdaSerializer : IGraphSONSerializer
+    {
+        public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
+        {
+            ILambda lambda = objectData;
+            var valueDict = new Dictionary<string, dynamic>
+            {
+                {"script", lambda.LambdaExpression},
+                {"language", lambda.Language},
+                {"arguments", lambda.Arguments}
+            };
+            return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/820adc44/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
deleted file mode 100644
index 2e66367..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-#region License
-
-/*
- * 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.
- */
-
-#endregion
-
-using System.Collections.Generic;
-using Gremlin.Net.Process.Traversal;
-
-namespace Gremlin.Net.Structure.IO.GraphSON
-{
-    internal class StringBasedLambdaSerializer : IGraphSONSerializer
-    {
-        public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
-        {
-            StringBasedLambda lambda = objectData;
-            var valueDict = new Dictionary<string, dynamic>
-            {
-                {"script", lambda.LambdaExpression},
-                {"language", lambda.Language},
-                {"arguments", lambda.Arguments}
-            };
-            return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict);
-        }
-    }
-}
\ No newline at end of file