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/13 22:53:28 UTC
[01/10] tinkerpop git commit: TINKERPOP-1919 Merge classes P and
TraversalPredicate
Repository: tinkerpop
Updated Branches:
refs/heads/master 5ae66ed94 -> 3e00a6402
refs/heads/tp32 504933975 -> 5cf1cba59
refs/heads/tp33 2d493fb3c -> 9bd4d7fed
TINKERPOP-1919 Merge classes P and TraversalPredicate
There is no good reason to keep those two classes separate anymore and
having P as the type for step parameters is probably easier to
understand for users than TraversalPredicate.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/359b08cc
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/359b08cc
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/359b08cc
Branch: refs/heads/master
Commit: 359b08cc79ed89cab1fbc4e2b0b69b94a4e9cd06
Parents: 5049339
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Mon Mar 12 21:16:18 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Tue Mar 13 22:12:31 2018 +0100
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
gremlin-dotnet/glv/P.template | 62 ++++++++++-
gremlin-dotnet/glv/generate.groovy | 2 +-
.../Process/Traversal/GraphTraversal.cs | 20 ++--
.../src/Gremlin.Net/Process/Traversal/P.cs | 106 ++++++++++++++-----
.../Process/Traversal/TraversalPredicate.cs | 85 ---------------
.../src/Gremlin.Net/Process/Traversal/__.cs | 20 ++--
.../Structure/IO/GraphSON/GraphSONWriter.cs | 2 +-
.../Structure/IO/GraphSON/PSerializer.cs | 45 ++++++++
.../IO/GraphSON/TraversalPredicateSerializer.cs | 45 --------
.../Gherkin/GherkinTestRunner.cs | 18 +---
.../Gherkin/IgnoreException.cs | 5 -
.../Gherkin/TraversalEvaluation/PParameter.cs | 97 +++++++++++++++++
.../TraversalEvaluationTests.cs | 2 +-
.../TraversalEvaluation/TraversalParser.cs | 2 +-
.../TraversalPredicateParameter.cs | 93 ----------------
.../GraphSON/BytecodeGraphSONSerializerTests.cs | 2 +-
.../IO/GraphSON/GraphSONWriterTests.cs | 4 +-
18 files changed, 311 insertions(+), 300 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 58c4dd0..97b90a5 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -43,6 +43,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
* Fixed a bug in Gremlin Console which prevented handling of `gremlin.sh` flags that had an "=" between the flag and its arguments.
* Fixed bug where `SparkMessenger` was not applying the `edgeFunction` from `MessageScope`.
* Fixed a bug in `ComputerAwareStep` that didn't handle `reset()` properly and thus occasionally produced some extra traversers.
+* Removed `TraversalPredicate` class in Gremlin.Net. It is now included in the `P` class instead.
[[release-3-2-7]]
=== TinkerPop 3.2.7 (Release Date: December 17, 2017)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/glv/P.template
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/P.template b/gremlin-dotnet/glv/P.template
index f337127..ad037c1 100644
--- a/gremlin-dotnet/glv/P.template
+++ b/gremlin-dotnet/glv/P.template
@@ -30,20 +30,72 @@ namespace Gremlin.Net.Process.Traversal
/// A <see cref="P" /> is a predicate of the form Func<object, bool>.
/// That is, given some object, return true or false.
/// </summary>
- public class P
+ public class P : IPredicate
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="P" /> class.
+ /// </summary>
+ /// <param name="operatorName">The name of the predicate.</param>
+ /// <param name="value">The value of the predicate.</param>
+ /// <param name="other">An optional other predicate that is used as an argument for this predicate.</param>
+ public P(string operatorName, dynamic value, P other = null)
+ {
+ OperatorName = operatorName;
+ Value = value;
+ Other = other;
+ }
+
+ /// <summary>
+ /// Gets the name of the predicate.
+ /// </summary>
+ public string OperatorName { get; }
+
+ /// <summary>
+ /// Gets the value of the predicate.
+ /// </summary>
+ public dynamic Value { get; }
+
+ /// <summary>
+ /// Gets an optional other predicate that is used as an argument for this predicate.
+ /// </summary>
+ public P Other { get; }
+
+ /// <summary>
+ /// Returns a composed predicate that represents a logical AND of this predicate and another.
+ /// </summary>
+ /// <param name="otherPredicate">A predicate that will be logically-ANDed with this predicate.</param>
+ /// <returns>The composed predicate.</returns>
+ public P And(P otherPredicate)
+ {
+ return new P("and", this, otherPredicate);
+ }
+
+ /// <summary>
+ /// Returns a composed predicate that represents a logical OR of this predicate and another.
+ /// </summary>
+ /// <param name="otherPredicate">A predicate that will be logically-ORed with this predicate.</param>
+ /// <returns>The composed predicate.</returns>
+ public P Or(P otherPredicate)
+ {
+ return new P("or", this, otherPredicate);
+ }
<% pmethods.findAll{ !(it in ["within", "without"]) }.each { method -> %>
- public static TraversalPredicate <%= toCSharpMethodName.call(method) %>(params object[] args)
+ public static P <%= toCSharpMethodName.call(method) %>(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("<%= method %>", value);
+ return new P("<%= method %>", value);
}
<% } %><% pmethods.findAll{ it in ["within", "without"] }.each { method -> %>
- public static TraversalPredicate <%= toCSharpMethodName.call(method) %>(params object[] args)
+ public static P <%= toCSharpMethodName.call(method) %>(params object[] args)
{
- return new TraversalPredicate("<%= method %>", args);
+ return new P("<%= method %>", args);
}
<% } %>
+ /// <inheritdoc />
+ public override string ToString()
+ {
+ return Other == null ? \$"{OperatorName}({Value})" : \$"{OperatorName}({Value},{Other})";
+ }
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy
index 0404307..5057ff8 100644
--- a/gremlin-dotnet/glv/generate.groovy
+++ b/gremlin-dotnet/glv/generate.groovy
@@ -49,7 +49,7 @@ def toCSharpTypeMap = ["Long": "long",
"Traversal": "ITraversal",
"Traversal[]": "ITraversal[]",
"Predicate": "IPredicate",
- "P": "TraversalPredicate",
+ "P": "P",
"TraversalStrategy": "ITraversalStrategy",
"TraversalStrategy[]": "ITraversalStrategy[]",
"Function": "IFunction",
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
index 7100ea3..c8708df 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
@@ -667,7 +667,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the has step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Has (string propertyKey, TraversalPredicate predicate)
+ public GraphTraversal<S, E> Has (string propertyKey, P predicate)
{
Bytecode.AddStep("has", propertyKey, predicate);
return Wrap<S, E>(this);
@@ -685,7 +685,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the has step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Has (string label, string propertyKey, TraversalPredicate predicate)
+ public GraphTraversal<S, E> Has (string label, string propertyKey, P predicate)
{
Bytecode.AddStep("has", label, propertyKey, predicate);
return Wrap<S, E>(this);
@@ -712,7 +712,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the has step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Has (T accessor, TraversalPredicate predicate)
+ public GraphTraversal<S, E> Has (T accessor, P predicate)
{
Bytecode.AddStep("has", accessor, predicate);
return Wrap<S, E>(this);
@@ -741,7 +741,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasId step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasId (TraversalPredicate predicate)
+ public GraphTraversal<S, E> HasId (P predicate)
{
Bytecode.AddStep("hasId", predicate);
return Wrap<S, E>(this);
@@ -750,7 +750,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasKey step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasKey (TraversalPredicate predicate)
+ public GraphTraversal<S, E> HasKey (P predicate)
{
Bytecode.AddStep("hasKey", predicate);
return Wrap<S, E>(this);
@@ -770,7 +770,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasLabel step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasLabel (TraversalPredicate predicate)
+ public GraphTraversal<S, E> HasLabel (P predicate)
{
Bytecode.AddStep("hasLabel", predicate);
return Wrap<S, E>(this);
@@ -810,7 +810,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasValue step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasValue (TraversalPredicate predicate)
+ public GraphTraversal<S, E> HasValue (P predicate)
{
Bytecode.AddStep("hasValue", predicate);
return Wrap<S, E>(this);
@@ -888,7 +888,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the is step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Is (TraversalPredicate predicate)
+ public GraphTraversal<S, E> Is (P predicate)
{
Bytecode.AddStep("is", predicate);
return Wrap<S, E>(this);
@@ -1660,7 +1660,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the where step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Where (TraversalPredicate predicate)
+ public GraphTraversal<S, E> Where (P predicate)
{
Bytecode.AddStep("where", predicate);
return Wrap<S, E>(this);
@@ -1669,7 +1669,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the where step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Where (string startKey, TraversalPredicate predicate)
+ public GraphTraversal<S, E> Where (string startKey, P predicate)
{
Bytecode.AddStep("where", startKey, predicate);
return Wrap<S, E>(this);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
index 0a7809f..e3a1e76 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
@@ -30,85 +30,137 @@ namespace Gremlin.Net.Process.Traversal
/// A <see cref="P" /> is a predicate of the form Func<object, bool>.
/// That is, given some object, return true or false.
/// </summary>
- public class P
+ public class P : IPredicate
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="P" /> class.
+ /// </summary>
+ /// <param name="operatorName">The name of the predicate.</param>
+ /// <param name="value">The value of the predicate.</param>
+ /// <param name="other">An optional other predicate that is used as an argument for this predicate.</param>
+ public P(string operatorName, dynamic value, P other = null)
+ {
+ OperatorName = operatorName;
+ Value = value;
+ Other = other;
+ }
+
+ /// <summary>
+ /// Gets the name of the predicate.
+ /// </summary>
+ public string OperatorName { get; }
+
+ /// <summary>
+ /// Gets the value of the predicate.
+ /// </summary>
+ public dynamic Value { get; }
+
+ /// <summary>
+ /// Gets an optional other predicate that is used as an argument for this predicate.
+ /// </summary>
+ public P Other { get; }
+
+ /// <summary>
+ /// Returns a composed predicate that represents a logical AND of this predicate and another.
+ /// </summary>
+ /// <param name="otherPredicate">A predicate that will be logically-ANDed with this predicate.</param>
+ /// <returns>The composed predicate.</returns>
+ public P And(P otherPredicate)
+ {
+ return new P("and", this, otherPredicate);
+ }
- public static TraversalPredicate Between(params object[] args)
+ /// <summary>
+ /// Returns a composed predicate that represents a logical OR of this predicate and another.
+ /// </summary>
+ /// <param name="otherPredicate">A predicate that will be logically-ORed with this predicate.</param>
+ /// <returns>The composed predicate.</returns>
+ public P Or(P otherPredicate)
+ {
+ return new P("or", this, otherPredicate);
+ }
+
+ public static P Between(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("between", value);
+ return new P("between", value);
}
- public static TraversalPredicate Eq(params object[] args)
+ public static P Eq(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("eq", value);
+ return new P("eq", value);
}
- public static TraversalPredicate Gt(params object[] args)
+ public static P Gt(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("gt", value);
+ return new P("gt", value);
}
- public static TraversalPredicate Gte(params object[] args)
+ public static P Gte(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("gte", value);
+ return new P("gte", value);
}
- public static TraversalPredicate Inside(params object[] args)
+ public static P Inside(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("inside", value);
+ return new P("inside", value);
}
- public static TraversalPredicate Lt(params object[] args)
+ public static P Lt(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("lt", value);
+ return new P("lt", value);
}
- public static TraversalPredicate Lte(params object[] args)
+ public static P Lte(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("lte", value);
+ return new P("lte", value);
}
- public static TraversalPredicate Neq(params object[] args)
+ public static P Neq(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("neq", value);
+ return new P("neq", value);
}
- public static TraversalPredicate Not(params object[] args)
+ public static P Not(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("not", value);
+ return new P("not", value);
}
- public static TraversalPredicate Outside(params object[] args)
+ public static P Outside(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("outside", value);
+ return new P("outside", value);
}
- public static TraversalPredicate Test(params object[] args)
+ public static P Test(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("test", value);
+ return new P("test", value);
}
- public static TraversalPredicate Within(params object[] args)
+ public static P Within(params object[] args)
{
- return new TraversalPredicate("within", args);
+ return new P("within", args);
}
- public static TraversalPredicate Without(params object[] args)
+ public static P Without(params object[] args)
{
- return new TraversalPredicate("without", args);
+ return new P("without", args);
}
+ /// <inheritdoc />
+ public override string ToString()
+ {
+ return Other == null ? $"{OperatorName}({Value})" : $"{OperatorName}({Value},{Other})";
+ }
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs
deleted file mode 100644
index e8b5be8..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs
+++ /dev/null
@@ -1,85 +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
-
-namespace Gremlin.Net.Process.Traversal
-{
- /// <summary>
- /// Represents a predicate (boolean-valued function) used in a <see cref="ITraversal" />.
- /// </summary>
- public class TraversalPredicate : IPredicate
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="TraversalPredicate" /> class.
- /// </summary>
- /// <param name="operatorName">The name of the predicate.</param>
- /// <param name="value">The value of the predicate.</param>
- /// <param name="other">An optional other predicate that is used as an argument for this predicate.</param>
- public TraversalPredicate(string operatorName, dynamic value, TraversalPredicate other = null)
- {
- OperatorName = operatorName;
- Value = value;
- Other = other;
- }
-
- /// <summary>
- /// Gets the name of the predicate.
- /// </summary>
- public string OperatorName { get; }
-
- /// <summary>
- /// Gets the value of the predicate.
- /// </summary>
- public dynamic Value { get; }
-
- /// <summary>
- /// Gets an optional other predicate that is used as an argument for this predicate.
- /// </summary>
- public TraversalPredicate Other { get; }
-
- /// <summary>
- /// Returns a composed predicate that represents a logical AND of this predicate and another.
- /// </summary>
- /// <param name="otherPredicate">A predicate that will be logically-ANDed with this predicate.</param>
- /// <returns>The composed predicate.</returns>
- public TraversalPredicate And(TraversalPredicate otherPredicate)
- {
- return new TraversalPredicate("and", this, otherPredicate);
- }
-
- /// <summary>
- /// Returns a composed predicate that represents a logical OR of this predicate and another.
- /// </summary>
- /// <param name="otherPredicate">A predicate that will be logically-ORed with this predicate.</param>
- /// <returns>The composed predicate.</returns>
- public TraversalPredicate Or(TraversalPredicate otherPredicate)
- {
- return new TraversalPredicate("or", this, otherPredicate);
- }
-
- /// <inheritdoc />
- public override string ToString()
- {
- return Other == null ? $"{OperatorName}({Value})" : $"{OperatorName}({Value},{Other})";
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
index 9620e7f..46f510a 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
@@ -485,7 +485,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the has step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Has(string propertyKey, TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Has(string propertyKey, P predicate)
{
return new GraphTraversal<object, object>().Has(propertyKey, predicate);
}
@@ -501,7 +501,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the has step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Has(string label, string propertyKey, TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Has(string label, string propertyKey, P predicate)
{
return new GraphTraversal<object, object>().Has(label, propertyKey, predicate);
}
@@ -525,7 +525,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the has step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Has(T accessor, TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Has(T accessor, P predicate)
{
return new GraphTraversal<object, object>().Has(accessor, predicate);
}
@@ -551,7 +551,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasId step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasId(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> HasId(P predicate)
{
return new GraphTraversal<object, object>().HasId(predicate);
}
@@ -559,7 +559,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasKey step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasKey(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> HasKey(P predicate)
{
return new GraphTraversal<object, object>().HasKey(predicate);
}
@@ -577,7 +577,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasLabel step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasLabel(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> HasLabel(P predicate)
{
return new GraphTraversal<object, object>().HasLabel(predicate);
}
@@ -613,7 +613,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasValue step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasValue(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> HasValue(P predicate)
{
return new GraphTraversal<object, object>().HasValue(predicate);
}
@@ -683,7 +683,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the is step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Is(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Is(P predicate)
{
return new GraphTraversal<object, object>().Is(predicate);
}
@@ -1293,7 +1293,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the where step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Where(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Where(P predicate)
{
return new GraphTraversal<object, object>().Where(predicate);
}
@@ -1301,7 +1301,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the where step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Where(string startKey, TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Where(string startKey, P predicate)
{
return new GraphTraversal<object, object>().Where(startKey, predicate);
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/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 d5b7acc..f23d80d 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -54,7 +54,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
{typeof(DateTimeOffset), new DateSerializer()},
{typeof(Type), new ClassSerializer()},
{typeof(EnumWrapper), new EnumSerializer()},
- {typeof(TraversalPredicate), new TraversalPredicateSerializer()},
+ {typeof(P), new PSerializer()},
{typeof(Vertex), new VertexSerializer()},
{typeof(Edge), new EdgeSerializer()},
{typeof(Property), new PropertySerializer()},
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PSerializer.cs
new file mode 100644
index 0000000..46facda
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PSerializer.cs
@@ -0,0 +1,45 @@
+#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 PSerializer : IGraphSONSerializer
+ {
+ public Dictionary<string, dynamic> Dictify(dynamic predicate, GraphSONWriter writer)
+ {
+ P p = predicate;
+ var value = p.Other == null
+ ? writer.ToDict(p.Value)
+ : new List<dynamic> {writer.ToDict(p.Value), writer.ToDict(p.Other)};
+ var dict = new Dictionary<string, dynamic>
+ {
+ {"predicate", p.OperatorName},
+ {"value", value}
+ };
+ return GraphSONUtil.ToTypedValue("P", dict);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs
deleted file mode 100644
index 937cb90..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs
+++ /dev/null
@@ -1,45 +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 TraversalPredicateSerializer : IGraphSONSerializer
- {
- public Dictionary<string, dynamic> Dictify(dynamic predicate, GraphSONWriter writer)
- {
- TraversalPredicate p = predicate;
- var value = p.Other == null
- ? writer.ToDict(p.Value)
- : new List<dynamic> {writer.ToDict(p.Value), writer.ToDict(p.Other)};
- var dict = new Dictionary<string, dynamic>
- {
- {"predicate", p.OperatorName},
- {"value", value}
- };
- return GraphSONUtil.ToTypedValue("P", dict);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
index d906357..c3819fe 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
@@ -43,23 +43,15 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
{"g_V_hasIdXwithinXemptyXX_count", IgnoreReason.PWithinWrapsArgumentsInArray},
{"g_VX1X_out_aggregateXxX_out_whereXnotXwithinXaXXX", IgnoreReason.PWithinWrapsArgumentsInArray},
{
- "g_V_hasLabelXpersonX_hasXage_notXlteX10X_andXnotXbetweenX11_20XXXX_andXltX29X_orXeqX35XXXX_name",
- IgnoreReason.PNotCreatedCorrectlyByGherkinRunner
- },
- {
- "g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX",
- IgnoreReason.PNotCreatedCorrectlyByGherkinRunner
- },
- {
- "g_V_asXaX_outEXcreatedX_asXbX_inV_asXcX_whereXa_gtXbX_orXeqXbXXX_byXageX_byXweightX_byXweightX_selectXa_cX_byXnameX",
- IgnoreReason.PNotCreatedCorrectlyByGherkinRunner
+ "g_V_asXaX_out_asXbX_whereXandXasXaX_outXknowsX_asXbX__orXasXbX_outXcreatedX_hasXname_rippleX__asXbX_inXknowsX_count_isXnotXeqX0XXXXX_selectXa_bX",
+ IgnoreReason.PNotDeserializationProblem
},
{
- "g_V_asXaX_outEXcreatedX_asXbX_inV_asXcX_inXcreatedX_asXdX_whereXa_ltXbX_orXgtXcXX_andXneqXdXXX_byXageX_byXweightX_byXinXcreatedX_valuesXageX_minX_selectXa_c_dX",
- IgnoreReason.PNotCreatedCorrectlyByGherkinRunner
+ "g_V_hasLabelXpersonX_hasXage_notXlteX10X_andXnotXbetweenX11_20XXXX_andXltX29X_orXeqX35XXXX_name",
+ IgnoreReason.PNotDeserializationProblem
},
{
- "g_V_asXaX_out_asXbX_whereXandXasXaX_outXknowsX_asXbX__orXasXbX_outXcreatedX_hasXname_rippleX__asXbX_inXknowsX_count_isXnotXeqX0XXXXX_selectXa_bX",
+ "g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX",
IgnoreReason.PNotDeserializationProblem
}
};
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/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 dae2ced..fd226bf 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
@@ -43,10 +43,6 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
case IgnoreReason.LambdaNotSupported:
reasonSuffix = " because lambdas are not supported in Gremlin.NET (TINKERPOP-1854)";
break;
- case IgnoreReason.PNotCreatedCorrectlyByGherkinRunner:
- reasonSuffix =
- " because the Gherkin runner can't call methods in TraversalPredicate class (TINKERPOP-1919)";
- break;
case IgnoreReason.PWithinWrapsArgumentsInArray:
reasonSuffix = " because P.Within() arguments are incorrectly wrapped in an array (TINKERPOP-1920)";
break;
@@ -61,7 +57,6 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
public enum IgnoreReason
{
LambdaNotSupported,
- PNotCreatedCorrectlyByGherkinRunner,
PWithinWrapsArgumentsInArray,
PNotDeserializationProblem
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/PParameter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/PParameter.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/PParameter.cs
new file mode 100644
index 0000000..b25faef
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/PParameter.cs
@@ -0,0 +1,97 @@
+#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;
+using System.Collections.Generic;
+using System.Dynamic;
+using System.Linq;
+using System.Reflection;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
+{
+ /// <summary>
+ /// Represents a parameter for a traversal predicate (ie: P.gt())
+ /// </summary>
+ internal class PParameter : ITokenParameter, IEquatable<PParameter>
+ {
+ private IDictionary<string, object> _contextParameterValues;
+ public IList<Token> Tokens { get; }
+
+ public PParameter(IList<Token> tokens)
+ {
+ Tokens = tokens;
+ }
+
+ public bool Equals(PParameter other)
+ {
+ return Tokens.SequenceEqual(other.Tokens);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != GetType()) return false;
+ return Equals((PParameter) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return Tokens != null ? Tokens.GetHashCode() : 0;
+ }
+
+ public object GetValue()
+ {
+ var type = typeof(P);
+ object instance = null;
+ for (var i = 1; i < Tokens.Count; i++)
+ {
+ var token = Tokens[i];
+ token.SetContextParameterValues(_contextParameterValues);
+ var method = type.GetMethod(TraversalParser.GetCsharpName(token.Name),
+ BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);
+ if (method == null)
+ {
+ throw new InvalidOperationException($"Predicate (P) method '{token}' not found for testing");
+ }
+
+ var parameters = method.IsStatic
+ ? new object[] {token.Parameters.Select(p => p.GetValue()).ToArray()}
+ : token.Parameters.Select(p => p.GetValue()).ToArray();
+ instance = method.Invoke(instance, parameters);
+ }
+ return instance;
+ }
+
+ public Type GetParameterType()
+ {
+ return typeof(P);
+ }
+
+ public void SetContextParameterValues(IDictionary<string, object> parameterValues)
+ {
+ _contextParameterValues = parameterValues;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs
index 94a8c99..4e2bfff 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs
@@ -55,7 +55,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
new[] {new Token("__"), new Token("in", new StringParameter("knows"))}, "__.in(\"knows\")")})}),
Tuple.Create("g.V().has(\"age\",P.gt(27))",
new[] {new Token("has", new ITokenParameter[] { new StringParameter("age"),
- new TraversalPredicateParameter(
+ new PParameter(
new[] { new Token("P"), new Token("gt", LiteralParameter.Create(27)) }) })}),
Tuple.Create("g.V().count(Scope.local)",
new[] { new Token("count", new TraversalEnumParameter("Scope.local"))}),
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/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 118fcea..11145da 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
@@ -406,7 +406,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
}
if (text.Substring(i, 2).StartsWith("P."))
{
- return new TraversalPredicateParameter(ParseTokens(text, ref i));
+ return new PParameter(ParseTokens(text, ref i));
}
var parameterText = text.Substring(i, text.IndexOf(')', i) - i);
var separatorIndex = parameterText.IndexOf(',');
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalPredicateParameter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalPredicateParameter.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalPredicateParameter.cs
deleted file mode 100644
index 57262c1..0000000
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalPredicateParameter.cs
+++ /dev/null
@@ -1,93 +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;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using Gremlin.Net.Process.Traversal;
-
-namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
-{
- /// <summary>
- /// Represents a parameter for a traversal predicate (ie: P.gt())
- /// </summary>
- internal class TraversalPredicateParameter : ITokenParameter, IEquatable<TraversalPredicateParameter>
- {
- private IDictionary<string, object> _contextParameterValues;
- public IList<Token> Tokens { get; }
-
- public TraversalPredicateParameter(IList<Token> tokens)
- {
- Tokens = tokens;
- }
-
- public bool Equals(TraversalPredicateParameter other)
- {
- return Tokens.SequenceEqual(other.Tokens);
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != GetType()) return false;
- return Equals((TraversalPredicateParameter) obj);
- }
-
- public override int GetHashCode()
- {
- return Tokens != null ? Tokens.GetHashCode() : 0;
- }
-
- public object GetValue()
- {
- var type = typeof(P);
- object instance = null;
- for (var i = 1; i < Tokens.Count; i++)
- {
- var token = Tokens[i];
- token.SetContextParameterValues(_contextParameterValues);
- var method = type.GetMethod(TraversalParser.GetCsharpName(token.Name),
- BindingFlags.Static | BindingFlags.Public);
- if (method == null)
- {
- throw new InvalidOperationException($"Predicate (P) method '{token}' not found for testing");
- }
- instance = method.Invoke(instance,
- new object[] {token.Parameters.Select(p => p.GetValue()).ToArray()});
- }
- return instance;
- }
-
- public Type GetParameterType()
- {
- return typeof(TraversalPredicate);
- }
-
- public void SetContextParameterValues(IDictionary<string, object> parameterValues)
- {
- _contextParameterValues = parameterValues;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
index 8ed7a3d..568b970 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
@@ -118,7 +118,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
bytecode.AddSource("withSideEffect", "a", new List<string> {"josh", "peter"});
bytecode.AddStep("V", 1);
bytecode.AddStep("values", "name");
- bytecode.AddStep("where", new TraversalPredicate("within", "a"));
+ bytecode.AddStep("where", new P("within", "a"));
var graphsonWriter = CreateGraphSONWriter();
var graphSON = graphsonWriter.WriteObject(bytecode);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/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 3d02533..3e2d307 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
@@ -222,7 +222,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
public void ShouldSerializePredicateWithTwoValues()
{
var writer = CreateStandardGraphSONWriter();
- var predicate = new TraversalPredicate("within", new List<int> {1, 2});
+ var predicate = new P("within", new List<int> {1, 2});
var serializedPredicate = writer.WriteObject(predicate);
@@ -235,7 +235,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
public void ShouldSerializePredicateWithSingleValue()
{
var writer = CreateStandardGraphSONWriter();
- var predicate = new TraversalPredicate("lt", 5);
+ var predicate = new P("lt", 5);
var serializedPredicate = writer.WriteObject(predicate);
[05/10] tinkerpop git commit: TINKERPOP-1919 Add note about merged P
classes to upgrade docs
Posted by fl...@apache.org.
TINKERPOP-1919 Add note about merged P classes to upgrade docs
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/5cf1cba5
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/5cf1cba5
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/5cf1cba5
Branch: refs/heads/tp32
Commit: 5cf1cba59cfb6818b371b1d605dac3b8d190157a
Parents: 359b08c
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Tue Mar 13 23:39:21 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Tue Mar 13 23:39:21 2018 +0100
----------------------------------------------------------------------
docs/src/upgrade/release-3.2.x-incubating.asciidoc | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5cf1cba5/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 0cb8ddc..0848843 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -53,6 +53,18 @@ However, usage of these tokens themselves shouldn't change at all (e.g. `T.Id` i
See: link:https://issues.apache.org/jira/browse/TINKERPOP-1901[TINKERPOP-1901]
+==== Gremlin.Net: Traversal Predicate Classes Merged
+
+Gremlin.Net used two classes for traversal predicates: `P` and `TraversalPredicate`. Steps that worked with traversal
+predicates expected objects of type `TraversalPredicate`, but they were constructed from the `P` class
+(e.g. `P.Gt(1)` returned a `TraversalPredicate`). Merging these two classes into the `P` class should avoid unnecessary
+confusion. Most users should not notice this change as predicates can still be constructed exactly as before, e.g.,
+`P.Gt(1).And(P.Lt(3))` still works without any modifications.
+Only users that implemented their own predicates and used `TraversalPredicate` as the base class need to change their
+implementation to now use `P` as the new base class.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1919[TINKERPOP-1919]
+
=== Upgrading for Providers
==== Graph System Providers
[02/10] tinkerpop git commit: TINKERPOP-1919 Merge classes P and
TraversalPredicate
Posted by fl...@apache.org.
TINKERPOP-1919 Merge classes P and TraversalPredicate
There is no good reason to keep those two classes separate anymore and
having P as the type for step parameters is probably easier to
understand for users than TraversalPredicate.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/359b08cc
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/359b08cc
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/359b08cc
Branch: refs/heads/tp32
Commit: 359b08cc79ed89cab1fbc4e2b0b69b94a4e9cd06
Parents: 5049339
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Mon Mar 12 21:16:18 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Tue Mar 13 22:12:31 2018 +0100
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
gremlin-dotnet/glv/P.template | 62 ++++++++++-
gremlin-dotnet/glv/generate.groovy | 2 +-
.../Process/Traversal/GraphTraversal.cs | 20 ++--
.../src/Gremlin.Net/Process/Traversal/P.cs | 106 ++++++++++++++-----
.../Process/Traversal/TraversalPredicate.cs | 85 ---------------
.../src/Gremlin.Net/Process/Traversal/__.cs | 20 ++--
.../Structure/IO/GraphSON/GraphSONWriter.cs | 2 +-
.../Structure/IO/GraphSON/PSerializer.cs | 45 ++++++++
.../IO/GraphSON/TraversalPredicateSerializer.cs | 45 --------
.../Gherkin/GherkinTestRunner.cs | 18 +---
.../Gherkin/IgnoreException.cs | 5 -
.../Gherkin/TraversalEvaluation/PParameter.cs | 97 +++++++++++++++++
.../TraversalEvaluationTests.cs | 2 +-
.../TraversalEvaluation/TraversalParser.cs | 2 +-
.../TraversalPredicateParameter.cs | 93 ----------------
.../GraphSON/BytecodeGraphSONSerializerTests.cs | 2 +-
.../IO/GraphSON/GraphSONWriterTests.cs | 4 +-
18 files changed, 311 insertions(+), 300 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 58c4dd0..97b90a5 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -43,6 +43,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
* Fixed a bug in Gremlin Console which prevented handling of `gremlin.sh` flags that had an "=" between the flag and its arguments.
* Fixed bug where `SparkMessenger` was not applying the `edgeFunction` from `MessageScope`.
* Fixed a bug in `ComputerAwareStep` that didn't handle `reset()` properly and thus occasionally produced some extra traversers.
+* Removed `TraversalPredicate` class in Gremlin.Net. It is now included in the `P` class instead.
[[release-3-2-7]]
=== TinkerPop 3.2.7 (Release Date: December 17, 2017)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/glv/P.template
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/P.template b/gremlin-dotnet/glv/P.template
index f337127..ad037c1 100644
--- a/gremlin-dotnet/glv/P.template
+++ b/gremlin-dotnet/glv/P.template
@@ -30,20 +30,72 @@ namespace Gremlin.Net.Process.Traversal
/// A <see cref="P" /> is a predicate of the form Func<object, bool>.
/// That is, given some object, return true or false.
/// </summary>
- public class P
+ public class P : IPredicate
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="P" /> class.
+ /// </summary>
+ /// <param name="operatorName">The name of the predicate.</param>
+ /// <param name="value">The value of the predicate.</param>
+ /// <param name="other">An optional other predicate that is used as an argument for this predicate.</param>
+ public P(string operatorName, dynamic value, P other = null)
+ {
+ OperatorName = operatorName;
+ Value = value;
+ Other = other;
+ }
+
+ /// <summary>
+ /// Gets the name of the predicate.
+ /// </summary>
+ public string OperatorName { get; }
+
+ /// <summary>
+ /// Gets the value of the predicate.
+ /// </summary>
+ public dynamic Value { get; }
+
+ /// <summary>
+ /// Gets an optional other predicate that is used as an argument for this predicate.
+ /// </summary>
+ public P Other { get; }
+
+ /// <summary>
+ /// Returns a composed predicate that represents a logical AND of this predicate and another.
+ /// </summary>
+ /// <param name="otherPredicate">A predicate that will be logically-ANDed with this predicate.</param>
+ /// <returns>The composed predicate.</returns>
+ public P And(P otherPredicate)
+ {
+ return new P("and", this, otherPredicate);
+ }
+
+ /// <summary>
+ /// Returns a composed predicate that represents a logical OR of this predicate and another.
+ /// </summary>
+ /// <param name="otherPredicate">A predicate that will be logically-ORed with this predicate.</param>
+ /// <returns>The composed predicate.</returns>
+ public P Or(P otherPredicate)
+ {
+ return new P("or", this, otherPredicate);
+ }
<% pmethods.findAll{ !(it in ["within", "without"]) }.each { method -> %>
- public static TraversalPredicate <%= toCSharpMethodName.call(method) %>(params object[] args)
+ public static P <%= toCSharpMethodName.call(method) %>(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("<%= method %>", value);
+ return new P("<%= method %>", value);
}
<% } %><% pmethods.findAll{ it in ["within", "without"] }.each { method -> %>
- public static TraversalPredicate <%= toCSharpMethodName.call(method) %>(params object[] args)
+ public static P <%= toCSharpMethodName.call(method) %>(params object[] args)
{
- return new TraversalPredicate("<%= method %>", args);
+ return new P("<%= method %>", args);
}
<% } %>
+ /// <inheritdoc />
+ public override string ToString()
+ {
+ return Other == null ? \$"{OperatorName}({Value})" : \$"{OperatorName}({Value},{Other})";
+ }
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy
index 0404307..5057ff8 100644
--- a/gremlin-dotnet/glv/generate.groovy
+++ b/gremlin-dotnet/glv/generate.groovy
@@ -49,7 +49,7 @@ def toCSharpTypeMap = ["Long": "long",
"Traversal": "ITraversal",
"Traversal[]": "ITraversal[]",
"Predicate": "IPredicate",
- "P": "TraversalPredicate",
+ "P": "P",
"TraversalStrategy": "ITraversalStrategy",
"TraversalStrategy[]": "ITraversalStrategy[]",
"Function": "IFunction",
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
index 7100ea3..c8708df 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
@@ -667,7 +667,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the has step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Has (string propertyKey, TraversalPredicate predicate)
+ public GraphTraversal<S, E> Has (string propertyKey, P predicate)
{
Bytecode.AddStep("has", propertyKey, predicate);
return Wrap<S, E>(this);
@@ -685,7 +685,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the has step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Has (string label, string propertyKey, TraversalPredicate predicate)
+ public GraphTraversal<S, E> Has (string label, string propertyKey, P predicate)
{
Bytecode.AddStep("has", label, propertyKey, predicate);
return Wrap<S, E>(this);
@@ -712,7 +712,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the has step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Has (T accessor, TraversalPredicate predicate)
+ public GraphTraversal<S, E> Has (T accessor, P predicate)
{
Bytecode.AddStep("has", accessor, predicate);
return Wrap<S, E>(this);
@@ -741,7 +741,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasId step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasId (TraversalPredicate predicate)
+ public GraphTraversal<S, E> HasId (P predicate)
{
Bytecode.AddStep("hasId", predicate);
return Wrap<S, E>(this);
@@ -750,7 +750,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasKey step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasKey (TraversalPredicate predicate)
+ public GraphTraversal<S, E> HasKey (P predicate)
{
Bytecode.AddStep("hasKey", predicate);
return Wrap<S, E>(this);
@@ -770,7 +770,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasLabel step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasLabel (TraversalPredicate predicate)
+ public GraphTraversal<S, E> HasLabel (P predicate)
{
Bytecode.AddStep("hasLabel", predicate);
return Wrap<S, E>(this);
@@ -810,7 +810,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasValue step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasValue (TraversalPredicate predicate)
+ public GraphTraversal<S, E> HasValue (P predicate)
{
Bytecode.AddStep("hasValue", predicate);
return Wrap<S, E>(this);
@@ -888,7 +888,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the is step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Is (TraversalPredicate predicate)
+ public GraphTraversal<S, E> Is (P predicate)
{
Bytecode.AddStep("is", predicate);
return Wrap<S, E>(this);
@@ -1660,7 +1660,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the where step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Where (TraversalPredicate predicate)
+ public GraphTraversal<S, E> Where (P predicate)
{
Bytecode.AddStep("where", predicate);
return Wrap<S, E>(this);
@@ -1669,7 +1669,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the where step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Where (string startKey, TraversalPredicate predicate)
+ public GraphTraversal<S, E> Where (string startKey, P predicate)
{
Bytecode.AddStep("where", startKey, predicate);
return Wrap<S, E>(this);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
index 0a7809f..e3a1e76 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
@@ -30,85 +30,137 @@ namespace Gremlin.Net.Process.Traversal
/// A <see cref="P" /> is a predicate of the form Func<object, bool>.
/// That is, given some object, return true or false.
/// </summary>
- public class P
+ public class P : IPredicate
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="P" /> class.
+ /// </summary>
+ /// <param name="operatorName">The name of the predicate.</param>
+ /// <param name="value">The value of the predicate.</param>
+ /// <param name="other">An optional other predicate that is used as an argument for this predicate.</param>
+ public P(string operatorName, dynamic value, P other = null)
+ {
+ OperatorName = operatorName;
+ Value = value;
+ Other = other;
+ }
+
+ /// <summary>
+ /// Gets the name of the predicate.
+ /// </summary>
+ public string OperatorName { get; }
+
+ /// <summary>
+ /// Gets the value of the predicate.
+ /// </summary>
+ public dynamic Value { get; }
+
+ /// <summary>
+ /// Gets an optional other predicate that is used as an argument for this predicate.
+ /// </summary>
+ public P Other { get; }
+
+ /// <summary>
+ /// Returns a composed predicate that represents a logical AND of this predicate and another.
+ /// </summary>
+ /// <param name="otherPredicate">A predicate that will be logically-ANDed with this predicate.</param>
+ /// <returns>The composed predicate.</returns>
+ public P And(P otherPredicate)
+ {
+ return new P("and", this, otherPredicate);
+ }
- public static TraversalPredicate Between(params object[] args)
+ /// <summary>
+ /// Returns a composed predicate that represents a logical OR of this predicate and another.
+ /// </summary>
+ /// <param name="otherPredicate">A predicate that will be logically-ORed with this predicate.</param>
+ /// <returns>The composed predicate.</returns>
+ public P Or(P otherPredicate)
+ {
+ return new P("or", this, otherPredicate);
+ }
+
+ public static P Between(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("between", value);
+ return new P("between", value);
}
- public static TraversalPredicate Eq(params object[] args)
+ public static P Eq(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("eq", value);
+ return new P("eq", value);
}
- public static TraversalPredicate Gt(params object[] args)
+ public static P Gt(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("gt", value);
+ return new P("gt", value);
}
- public static TraversalPredicate Gte(params object[] args)
+ public static P Gte(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("gte", value);
+ return new P("gte", value);
}
- public static TraversalPredicate Inside(params object[] args)
+ public static P Inside(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("inside", value);
+ return new P("inside", value);
}
- public static TraversalPredicate Lt(params object[] args)
+ public static P Lt(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("lt", value);
+ return new P("lt", value);
}
- public static TraversalPredicate Lte(params object[] args)
+ public static P Lte(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("lte", value);
+ return new P("lte", value);
}
- public static TraversalPredicate Neq(params object[] args)
+ public static P Neq(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("neq", value);
+ return new P("neq", value);
}
- public static TraversalPredicate Not(params object[] args)
+ public static P Not(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("not", value);
+ return new P("not", value);
}
- public static TraversalPredicate Outside(params object[] args)
+ public static P Outside(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("outside", value);
+ return new P("outside", value);
}
- public static TraversalPredicate Test(params object[] args)
+ public static P Test(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("test", value);
+ return new P("test", value);
}
- public static TraversalPredicate Within(params object[] args)
+ public static P Within(params object[] args)
{
- return new TraversalPredicate("within", args);
+ return new P("within", args);
}
- public static TraversalPredicate Without(params object[] args)
+ public static P Without(params object[] args)
{
- return new TraversalPredicate("without", args);
+ return new P("without", args);
}
+ /// <inheritdoc />
+ public override string ToString()
+ {
+ return Other == null ? $"{OperatorName}({Value})" : $"{OperatorName}({Value},{Other})";
+ }
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs
deleted file mode 100644
index e8b5be8..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs
+++ /dev/null
@@ -1,85 +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
-
-namespace Gremlin.Net.Process.Traversal
-{
- /// <summary>
- /// Represents a predicate (boolean-valued function) used in a <see cref="ITraversal" />.
- /// </summary>
- public class TraversalPredicate : IPredicate
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="TraversalPredicate" /> class.
- /// </summary>
- /// <param name="operatorName">The name of the predicate.</param>
- /// <param name="value">The value of the predicate.</param>
- /// <param name="other">An optional other predicate that is used as an argument for this predicate.</param>
- public TraversalPredicate(string operatorName, dynamic value, TraversalPredicate other = null)
- {
- OperatorName = operatorName;
- Value = value;
- Other = other;
- }
-
- /// <summary>
- /// Gets the name of the predicate.
- /// </summary>
- public string OperatorName { get; }
-
- /// <summary>
- /// Gets the value of the predicate.
- /// </summary>
- public dynamic Value { get; }
-
- /// <summary>
- /// Gets an optional other predicate that is used as an argument for this predicate.
- /// </summary>
- public TraversalPredicate Other { get; }
-
- /// <summary>
- /// Returns a composed predicate that represents a logical AND of this predicate and another.
- /// </summary>
- /// <param name="otherPredicate">A predicate that will be logically-ANDed with this predicate.</param>
- /// <returns>The composed predicate.</returns>
- public TraversalPredicate And(TraversalPredicate otherPredicate)
- {
- return new TraversalPredicate("and", this, otherPredicate);
- }
-
- /// <summary>
- /// Returns a composed predicate that represents a logical OR of this predicate and another.
- /// </summary>
- /// <param name="otherPredicate">A predicate that will be logically-ORed with this predicate.</param>
- /// <returns>The composed predicate.</returns>
- public TraversalPredicate Or(TraversalPredicate otherPredicate)
- {
- return new TraversalPredicate("or", this, otherPredicate);
- }
-
- /// <inheritdoc />
- public override string ToString()
- {
- return Other == null ? $"{OperatorName}({Value})" : $"{OperatorName}({Value},{Other})";
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
index 9620e7f..46f510a 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
@@ -485,7 +485,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the has step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Has(string propertyKey, TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Has(string propertyKey, P predicate)
{
return new GraphTraversal<object, object>().Has(propertyKey, predicate);
}
@@ -501,7 +501,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the has step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Has(string label, string propertyKey, TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Has(string label, string propertyKey, P predicate)
{
return new GraphTraversal<object, object>().Has(label, propertyKey, predicate);
}
@@ -525,7 +525,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the has step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Has(T accessor, TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Has(T accessor, P predicate)
{
return new GraphTraversal<object, object>().Has(accessor, predicate);
}
@@ -551,7 +551,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasId step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasId(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> HasId(P predicate)
{
return new GraphTraversal<object, object>().HasId(predicate);
}
@@ -559,7 +559,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasKey step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasKey(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> HasKey(P predicate)
{
return new GraphTraversal<object, object>().HasKey(predicate);
}
@@ -577,7 +577,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasLabel step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasLabel(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> HasLabel(P predicate)
{
return new GraphTraversal<object, object>().HasLabel(predicate);
}
@@ -613,7 +613,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasValue step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasValue(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> HasValue(P predicate)
{
return new GraphTraversal<object, object>().HasValue(predicate);
}
@@ -683,7 +683,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the is step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Is(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Is(P predicate)
{
return new GraphTraversal<object, object>().Is(predicate);
}
@@ -1293,7 +1293,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the where step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Where(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Where(P predicate)
{
return new GraphTraversal<object, object>().Where(predicate);
}
@@ -1301,7 +1301,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the where step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Where(string startKey, TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Where(string startKey, P predicate)
{
return new GraphTraversal<object, object>().Where(startKey, predicate);
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/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 d5b7acc..f23d80d 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -54,7 +54,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
{typeof(DateTimeOffset), new DateSerializer()},
{typeof(Type), new ClassSerializer()},
{typeof(EnumWrapper), new EnumSerializer()},
- {typeof(TraversalPredicate), new TraversalPredicateSerializer()},
+ {typeof(P), new PSerializer()},
{typeof(Vertex), new VertexSerializer()},
{typeof(Edge), new EdgeSerializer()},
{typeof(Property), new PropertySerializer()},
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PSerializer.cs
new file mode 100644
index 0000000..46facda
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PSerializer.cs
@@ -0,0 +1,45 @@
+#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 PSerializer : IGraphSONSerializer
+ {
+ public Dictionary<string, dynamic> Dictify(dynamic predicate, GraphSONWriter writer)
+ {
+ P p = predicate;
+ var value = p.Other == null
+ ? writer.ToDict(p.Value)
+ : new List<dynamic> {writer.ToDict(p.Value), writer.ToDict(p.Other)};
+ var dict = new Dictionary<string, dynamic>
+ {
+ {"predicate", p.OperatorName},
+ {"value", value}
+ };
+ return GraphSONUtil.ToTypedValue("P", dict);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs
deleted file mode 100644
index 937cb90..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs
+++ /dev/null
@@ -1,45 +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 TraversalPredicateSerializer : IGraphSONSerializer
- {
- public Dictionary<string, dynamic> Dictify(dynamic predicate, GraphSONWriter writer)
- {
- TraversalPredicate p = predicate;
- var value = p.Other == null
- ? writer.ToDict(p.Value)
- : new List<dynamic> {writer.ToDict(p.Value), writer.ToDict(p.Other)};
- var dict = new Dictionary<string, dynamic>
- {
- {"predicate", p.OperatorName},
- {"value", value}
- };
- return GraphSONUtil.ToTypedValue("P", dict);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
index d906357..c3819fe 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
@@ -43,23 +43,15 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
{"g_V_hasIdXwithinXemptyXX_count", IgnoreReason.PWithinWrapsArgumentsInArray},
{"g_VX1X_out_aggregateXxX_out_whereXnotXwithinXaXXX", IgnoreReason.PWithinWrapsArgumentsInArray},
{
- "g_V_hasLabelXpersonX_hasXage_notXlteX10X_andXnotXbetweenX11_20XXXX_andXltX29X_orXeqX35XXXX_name",
- IgnoreReason.PNotCreatedCorrectlyByGherkinRunner
- },
- {
- "g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX",
- IgnoreReason.PNotCreatedCorrectlyByGherkinRunner
- },
- {
- "g_V_asXaX_outEXcreatedX_asXbX_inV_asXcX_whereXa_gtXbX_orXeqXbXXX_byXageX_byXweightX_byXweightX_selectXa_cX_byXnameX",
- IgnoreReason.PNotCreatedCorrectlyByGherkinRunner
+ "g_V_asXaX_out_asXbX_whereXandXasXaX_outXknowsX_asXbX__orXasXbX_outXcreatedX_hasXname_rippleX__asXbX_inXknowsX_count_isXnotXeqX0XXXXX_selectXa_bX",
+ IgnoreReason.PNotDeserializationProblem
},
{
- "g_V_asXaX_outEXcreatedX_asXbX_inV_asXcX_inXcreatedX_asXdX_whereXa_ltXbX_orXgtXcXX_andXneqXdXXX_byXageX_byXweightX_byXinXcreatedX_valuesXageX_minX_selectXa_c_dX",
- IgnoreReason.PNotCreatedCorrectlyByGherkinRunner
+ "g_V_hasLabelXpersonX_hasXage_notXlteX10X_andXnotXbetweenX11_20XXXX_andXltX29X_orXeqX35XXXX_name",
+ IgnoreReason.PNotDeserializationProblem
},
{
- "g_V_asXaX_out_asXbX_whereXandXasXaX_outXknowsX_asXbX__orXasXbX_outXcreatedX_hasXname_rippleX__asXbX_inXknowsX_count_isXnotXeqX0XXXXX_selectXa_bX",
+ "g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX",
IgnoreReason.PNotDeserializationProblem
}
};
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/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 dae2ced..fd226bf 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
@@ -43,10 +43,6 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
case IgnoreReason.LambdaNotSupported:
reasonSuffix = " because lambdas are not supported in Gremlin.NET (TINKERPOP-1854)";
break;
- case IgnoreReason.PNotCreatedCorrectlyByGherkinRunner:
- reasonSuffix =
- " because the Gherkin runner can't call methods in TraversalPredicate class (TINKERPOP-1919)";
- break;
case IgnoreReason.PWithinWrapsArgumentsInArray:
reasonSuffix = " because P.Within() arguments are incorrectly wrapped in an array (TINKERPOP-1920)";
break;
@@ -61,7 +57,6 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
public enum IgnoreReason
{
LambdaNotSupported,
- PNotCreatedCorrectlyByGherkinRunner,
PWithinWrapsArgumentsInArray,
PNotDeserializationProblem
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/PParameter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/PParameter.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/PParameter.cs
new file mode 100644
index 0000000..b25faef
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/PParameter.cs
@@ -0,0 +1,97 @@
+#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;
+using System.Collections.Generic;
+using System.Dynamic;
+using System.Linq;
+using System.Reflection;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
+{
+ /// <summary>
+ /// Represents a parameter for a traversal predicate (ie: P.gt())
+ /// </summary>
+ internal class PParameter : ITokenParameter, IEquatable<PParameter>
+ {
+ private IDictionary<string, object> _contextParameterValues;
+ public IList<Token> Tokens { get; }
+
+ public PParameter(IList<Token> tokens)
+ {
+ Tokens = tokens;
+ }
+
+ public bool Equals(PParameter other)
+ {
+ return Tokens.SequenceEqual(other.Tokens);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != GetType()) return false;
+ return Equals((PParameter) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return Tokens != null ? Tokens.GetHashCode() : 0;
+ }
+
+ public object GetValue()
+ {
+ var type = typeof(P);
+ object instance = null;
+ for (var i = 1; i < Tokens.Count; i++)
+ {
+ var token = Tokens[i];
+ token.SetContextParameterValues(_contextParameterValues);
+ var method = type.GetMethod(TraversalParser.GetCsharpName(token.Name),
+ BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);
+ if (method == null)
+ {
+ throw new InvalidOperationException($"Predicate (P) method '{token}' not found for testing");
+ }
+
+ var parameters = method.IsStatic
+ ? new object[] {token.Parameters.Select(p => p.GetValue()).ToArray()}
+ : token.Parameters.Select(p => p.GetValue()).ToArray();
+ instance = method.Invoke(instance, parameters);
+ }
+ return instance;
+ }
+
+ public Type GetParameterType()
+ {
+ return typeof(P);
+ }
+
+ public void SetContextParameterValues(IDictionary<string, object> parameterValues)
+ {
+ _contextParameterValues = parameterValues;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs
index 94a8c99..4e2bfff 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs
@@ -55,7 +55,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
new[] {new Token("__"), new Token("in", new StringParameter("knows"))}, "__.in(\"knows\")")})}),
Tuple.Create("g.V().has(\"age\",P.gt(27))",
new[] {new Token("has", new ITokenParameter[] { new StringParameter("age"),
- new TraversalPredicateParameter(
+ new PParameter(
new[] { new Token("P"), new Token("gt", LiteralParameter.Create(27)) }) })}),
Tuple.Create("g.V().count(Scope.local)",
new[] { new Token("count", new TraversalEnumParameter("Scope.local"))}),
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/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 118fcea..11145da 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
@@ -406,7 +406,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
}
if (text.Substring(i, 2).StartsWith("P."))
{
- return new TraversalPredicateParameter(ParseTokens(text, ref i));
+ return new PParameter(ParseTokens(text, ref i));
}
var parameterText = text.Substring(i, text.IndexOf(')', i) - i);
var separatorIndex = parameterText.IndexOf(',');
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalPredicateParameter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalPredicateParameter.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalPredicateParameter.cs
deleted file mode 100644
index 57262c1..0000000
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalPredicateParameter.cs
+++ /dev/null
@@ -1,93 +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;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using Gremlin.Net.Process.Traversal;
-
-namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
-{
- /// <summary>
- /// Represents a parameter for a traversal predicate (ie: P.gt())
- /// </summary>
- internal class TraversalPredicateParameter : ITokenParameter, IEquatable<TraversalPredicateParameter>
- {
- private IDictionary<string, object> _contextParameterValues;
- public IList<Token> Tokens { get; }
-
- public TraversalPredicateParameter(IList<Token> tokens)
- {
- Tokens = tokens;
- }
-
- public bool Equals(TraversalPredicateParameter other)
- {
- return Tokens.SequenceEqual(other.Tokens);
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != GetType()) return false;
- return Equals((TraversalPredicateParameter) obj);
- }
-
- public override int GetHashCode()
- {
- return Tokens != null ? Tokens.GetHashCode() : 0;
- }
-
- public object GetValue()
- {
- var type = typeof(P);
- object instance = null;
- for (var i = 1; i < Tokens.Count; i++)
- {
- var token = Tokens[i];
- token.SetContextParameterValues(_contextParameterValues);
- var method = type.GetMethod(TraversalParser.GetCsharpName(token.Name),
- BindingFlags.Static | BindingFlags.Public);
- if (method == null)
- {
- throw new InvalidOperationException($"Predicate (P) method '{token}' not found for testing");
- }
- instance = method.Invoke(instance,
- new object[] {token.Parameters.Select(p => p.GetValue()).ToArray()});
- }
- return instance;
- }
-
- public Type GetParameterType()
- {
- return typeof(TraversalPredicate);
- }
-
- public void SetContextParameterValues(IDictionary<string, object> parameterValues)
- {
- _contextParameterValues = parameterValues;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
index 8ed7a3d..568b970 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
@@ -118,7 +118,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
bytecode.AddSource("withSideEffect", "a", new List<string> {"josh", "peter"});
bytecode.AddStep("V", 1);
bytecode.AddStep("values", "name");
- bytecode.AddStep("where", new TraversalPredicate("within", "a"));
+ bytecode.AddStep("where", new P("within", "a"));
var graphsonWriter = CreateGraphSONWriter();
var graphSON = graphsonWriter.WriteObject(bytecode);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/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 3d02533..3e2d307 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
@@ -222,7 +222,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
public void ShouldSerializePredicateWithTwoValues()
{
var writer = CreateStandardGraphSONWriter();
- var predicate = new TraversalPredicate("within", new List<int> {1, 2});
+ var predicate = new P("within", new List<int> {1, 2});
var serializedPredicate = writer.WriteObject(predicate);
@@ -235,7 +235,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
public void ShouldSerializePredicateWithSingleValue()
{
var writer = CreateStandardGraphSONWriter();
- var predicate = new TraversalPredicate("lt", 5);
+ var predicate = new P("lt", 5);
var serializedPredicate = writer.WriteObject(predicate);
[09/10] 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/9bd4d7fe
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/9bd4d7fe
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/9bd4d7fe
Branch: refs/heads/tp33
Commit: 9bd4d7fedf943f5f09d5e5a0f77e27efbc559e2e
Parents: 2d493fb 5cf1cba
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Tue Mar 13 23:50:48 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Tue Mar 13 23:50:48 2018 +0100
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../upgrade/release-3.2.x-incubating.asciidoc | 12 +++
gremlin-dotnet/glv/P.template | 62 ++++++++++-
gremlin-dotnet/glv/generate.groovy | 2 +-
.../Process/Traversal/GraphTraversal.cs | 20 ++--
.../src/Gremlin.Net/Process/Traversal/P.cs | 106 ++++++++++++++-----
.../Process/Traversal/TraversalPredicate.cs | 85 ---------------
.../src/Gremlin.Net/Process/Traversal/__.cs | 20 ++--
.../Structure/IO/GraphSON/GraphSONWriter.cs | 2 +-
.../Structure/IO/GraphSON/PSerializer.cs | 45 ++++++++
.../IO/GraphSON/TraversalPredicateSerializer.cs | 45 --------
.../Gherkin/GherkinTestRunner.cs | 18 +---
.../Gherkin/IgnoreException.cs | 5 -
.../Gherkin/TraversalEvaluation/PParameter.cs | 97 +++++++++++++++++
.../TraversalEvaluationTests.cs | 2 +-
.../TraversalEvaluation/TraversalParser.cs | 2 +-
.../TraversalPredicateParameter.cs | 93 ----------------
.../GraphSON/BytecodeGraphSONSerializerTests.cs | 2 +-
.../IO/GraphSON/GraphSONWriterTests.cs | 4 +-
19 files changed, 323 insertions(+), 300 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/CHANGELOG.asciidoc
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
----------------------------------------------------------------------
diff --cc gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
index da455a8,fd226bf..56984d9
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
@@@ -43,13 -43,6 +43,9 @@@ namespace Gremlin.Net.IntegrationTest.G
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.PNotCreatedCorrectlyByGherkinRunner:
- reasonSuffix =
- " because the Gherkin runner can't call methods in TraversalPredicate class (TINKERPOP-1919)";
- break;
case IgnoreReason.PWithinWrapsArgumentsInArray:
reasonSuffix = " because P.Within() arguments are incorrectly wrapped in an array (TINKERPOP-1920)";
break;
@@@ -63,17 -56,7 +59,16 @@@
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,
+
- PNotCreatedCorrectlyByGherkinRunner,
PWithinWrapsArgumentsInArray,
PNotDeserializationProblem
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
----------------------------------------------------------------------
diff --cc gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
index ab7be13,568b970..9b39391
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
@@@ -125,15 -111,15 +125,15 @@@ namespace Gremlin.Net.UnitTest.Structur
Assert.Equal(expectedGraphSon, graphSON);
}
- [Fact]
- public void ShouldSerializeBytecodeWithSourcesStep()
+ [Theory, MemberData(nameof(Versions))]
+ public void ShouldSerializeBytecodeWithSourcesStep(int version)
{
var bytecode = new Bytecode();
- bytecode.AddSource("withSideEffect", "a", new List<string> {"josh", "peter"});
+ bytecode.AddSource("withSideEffect", "a", "josh");
bytecode.AddStep("V", 1);
bytecode.AddStep("values", "name");
- bytecode.AddStep("where", new TraversalPredicate("within", "a"));
+ bytecode.AddStep("where", new P("within", "a"));
- var graphsonWriter = CreateGraphSONWriter();
+ var graphsonWriter = CreateGraphSONWriter(version);
var graphSON = graphsonWriter.WriteObject(bytecode);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/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 beb514e,3e2d307..0898c1c
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
@@@ -239,50 -218,11 +239,50 @@@ namespace Gremlin.Net.UnitTest.Structur
Assert.Equal(expectedGraphSON, serializedGraphSON);
}
- [Fact]
- public void ShouldSerializePredicateWithTwoValues()
+ [Theory, MemberData(nameof(VersionsSupportingCollections))]
+ public void ShouldSerializeGList(int version)
+ {
+ var writer = CreateGraphSONWriter(version);
+ var list = new List<object> {5, 6};
+
+ var serializedGraphSON = writer.WriteObject(list);
+
+ var expectedGraphSON = "{\"@type\":\"g:List\",\"@value\":[{\"@type\":\"g:Int32\",\"@value\":5}," +
+ "{\"@type\":\"g:Int32\",\"@value\":6}]}";
+ Assert.Equal(expectedGraphSON, serializedGraphSON);
+ }
+
+ [Theory, MemberData(nameof(VersionsSupportingCollections))]
+ public void ShouldSerializeGSet(int version)
+ {
+ var writer = CreateGraphSONWriter(version);
+ ISet<object> set = new HashSet<object> {600L, 700L};
+
+ var serializedGraphSON = writer.WriteObject(set);
+
+ var expectedGraphSON = "{\"@type\":\"g:Set\",\"@value\":[{\"@type\":\"g:Int64\",\"@value\":600}," +
+ "{\"@type\":\"g:Int64\",\"@value\":700}]}";
+ Assert.Equal(expectedGraphSON, serializedGraphSON);
+ }
+
+ [Theory, MemberData(nameof(VersionsSupportingCollections))]
+ public void ShouldSerializeGMap(int version)
+ {
+ var writer = CreateGraphSONWriter(version);
+ IDictionary<object, object> map = new Dictionary<object, object> { { 1L, "a"}, { 200L, "b"}};
+
+ var serializedGraphSON = writer.WriteObject(map);
+
+ var expectedGraphSON = "{\"@type\":\"g:Map\",\"@value\":[{\"@type\":\"g:Int64\",\"@value\":1},\"a\"," +
+ "{\"@type\":\"g:Int64\",\"@value\":200},\"b\"]}";
+ Assert.Equal(expectedGraphSON, serializedGraphSON);
+ }
+
+ [Theory, MemberData(nameof(Versions))]
+ public void ShouldSerializePredicateWithTwoValues(int version)
{
- var writer = CreateStandardGraphSONWriter();
+ var writer = CreateGraphSONWriter(version);
- var predicate = new TraversalPredicate("within", new List<int> {1, 2});
+ var predicate = new P("within", new List<int> {1, 2});
var serializedPredicate = writer.WriteObject(predicate);
@@@ -291,11 -231,11 +291,11 @@@
Assert.Equal(expectedGraphSON, serializedPredicate);
}
- [Fact]
- public void ShouldSerializePredicateWithSingleValue()
+ [Theory, MemberData(nameof(Versions))]
+ public void ShouldSerializePredicateWithSingleValue(int version)
{
- var writer = CreateStandardGraphSONWriter();
+ var writer = CreateGraphSONWriter(version);
- var predicate = new TraversalPredicate("lt", 5);
+ var predicate = new P("lt", 5);
var serializedPredicate = writer.WriteObject(predicate);
[03/10] tinkerpop git commit: TINKERPOP-1919 Merge classes P and
TraversalPredicate
Posted by fl...@apache.org.
TINKERPOP-1919 Merge classes P and TraversalPredicate
There is no good reason to keep those two classes separate anymore and
having P as the type for step parameters is probably easier to
understand for users than TraversalPredicate.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/359b08cc
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/359b08cc
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/359b08cc
Branch: refs/heads/tp33
Commit: 359b08cc79ed89cab1fbc4e2b0b69b94a4e9cd06
Parents: 5049339
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Mon Mar 12 21:16:18 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Tue Mar 13 22:12:31 2018 +0100
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
gremlin-dotnet/glv/P.template | 62 ++++++++++-
gremlin-dotnet/glv/generate.groovy | 2 +-
.../Process/Traversal/GraphTraversal.cs | 20 ++--
.../src/Gremlin.Net/Process/Traversal/P.cs | 106 ++++++++++++++-----
.../Process/Traversal/TraversalPredicate.cs | 85 ---------------
.../src/Gremlin.Net/Process/Traversal/__.cs | 20 ++--
.../Structure/IO/GraphSON/GraphSONWriter.cs | 2 +-
.../Structure/IO/GraphSON/PSerializer.cs | 45 ++++++++
.../IO/GraphSON/TraversalPredicateSerializer.cs | 45 --------
.../Gherkin/GherkinTestRunner.cs | 18 +---
.../Gherkin/IgnoreException.cs | 5 -
.../Gherkin/TraversalEvaluation/PParameter.cs | 97 +++++++++++++++++
.../TraversalEvaluationTests.cs | 2 +-
.../TraversalEvaluation/TraversalParser.cs | 2 +-
.../TraversalPredicateParameter.cs | 93 ----------------
.../GraphSON/BytecodeGraphSONSerializerTests.cs | 2 +-
.../IO/GraphSON/GraphSONWriterTests.cs | 4 +-
18 files changed, 311 insertions(+), 300 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 58c4dd0..97b90a5 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -43,6 +43,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
* Fixed a bug in Gremlin Console which prevented handling of `gremlin.sh` flags that had an "=" between the flag and its arguments.
* Fixed bug where `SparkMessenger` was not applying the `edgeFunction` from `MessageScope`.
* Fixed a bug in `ComputerAwareStep` that didn't handle `reset()` properly and thus occasionally produced some extra traversers.
+* Removed `TraversalPredicate` class in Gremlin.Net. It is now included in the `P` class instead.
[[release-3-2-7]]
=== TinkerPop 3.2.7 (Release Date: December 17, 2017)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/glv/P.template
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/P.template b/gremlin-dotnet/glv/P.template
index f337127..ad037c1 100644
--- a/gremlin-dotnet/glv/P.template
+++ b/gremlin-dotnet/glv/P.template
@@ -30,20 +30,72 @@ namespace Gremlin.Net.Process.Traversal
/// A <see cref="P" /> is a predicate of the form Func<object, bool>.
/// That is, given some object, return true or false.
/// </summary>
- public class P
+ public class P : IPredicate
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="P" /> class.
+ /// </summary>
+ /// <param name="operatorName">The name of the predicate.</param>
+ /// <param name="value">The value of the predicate.</param>
+ /// <param name="other">An optional other predicate that is used as an argument for this predicate.</param>
+ public P(string operatorName, dynamic value, P other = null)
+ {
+ OperatorName = operatorName;
+ Value = value;
+ Other = other;
+ }
+
+ /// <summary>
+ /// Gets the name of the predicate.
+ /// </summary>
+ public string OperatorName { get; }
+
+ /// <summary>
+ /// Gets the value of the predicate.
+ /// </summary>
+ public dynamic Value { get; }
+
+ /// <summary>
+ /// Gets an optional other predicate that is used as an argument for this predicate.
+ /// </summary>
+ public P Other { get; }
+
+ /// <summary>
+ /// Returns a composed predicate that represents a logical AND of this predicate and another.
+ /// </summary>
+ /// <param name="otherPredicate">A predicate that will be logically-ANDed with this predicate.</param>
+ /// <returns>The composed predicate.</returns>
+ public P And(P otherPredicate)
+ {
+ return new P("and", this, otherPredicate);
+ }
+
+ /// <summary>
+ /// Returns a composed predicate that represents a logical OR of this predicate and another.
+ /// </summary>
+ /// <param name="otherPredicate">A predicate that will be logically-ORed with this predicate.</param>
+ /// <returns>The composed predicate.</returns>
+ public P Or(P otherPredicate)
+ {
+ return new P("or", this, otherPredicate);
+ }
<% pmethods.findAll{ !(it in ["within", "without"]) }.each { method -> %>
- public static TraversalPredicate <%= toCSharpMethodName.call(method) %>(params object[] args)
+ public static P <%= toCSharpMethodName.call(method) %>(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("<%= method %>", value);
+ return new P("<%= method %>", value);
}
<% } %><% pmethods.findAll{ it in ["within", "without"] }.each { method -> %>
- public static TraversalPredicate <%= toCSharpMethodName.call(method) %>(params object[] args)
+ public static P <%= toCSharpMethodName.call(method) %>(params object[] args)
{
- return new TraversalPredicate("<%= method %>", args);
+ return new P("<%= method %>", args);
}
<% } %>
+ /// <inheritdoc />
+ public override string ToString()
+ {
+ return Other == null ? \$"{OperatorName}({Value})" : \$"{OperatorName}({Value},{Other})";
+ }
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy
index 0404307..5057ff8 100644
--- a/gremlin-dotnet/glv/generate.groovy
+++ b/gremlin-dotnet/glv/generate.groovy
@@ -49,7 +49,7 @@ def toCSharpTypeMap = ["Long": "long",
"Traversal": "ITraversal",
"Traversal[]": "ITraversal[]",
"Predicate": "IPredicate",
- "P": "TraversalPredicate",
+ "P": "P",
"TraversalStrategy": "ITraversalStrategy",
"TraversalStrategy[]": "ITraversalStrategy[]",
"Function": "IFunction",
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
index 7100ea3..c8708df 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
@@ -667,7 +667,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the has step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Has (string propertyKey, TraversalPredicate predicate)
+ public GraphTraversal<S, E> Has (string propertyKey, P predicate)
{
Bytecode.AddStep("has", propertyKey, predicate);
return Wrap<S, E>(this);
@@ -685,7 +685,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the has step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Has (string label, string propertyKey, TraversalPredicate predicate)
+ public GraphTraversal<S, E> Has (string label, string propertyKey, P predicate)
{
Bytecode.AddStep("has", label, propertyKey, predicate);
return Wrap<S, E>(this);
@@ -712,7 +712,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the has step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Has (T accessor, TraversalPredicate predicate)
+ public GraphTraversal<S, E> Has (T accessor, P predicate)
{
Bytecode.AddStep("has", accessor, predicate);
return Wrap<S, E>(this);
@@ -741,7 +741,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasId step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasId (TraversalPredicate predicate)
+ public GraphTraversal<S, E> HasId (P predicate)
{
Bytecode.AddStep("hasId", predicate);
return Wrap<S, E>(this);
@@ -750,7 +750,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasKey step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasKey (TraversalPredicate predicate)
+ public GraphTraversal<S, E> HasKey (P predicate)
{
Bytecode.AddStep("hasKey", predicate);
return Wrap<S, E>(this);
@@ -770,7 +770,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasLabel step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasLabel (TraversalPredicate predicate)
+ public GraphTraversal<S, E> HasLabel (P predicate)
{
Bytecode.AddStep("hasLabel", predicate);
return Wrap<S, E>(this);
@@ -810,7 +810,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasValue step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasValue (TraversalPredicate predicate)
+ public GraphTraversal<S, E> HasValue (P predicate)
{
Bytecode.AddStep("hasValue", predicate);
return Wrap<S, E>(this);
@@ -888,7 +888,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the is step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Is (TraversalPredicate predicate)
+ public GraphTraversal<S, E> Is (P predicate)
{
Bytecode.AddStep("is", predicate);
return Wrap<S, E>(this);
@@ -1660,7 +1660,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the where step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Where (TraversalPredicate predicate)
+ public GraphTraversal<S, E> Where (P predicate)
{
Bytecode.AddStep("where", predicate);
return Wrap<S, E>(this);
@@ -1669,7 +1669,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the where step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Where (string startKey, TraversalPredicate predicate)
+ public GraphTraversal<S, E> Where (string startKey, P predicate)
{
Bytecode.AddStep("where", startKey, predicate);
return Wrap<S, E>(this);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
index 0a7809f..e3a1e76 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
@@ -30,85 +30,137 @@ namespace Gremlin.Net.Process.Traversal
/// A <see cref="P" /> is a predicate of the form Func<object, bool>.
/// That is, given some object, return true or false.
/// </summary>
- public class P
+ public class P : IPredicate
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="P" /> class.
+ /// </summary>
+ /// <param name="operatorName">The name of the predicate.</param>
+ /// <param name="value">The value of the predicate.</param>
+ /// <param name="other">An optional other predicate that is used as an argument for this predicate.</param>
+ public P(string operatorName, dynamic value, P other = null)
+ {
+ OperatorName = operatorName;
+ Value = value;
+ Other = other;
+ }
+
+ /// <summary>
+ /// Gets the name of the predicate.
+ /// </summary>
+ public string OperatorName { get; }
+
+ /// <summary>
+ /// Gets the value of the predicate.
+ /// </summary>
+ public dynamic Value { get; }
+
+ /// <summary>
+ /// Gets an optional other predicate that is used as an argument for this predicate.
+ /// </summary>
+ public P Other { get; }
+
+ /// <summary>
+ /// Returns a composed predicate that represents a logical AND of this predicate and another.
+ /// </summary>
+ /// <param name="otherPredicate">A predicate that will be logically-ANDed with this predicate.</param>
+ /// <returns>The composed predicate.</returns>
+ public P And(P otherPredicate)
+ {
+ return new P("and", this, otherPredicate);
+ }
- public static TraversalPredicate Between(params object[] args)
+ /// <summary>
+ /// Returns a composed predicate that represents a logical OR of this predicate and another.
+ /// </summary>
+ /// <param name="otherPredicate">A predicate that will be logically-ORed with this predicate.</param>
+ /// <returns>The composed predicate.</returns>
+ public P Or(P otherPredicate)
+ {
+ return new P("or", this, otherPredicate);
+ }
+
+ public static P Between(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("between", value);
+ return new P("between", value);
}
- public static TraversalPredicate Eq(params object[] args)
+ public static P Eq(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("eq", value);
+ return new P("eq", value);
}
- public static TraversalPredicate Gt(params object[] args)
+ public static P Gt(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("gt", value);
+ return new P("gt", value);
}
- public static TraversalPredicate Gte(params object[] args)
+ public static P Gte(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("gte", value);
+ return new P("gte", value);
}
- public static TraversalPredicate Inside(params object[] args)
+ public static P Inside(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("inside", value);
+ return new P("inside", value);
}
- public static TraversalPredicate Lt(params object[] args)
+ public static P Lt(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("lt", value);
+ return new P("lt", value);
}
- public static TraversalPredicate Lte(params object[] args)
+ public static P Lte(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("lte", value);
+ return new P("lte", value);
}
- public static TraversalPredicate Neq(params object[] args)
+ public static P Neq(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("neq", value);
+ return new P("neq", value);
}
- public static TraversalPredicate Not(params object[] args)
+ public static P Not(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("not", value);
+ return new P("not", value);
}
- public static TraversalPredicate Outside(params object[] args)
+ public static P Outside(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("outside", value);
+ return new P("outside", value);
}
- public static TraversalPredicate Test(params object[] args)
+ public static P Test(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("test", value);
+ return new P("test", value);
}
- public static TraversalPredicate Within(params object[] args)
+ public static P Within(params object[] args)
{
- return new TraversalPredicate("within", args);
+ return new P("within", args);
}
- public static TraversalPredicate Without(params object[] args)
+ public static P Without(params object[] args)
{
- return new TraversalPredicate("without", args);
+ return new P("without", args);
}
+ /// <inheritdoc />
+ public override string ToString()
+ {
+ return Other == null ? $"{OperatorName}({Value})" : $"{OperatorName}({Value},{Other})";
+ }
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs
deleted file mode 100644
index e8b5be8..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs
+++ /dev/null
@@ -1,85 +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
-
-namespace Gremlin.Net.Process.Traversal
-{
- /// <summary>
- /// Represents a predicate (boolean-valued function) used in a <see cref="ITraversal" />.
- /// </summary>
- public class TraversalPredicate : IPredicate
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="TraversalPredicate" /> class.
- /// </summary>
- /// <param name="operatorName">The name of the predicate.</param>
- /// <param name="value">The value of the predicate.</param>
- /// <param name="other">An optional other predicate that is used as an argument for this predicate.</param>
- public TraversalPredicate(string operatorName, dynamic value, TraversalPredicate other = null)
- {
- OperatorName = operatorName;
- Value = value;
- Other = other;
- }
-
- /// <summary>
- /// Gets the name of the predicate.
- /// </summary>
- public string OperatorName { get; }
-
- /// <summary>
- /// Gets the value of the predicate.
- /// </summary>
- public dynamic Value { get; }
-
- /// <summary>
- /// Gets an optional other predicate that is used as an argument for this predicate.
- /// </summary>
- public TraversalPredicate Other { get; }
-
- /// <summary>
- /// Returns a composed predicate that represents a logical AND of this predicate and another.
- /// </summary>
- /// <param name="otherPredicate">A predicate that will be logically-ANDed with this predicate.</param>
- /// <returns>The composed predicate.</returns>
- public TraversalPredicate And(TraversalPredicate otherPredicate)
- {
- return new TraversalPredicate("and", this, otherPredicate);
- }
-
- /// <summary>
- /// Returns a composed predicate that represents a logical OR of this predicate and another.
- /// </summary>
- /// <param name="otherPredicate">A predicate that will be logically-ORed with this predicate.</param>
- /// <returns>The composed predicate.</returns>
- public TraversalPredicate Or(TraversalPredicate otherPredicate)
- {
- return new TraversalPredicate("or", this, otherPredicate);
- }
-
- /// <inheritdoc />
- public override string ToString()
- {
- return Other == null ? $"{OperatorName}({Value})" : $"{OperatorName}({Value},{Other})";
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
index 9620e7f..46f510a 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
@@ -485,7 +485,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the has step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Has(string propertyKey, TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Has(string propertyKey, P predicate)
{
return new GraphTraversal<object, object>().Has(propertyKey, predicate);
}
@@ -501,7 +501,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the has step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Has(string label, string propertyKey, TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Has(string label, string propertyKey, P predicate)
{
return new GraphTraversal<object, object>().Has(label, propertyKey, predicate);
}
@@ -525,7 +525,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the has step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Has(T accessor, TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Has(T accessor, P predicate)
{
return new GraphTraversal<object, object>().Has(accessor, predicate);
}
@@ -551,7 +551,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasId step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasId(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> HasId(P predicate)
{
return new GraphTraversal<object, object>().HasId(predicate);
}
@@ -559,7 +559,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasKey step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasKey(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> HasKey(P predicate)
{
return new GraphTraversal<object, object>().HasKey(predicate);
}
@@ -577,7 +577,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasLabel step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasLabel(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> HasLabel(P predicate)
{
return new GraphTraversal<object, object>().HasLabel(predicate);
}
@@ -613,7 +613,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasValue step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasValue(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> HasValue(P predicate)
{
return new GraphTraversal<object, object>().HasValue(predicate);
}
@@ -683,7 +683,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the is step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Is(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Is(P predicate)
{
return new GraphTraversal<object, object>().Is(predicate);
}
@@ -1293,7 +1293,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the where step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Where(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Where(P predicate)
{
return new GraphTraversal<object, object>().Where(predicate);
}
@@ -1301,7 +1301,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the where step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Where(string startKey, TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Where(string startKey, P predicate)
{
return new GraphTraversal<object, object>().Where(startKey, predicate);
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/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 d5b7acc..f23d80d 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -54,7 +54,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
{typeof(DateTimeOffset), new DateSerializer()},
{typeof(Type), new ClassSerializer()},
{typeof(EnumWrapper), new EnumSerializer()},
- {typeof(TraversalPredicate), new TraversalPredicateSerializer()},
+ {typeof(P), new PSerializer()},
{typeof(Vertex), new VertexSerializer()},
{typeof(Edge), new EdgeSerializer()},
{typeof(Property), new PropertySerializer()},
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PSerializer.cs
new file mode 100644
index 0000000..46facda
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PSerializer.cs
@@ -0,0 +1,45 @@
+#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 PSerializer : IGraphSONSerializer
+ {
+ public Dictionary<string, dynamic> Dictify(dynamic predicate, GraphSONWriter writer)
+ {
+ P p = predicate;
+ var value = p.Other == null
+ ? writer.ToDict(p.Value)
+ : new List<dynamic> {writer.ToDict(p.Value), writer.ToDict(p.Other)};
+ var dict = new Dictionary<string, dynamic>
+ {
+ {"predicate", p.OperatorName},
+ {"value", value}
+ };
+ return GraphSONUtil.ToTypedValue("P", dict);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs
deleted file mode 100644
index 937cb90..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs
+++ /dev/null
@@ -1,45 +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 TraversalPredicateSerializer : IGraphSONSerializer
- {
- public Dictionary<string, dynamic> Dictify(dynamic predicate, GraphSONWriter writer)
- {
- TraversalPredicate p = predicate;
- var value = p.Other == null
- ? writer.ToDict(p.Value)
- : new List<dynamic> {writer.ToDict(p.Value), writer.ToDict(p.Other)};
- var dict = new Dictionary<string, dynamic>
- {
- {"predicate", p.OperatorName},
- {"value", value}
- };
- return GraphSONUtil.ToTypedValue("P", dict);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
index d906357..c3819fe 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
@@ -43,23 +43,15 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
{"g_V_hasIdXwithinXemptyXX_count", IgnoreReason.PWithinWrapsArgumentsInArray},
{"g_VX1X_out_aggregateXxX_out_whereXnotXwithinXaXXX", IgnoreReason.PWithinWrapsArgumentsInArray},
{
- "g_V_hasLabelXpersonX_hasXage_notXlteX10X_andXnotXbetweenX11_20XXXX_andXltX29X_orXeqX35XXXX_name",
- IgnoreReason.PNotCreatedCorrectlyByGherkinRunner
- },
- {
- "g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX",
- IgnoreReason.PNotCreatedCorrectlyByGherkinRunner
- },
- {
- "g_V_asXaX_outEXcreatedX_asXbX_inV_asXcX_whereXa_gtXbX_orXeqXbXXX_byXageX_byXweightX_byXweightX_selectXa_cX_byXnameX",
- IgnoreReason.PNotCreatedCorrectlyByGherkinRunner
+ "g_V_asXaX_out_asXbX_whereXandXasXaX_outXknowsX_asXbX__orXasXbX_outXcreatedX_hasXname_rippleX__asXbX_inXknowsX_count_isXnotXeqX0XXXXX_selectXa_bX",
+ IgnoreReason.PNotDeserializationProblem
},
{
- "g_V_asXaX_outEXcreatedX_asXbX_inV_asXcX_inXcreatedX_asXdX_whereXa_ltXbX_orXgtXcXX_andXneqXdXXX_byXageX_byXweightX_byXinXcreatedX_valuesXageX_minX_selectXa_c_dX",
- IgnoreReason.PNotCreatedCorrectlyByGherkinRunner
+ "g_V_hasLabelXpersonX_hasXage_notXlteX10X_andXnotXbetweenX11_20XXXX_andXltX29X_orXeqX35XXXX_name",
+ IgnoreReason.PNotDeserializationProblem
},
{
- "g_V_asXaX_out_asXbX_whereXandXasXaX_outXknowsX_asXbX__orXasXbX_outXcreatedX_hasXname_rippleX__asXbX_inXknowsX_count_isXnotXeqX0XXXXX_selectXa_bX",
+ "g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX",
IgnoreReason.PNotDeserializationProblem
}
};
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/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 dae2ced..fd226bf 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
@@ -43,10 +43,6 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
case IgnoreReason.LambdaNotSupported:
reasonSuffix = " because lambdas are not supported in Gremlin.NET (TINKERPOP-1854)";
break;
- case IgnoreReason.PNotCreatedCorrectlyByGherkinRunner:
- reasonSuffix =
- " because the Gherkin runner can't call methods in TraversalPredicate class (TINKERPOP-1919)";
- break;
case IgnoreReason.PWithinWrapsArgumentsInArray:
reasonSuffix = " because P.Within() arguments are incorrectly wrapped in an array (TINKERPOP-1920)";
break;
@@ -61,7 +57,6 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
public enum IgnoreReason
{
LambdaNotSupported,
- PNotCreatedCorrectlyByGherkinRunner,
PWithinWrapsArgumentsInArray,
PNotDeserializationProblem
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/PParameter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/PParameter.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/PParameter.cs
new file mode 100644
index 0000000..b25faef
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/PParameter.cs
@@ -0,0 +1,97 @@
+#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;
+using System.Collections.Generic;
+using System.Dynamic;
+using System.Linq;
+using System.Reflection;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
+{
+ /// <summary>
+ /// Represents a parameter for a traversal predicate (ie: P.gt())
+ /// </summary>
+ internal class PParameter : ITokenParameter, IEquatable<PParameter>
+ {
+ private IDictionary<string, object> _contextParameterValues;
+ public IList<Token> Tokens { get; }
+
+ public PParameter(IList<Token> tokens)
+ {
+ Tokens = tokens;
+ }
+
+ public bool Equals(PParameter other)
+ {
+ return Tokens.SequenceEqual(other.Tokens);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != GetType()) return false;
+ return Equals((PParameter) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return Tokens != null ? Tokens.GetHashCode() : 0;
+ }
+
+ public object GetValue()
+ {
+ var type = typeof(P);
+ object instance = null;
+ for (var i = 1; i < Tokens.Count; i++)
+ {
+ var token = Tokens[i];
+ token.SetContextParameterValues(_contextParameterValues);
+ var method = type.GetMethod(TraversalParser.GetCsharpName(token.Name),
+ BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);
+ if (method == null)
+ {
+ throw new InvalidOperationException($"Predicate (P) method '{token}' not found for testing");
+ }
+
+ var parameters = method.IsStatic
+ ? new object[] {token.Parameters.Select(p => p.GetValue()).ToArray()}
+ : token.Parameters.Select(p => p.GetValue()).ToArray();
+ instance = method.Invoke(instance, parameters);
+ }
+ return instance;
+ }
+
+ public Type GetParameterType()
+ {
+ return typeof(P);
+ }
+
+ public void SetContextParameterValues(IDictionary<string, object> parameterValues)
+ {
+ _contextParameterValues = parameterValues;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs
index 94a8c99..4e2bfff 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs
@@ -55,7 +55,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
new[] {new Token("__"), new Token("in", new StringParameter("knows"))}, "__.in(\"knows\")")})}),
Tuple.Create("g.V().has(\"age\",P.gt(27))",
new[] {new Token("has", new ITokenParameter[] { new StringParameter("age"),
- new TraversalPredicateParameter(
+ new PParameter(
new[] { new Token("P"), new Token("gt", LiteralParameter.Create(27)) }) })}),
Tuple.Create("g.V().count(Scope.local)",
new[] { new Token("count", new TraversalEnumParameter("Scope.local"))}),
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/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 118fcea..11145da 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
@@ -406,7 +406,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
}
if (text.Substring(i, 2).StartsWith("P."))
{
- return new TraversalPredicateParameter(ParseTokens(text, ref i));
+ return new PParameter(ParseTokens(text, ref i));
}
var parameterText = text.Substring(i, text.IndexOf(')', i) - i);
var separatorIndex = parameterText.IndexOf(',');
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalPredicateParameter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalPredicateParameter.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalPredicateParameter.cs
deleted file mode 100644
index 57262c1..0000000
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalPredicateParameter.cs
+++ /dev/null
@@ -1,93 +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;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using Gremlin.Net.Process.Traversal;
-
-namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
-{
- /// <summary>
- /// Represents a parameter for a traversal predicate (ie: P.gt())
- /// </summary>
- internal class TraversalPredicateParameter : ITokenParameter, IEquatable<TraversalPredicateParameter>
- {
- private IDictionary<string, object> _contextParameterValues;
- public IList<Token> Tokens { get; }
-
- public TraversalPredicateParameter(IList<Token> tokens)
- {
- Tokens = tokens;
- }
-
- public bool Equals(TraversalPredicateParameter other)
- {
- return Tokens.SequenceEqual(other.Tokens);
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != GetType()) return false;
- return Equals((TraversalPredicateParameter) obj);
- }
-
- public override int GetHashCode()
- {
- return Tokens != null ? Tokens.GetHashCode() : 0;
- }
-
- public object GetValue()
- {
- var type = typeof(P);
- object instance = null;
- for (var i = 1; i < Tokens.Count; i++)
- {
- var token = Tokens[i];
- token.SetContextParameterValues(_contextParameterValues);
- var method = type.GetMethod(TraversalParser.GetCsharpName(token.Name),
- BindingFlags.Static | BindingFlags.Public);
- if (method == null)
- {
- throw new InvalidOperationException($"Predicate (P) method '{token}' not found for testing");
- }
- instance = method.Invoke(instance,
- new object[] {token.Parameters.Select(p => p.GetValue()).ToArray()});
- }
- return instance;
- }
-
- public Type GetParameterType()
- {
- return typeof(TraversalPredicate);
- }
-
- public void SetContextParameterValues(IDictionary<string, object> parameterValues)
- {
- _contextParameterValues = parameterValues;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
index 8ed7a3d..568b970 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
@@ -118,7 +118,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
bytecode.AddSource("withSideEffect", "a", new List<string> {"josh", "peter"});
bytecode.AddStep("V", 1);
bytecode.AddStep("values", "name");
- bytecode.AddStep("where", new TraversalPredicate("within", "a"));
+ bytecode.AddStep("where", new P("within", "a"));
var graphsonWriter = CreateGraphSONWriter();
var graphSON = graphsonWriter.WriteObject(bytecode);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/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 3d02533..3e2d307 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
@@ -222,7 +222,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
public void ShouldSerializePredicateWithTwoValues()
{
var writer = CreateStandardGraphSONWriter();
- var predicate = new TraversalPredicate("within", new List<int> {1, 2});
+ var predicate = new P("within", new List<int> {1, 2});
var serializedPredicate = writer.WriteObject(predicate);
@@ -235,7 +235,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
public void ShouldSerializePredicateWithSingleValue()
{
var writer = CreateStandardGraphSONWriter();
- var predicate = new TraversalPredicate("lt", 5);
+ var predicate = new P("lt", 5);
var serializedPredicate = writer.WriteObject(predicate);
[08/10] 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/9bd4d7fe
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/9bd4d7fe
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/9bd4d7fe
Branch: refs/heads/master
Commit: 9bd4d7fedf943f5f09d5e5a0f77e27efbc559e2e
Parents: 2d493fb 5cf1cba
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Tue Mar 13 23:50:48 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Tue Mar 13 23:50:48 2018 +0100
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../upgrade/release-3.2.x-incubating.asciidoc | 12 +++
gremlin-dotnet/glv/P.template | 62 ++++++++++-
gremlin-dotnet/glv/generate.groovy | 2 +-
.../Process/Traversal/GraphTraversal.cs | 20 ++--
.../src/Gremlin.Net/Process/Traversal/P.cs | 106 ++++++++++++++-----
.../Process/Traversal/TraversalPredicate.cs | 85 ---------------
.../src/Gremlin.Net/Process/Traversal/__.cs | 20 ++--
.../Structure/IO/GraphSON/GraphSONWriter.cs | 2 +-
.../Structure/IO/GraphSON/PSerializer.cs | 45 ++++++++
.../IO/GraphSON/TraversalPredicateSerializer.cs | 45 --------
.../Gherkin/GherkinTestRunner.cs | 18 +---
.../Gherkin/IgnoreException.cs | 5 -
.../Gherkin/TraversalEvaluation/PParameter.cs | 97 +++++++++++++++++
.../TraversalEvaluationTests.cs | 2 +-
.../TraversalEvaluation/TraversalParser.cs | 2 +-
.../TraversalPredicateParameter.cs | 93 ----------------
.../GraphSON/BytecodeGraphSONSerializerTests.cs | 2 +-
.../IO/GraphSON/GraphSONWriterTests.cs | 4 +-
19 files changed, 323 insertions(+), 300 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/CHANGELOG.asciidoc
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
----------------------------------------------------------------------
diff --cc gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
index da455a8,fd226bf..56984d9
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
@@@ -43,13 -43,6 +43,9 @@@ namespace Gremlin.Net.IntegrationTest.G
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.PNotCreatedCorrectlyByGherkinRunner:
- reasonSuffix =
- " because the Gherkin runner can't call methods in TraversalPredicate class (TINKERPOP-1919)";
- break;
case IgnoreReason.PWithinWrapsArgumentsInArray:
reasonSuffix = " because P.Within() arguments are incorrectly wrapped in an array (TINKERPOP-1920)";
break;
@@@ -63,17 -56,7 +59,16 @@@
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,
+
- PNotCreatedCorrectlyByGherkinRunner,
PWithinWrapsArgumentsInArray,
PNotDeserializationProblem
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
----------------------------------------------------------------------
diff --cc gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
index ab7be13,568b970..9b39391
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
@@@ -125,15 -111,15 +125,15 @@@ namespace Gremlin.Net.UnitTest.Structur
Assert.Equal(expectedGraphSon, graphSON);
}
- [Fact]
- public void ShouldSerializeBytecodeWithSourcesStep()
+ [Theory, MemberData(nameof(Versions))]
+ public void ShouldSerializeBytecodeWithSourcesStep(int version)
{
var bytecode = new Bytecode();
- bytecode.AddSource("withSideEffect", "a", new List<string> {"josh", "peter"});
+ bytecode.AddSource("withSideEffect", "a", "josh");
bytecode.AddStep("V", 1);
bytecode.AddStep("values", "name");
- bytecode.AddStep("where", new TraversalPredicate("within", "a"));
+ bytecode.AddStep("where", new P("within", "a"));
- var graphsonWriter = CreateGraphSONWriter();
+ var graphsonWriter = CreateGraphSONWriter(version);
var graphSON = graphsonWriter.WriteObject(bytecode);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bd4d7fe/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 beb514e,3e2d307..0898c1c
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
@@@ -239,50 -218,11 +239,50 @@@ namespace Gremlin.Net.UnitTest.Structur
Assert.Equal(expectedGraphSON, serializedGraphSON);
}
- [Fact]
- public void ShouldSerializePredicateWithTwoValues()
+ [Theory, MemberData(nameof(VersionsSupportingCollections))]
+ public void ShouldSerializeGList(int version)
+ {
+ var writer = CreateGraphSONWriter(version);
+ var list = new List<object> {5, 6};
+
+ var serializedGraphSON = writer.WriteObject(list);
+
+ var expectedGraphSON = "{\"@type\":\"g:List\",\"@value\":[{\"@type\":\"g:Int32\",\"@value\":5}," +
+ "{\"@type\":\"g:Int32\",\"@value\":6}]}";
+ Assert.Equal(expectedGraphSON, serializedGraphSON);
+ }
+
+ [Theory, MemberData(nameof(VersionsSupportingCollections))]
+ public void ShouldSerializeGSet(int version)
+ {
+ var writer = CreateGraphSONWriter(version);
+ ISet<object> set = new HashSet<object> {600L, 700L};
+
+ var serializedGraphSON = writer.WriteObject(set);
+
+ var expectedGraphSON = "{\"@type\":\"g:Set\",\"@value\":[{\"@type\":\"g:Int64\",\"@value\":600}," +
+ "{\"@type\":\"g:Int64\",\"@value\":700}]}";
+ Assert.Equal(expectedGraphSON, serializedGraphSON);
+ }
+
+ [Theory, MemberData(nameof(VersionsSupportingCollections))]
+ public void ShouldSerializeGMap(int version)
+ {
+ var writer = CreateGraphSONWriter(version);
+ IDictionary<object, object> map = new Dictionary<object, object> { { 1L, "a"}, { 200L, "b"}};
+
+ var serializedGraphSON = writer.WriteObject(map);
+
+ var expectedGraphSON = "{\"@type\":\"g:Map\",\"@value\":[{\"@type\":\"g:Int64\",\"@value\":1},\"a\"," +
+ "{\"@type\":\"g:Int64\",\"@value\":200},\"b\"]}";
+ Assert.Equal(expectedGraphSON, serializedGraphSON);
+ }
+
+ [Theory, MemberData(nameof(Versions))]
+ public void ShouldSerializePredicateWithTwoValues(int version)
{
- var writer = CreateStandardGraphSONWriter();
+ var writer = CreateGraphSONWriter(version);
- var predicate = new TraversalPredicate("within", new List<int> {1, 2});
+ var predicate = new P("within", new List<int> {1, 2});
var serializedPredicate = writer.WriteObject(predicate);
@@@ -291,11 -231,11 +291,11 @@@
Assert.Equal(expectedGraphSON, serializedPredicate);
}
- [Fact]
- public void ShouldSerializePredicateWithSingleValue()
+ [Theory, MemberData(nameof(Versions))]
+ public void ShouldSerializePredicateWithSingleValue(int version)
{
- var writer = CreateStandardGraphSONWriter();
+ var writer = CreateGraphSONWriter(version);
- var predicate = new TraversalPredicate("lt", 5);
+ var predicate = new P("lt", 5);
var serializedPredicate = writer.WriteObject(predicate);
[10/10] 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/3e00a640
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3e00a640
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3e00a640
Branch: refs/heads/master
Commit: 3e00a64026eb865d90988beddb20b9103a8e83aa
Parents: 5ae66ed 9bd4d7f
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Tue Mar 13 23:51:28 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Tue Mar 13 23:51:28 2018 +0100
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../upgrade/release-3.2.x-incubating.asciidoc | 12 +++
gremlin-dotnet/glv/P.template | 62 ++++++++++-
gremlin-dotnet/glv/generate.groovy | 2 +-
.../Process/Traversal/GraphTraversal.cs | 20 ++--
.../src/Gremlin.Net/Process/Traversal/P.cs | 106 ++++++++++++++-----
.../Process/Traversal/TraversalPredicate.cs | 85 ---------------
.../src/Gremlin.Net/Process/Traversal/__.cs | 20 ++--
.../Structure/IO/GraphSON/GraphSONWriter.cs | 2 +-
.../Structure/IO/GraphSON/PSerializer.cs | 45 ++++++++
.../IO/GraphSON/TraversalPredicateSerializer.cs | 45 --------
.../Gherkin/GherkinTestRunner.cs | 18 +---
.../Gherkin/IgnoreException.cs | 5 -
.../Gherkin/TraversalEvaluation/PParameter.cs | 97 +++++++++++++++++
.../TraversalEvaluationTests.cs | 2 +-
.../TraversalEvaluation/TraversalParser.cs | 2 +-
.../TraversalPredicateParameter.cs | 93 ----------------
.../GraphSON/BytecodeGraphSONSerializerTests.cs | 2 +-
.../IO/GraphSON/GraphSONWriterTests.cs | 4 +-
19 files changed, 323 insertions(+), 300 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3e00a640/CHANGELOG.asciidoc
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3e00a640/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
----------------------------------------------------------------------
[07/10] tinkerpop git commit: TINKERPOP-1919 Add note about merged P
classes to upgrade docs
Posted by fl...@apache.org.
TINKERPOP-1919 Add note about merged P classes to upgrade docs
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/5cf1cba5
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/5cf1cba5
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/5cf1cba5
Branch: refs/heads/tp33
Commit: 5cf1cba59cfb6818b371b1d605dac3b8d190157a
Parents: 359b08c
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Tue Mar 13 23:39:21 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Tue Mar 13 23:39:21 2018 +0100
----------------------------------------------------------------------
docs/src/upgrade/release-3.2.x-incubating.asciidoc | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5cf1cba5/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 0cb8ddc..0848843 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -53,6 +53,18 @@ However, usage of these tokens themselves shouldn't change at all (e.g. `T.Id` i
See: link:https://issues.apache.org/jira/browse/TINKERPOP-1901[TINKERPOP-1901]
+==== Gremlin.Net: Traversal Predicate Classes Merged
+
+Gremlin.Net used two classes for traversal predicates: `P` and `TraversalPredicate`. Steps that worked with traversal
+predicates expected objects of type `TraversalPredicate`, but they were constructed from the `P` class
+(e.g. `P.Gt(1)` returned a `TraversalPredicate`). Merging these two classes into the `P` class should avoid unnecessary
+confusion. Most users should not notice this change as predicates can still be constructed exactly as before, e.g.,
+`P.Gt(1).And(P.Lt(3))` still works without any modifications.
+Only users that implemented their own predicates and used `TraversalPredicate` as the base class need to change their
+implementation to now use `P` as the new base class.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1919[TINKERPOP-1919]
+
=== Upgrading for Providers
==== Graph System Providers
[04/10] tinkerpop git commit: Merge branch 'tp33' of
https://git-wip-us.apache.org/repos/asf/tinkerpop into tp33
Posted by fl...@apache.org.
Merge branch 'tp33' of https://git-wip-us.apache.org/repos/asf/tinkerpop into tp33
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/2d493fb3
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/2d493fb3
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/2d493fb3
Branch: refs/heads/master
Commit: 2d493fb3cfb6dd89f84327677cd949cd8969c782
Parents: bccff98 c22ab90
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Tue Mar 13 14:56:27 2018 -0700
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Tue Mar 13 14:56:27 2018 -0700
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
docs/src/reference/gremlin-variants.asciidoc | 2 +-
.../upgrade/release-3.2.x-incubating.asciidoc | 11 +++++
gremlin-dotnet/glv/Enum.template | 9 +++-
gremlin-dotnet/glv/generate.groovy | 41 +++++++--------
.../Gremlin.Net/Process/Traversal/Barrier.cs | 9 +++-
.../Process/Traversal/Cardinality.cs | 13 +++--
.../src/Gremlin.Net/Process/Traversal/Column.cs | 11 +++--
.../Gremlin.Net/Process/Traversal/Direction.cs | 13 +++--
.../Process/Traversal/EnumWrapper.cs | 52 ++++++++++++++++++++
.../Process/Traversal/GraphSONVersion.cs | 13 +++--
.../Process/Traversal/GraphTraversal.cs | 43 +++++++++-------
.../Process/Traversal/GraphTraversalSource.cs | 14 ++++--
.../Process/Traversal/GryoVersion.cs | 11 +++--
.../Process/Traversal/IBiFunction.cs | 33 +++++++++++++
.../Process/Traversal/IBinaryOperator.cs | 34 +++++++++++++
.../Process/Traversal/IComparator.cs | 32 ++++++++++++
.../Gremlin.Net/Process/Traversal/IConsumer.cs | 33 +++++++++++++
.../Gremlin.Net/Process/Traversal/IFunction.cs | 32 ++++++++++++
.../Gremlin.Net/Process/Traversal/IPredicate.cs | 32 ++++++++++++
.../Gremlin.Net/Process/Traversal/Operator.cs | 29 ++++++-----
.../src/Gremlin.Net/Process/Traversal/Order.cs | 13 +++--
.../src/Gremlin.Net/Process/Traversal/Pick.cs | 11 +++--
.../src/Gremlin.Net/Process/Traversal/Pop.cs | 15 ++++--
.../src/Gremlin.Net/Process/Traversal/Scope.cs | 11 +++--
.../src/Gremlin.Net/Process/Traversal/T.cs | 15 ++++--
.../Process/Traversal/TraversalPredicate.cs | 2 +-
.../src/Gremlin.Net/Process/Traversal/__.cs | 26 +++++-----
.../Structure/IO/GraphSON/EnumSerializer.cs | 5 +-
.../Structure/IO/GraphSON/GraphSONWriter.cs | 2 +-
.../Gherkin/GherkinTestRunner.cs | 1 +
.../TraversalEnumParameter.cs | 5 +-
32 files changed, 455 insertions(+), 119 deletions(-)
----------------------------------------------------------------------
[06/10] tinkerpop git commit: TINKERPOP-1919 Add note about merged P
classes to upgrade docs
Posted by fl...@apache.org.
TINKERPOP-1919 Add note about merged P classes to upgrade docs
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/5cf1cba5
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/5cf1cba5
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/5cf1cba5
Branch: refs/heads/master
Commit: 5cf1cba59cfb6818b371b1d605dac3b8d190157a
Parents: 359b08c
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Tue Mar 13 23:39:21 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Tue Mar 13 23:39:21 2018 +0100
----------------------------------------------------------------------
docs/src/upgrade/release-3.2.x-incubating.asciidoc | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5cf1cba5/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 0cb8ddc..0848843 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -53,6 +53,18 @@ However, usage of these tokens themselves shouldn't change at all (e.g. `T.Id` i
See: link:https://issues.apache.org/jira/browse/TINKERPOP-1901[TINKERPOP-1901]
+==== Gremlin.Net: Traversal Predicate Classes Merged
+
+Gremlin.Net used two classes for traversal predicates: `P` and `TraversalPredicate`. Steps that worked with traversal
+predicates expected objects of type `TraversalPredicate`, but they were constructed from the `P` class
+(e.g. `P.Gt(1)` returned a `TraversalPredicate`). Merging these two classes into the `P` class should avoid unnecessary
+confusion. Most users should not notice this change as predicates can still be constructed exactly as before, e.g.,
+`P.Gt(1).And(P.Lt(3))` still works without any modifications.
+Only users that implemented their own predicates and used `TraversalPredicate` as the base class need to change their
+implementation to now use `P` as the new base class.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1919[TINKERPOP-1919]
+
=== Upgrading for Providers
==== Graph System Providers