You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2017/10/18 21:52:10 UTC

[1/4] tinkerpop git commit: We have had so many problems with LambdaRestrictionStragegy because it is difficult to know what is a true lambda. I have now simply hardcoded the lambda determination as a String analysis of the lambda object for Java, Groovy

Repository: tinkerpop
Updated Branches:
  refs/heads/master d669d44b1 -> 66a7856bd


We have had so many problems with LambdaRestrictionStragegy because it is difficult to know what is a true lambda. I have now simply hardcoded the lambda determination as a String analysis of the lambda object for Java, Groovy, and Python. As we add more GLVs, we can add more string mappers. Any other solution thus far has either been too lenient or too restrictive. Added more test cases to LambdaRestrictionStrategyTest as well.


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

Branch: refs/heads/master
Commit: 46ac055f747390eefb58ac7ab7ef4c9fc178aaec
Parents: a278edd
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Mon Oct 9 11:20:26 2017 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Mon Oct 9 11:20:26 2017 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  2 +-
 .../step/sideEffect/SackValueStep.java          |  5 +++--
 .../verification/LambdaRestrictionStrategy.java | 20 +-------------------
 .../gremlin/structure/util/StringFactory.java   |  8 +++++++-
 .../LambdaRestrictionStrategyTest.java          |  9 ++++++---
 5 files changed, 18 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/46ac055f/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index ec54cc2..717ad44 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -24,7 +24,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 === TinkerPop 3.2.7 (Release Date: NOT OFFICIALLY RELEASED YET)
 
 * Truncate the script in error logs and error return messages for "Method code too large" errors in Gremlin Server.
-* Fixed a bug in `LambdaRestrictionStrategy` where named steps with `@` were being considered lambdas.
+* Fixed a bug in `LambdaRestrictionStrategy` where it was too eager to consider a step as being a lambda step.
 * `ReferenceVertex` was missing its `label()` string. `ReferenceElement` now supports all label handling.
 * Fixed a bug where bytecode containing lambdas would randomly select a traversal source from bindings.
 * Deprecated `GremlinScriptEngine.eval()` methods and replaced them with new overloads that include the specific `TraversalSource` to bind to.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/46ac055f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SackValueStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SackValueStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SackValueStep.java
index 3281fa7..650140e 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SackValueStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SackValueStep.java
@@ -21,6 +21,7 @@ package org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.step.ByModulating;
+import org.apache.tinkerpop.gremlin.process.traversal.step.LambdaHolder;
 import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalUtil;
@@ -34,7 +35,7 @@ import java.util.function.BiFunction;
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
-public final class SackValueStep<S, A, B> extends SideEffectStep<S> implements TraversalParent, ByModulating {
+public final class SackValueStep<S, A, B> extends SideEffectStep<S> implements TraversalParent, ByModulating, LambdaHolder {
 
     private Traversal.Admin<S, B> sackTraversal = null;
 
@@ -70,7 +71,7 @@ public final class SackValueStep<S, A, B> extends SideEffectStep<S> implements T
         return super.hashCode() ^ this.sackFunction.hashCode() ^ ((null == this.sackTraversal) ? "null".hashCode() : this.sackTraversal.hashCode());
     }
 
-    public BiFunction<A,B,A> getSackFunction() {
+    public BiFunction<A, B, A> getSackFunction() {
         return this.sackFunction;
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/46ac055f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategy.java
index 134a852..642d17a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategy.java
@@ -23,11 +23,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.step.ComparatorHolder;
 import org.apache.tinkerpop.gremlin.process.traversal.step.LambdaHolder;
-import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SackValueStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
-import org.javatuples.Pair;
-
-import java.util.Comparator;
 
 /**
  * {@code LambdaRestrictionStrategy} does not allow lambdas to be used in a {@link Traversal}. The contents of a lambda
@@ -54,26 +50,12 @@ public final class LambdaRestrictionStrategy extends AbstractTraversalStrategy<T
 
     @Override
     public void apply(final Traversal.Admin<?, ?> traversal) {
-        if (traversal instanceof LambdaHolder)
-            throw new VerificationException("The provided traversal is a lambda traversal: ", traversal);
         for (final Step<?, ?> step : traversal.getSteps()) {
-            if (step instanceof LambdaHolder)
+            if ((step instanceof LambdaHolder || step instanceof ComparatorHolder) && step.toString().contains("lambda"))
                 throw new VerificationException("The provided traversal contains a lambda step: " + step, traversal);
-            if (step instanceof ComparatorHolder) {
-                for (final Pair<Traversal.Admin<Object, Comparable>, Comparator<Comparable>> comparator : ((ComparatorHolder<Object, Comparable>) step).getComparators()) {
-                    if (hasLambda(comparator.toString()))
-                        throw new VerificationException("The provided step contains a lambda comparator: " + step, traversal);
-                }
-            }
-            if (step instanceof SackValueStep && hasLambda(((SackValueStep) step).getSackFunction().toString()))
-                throw new VerificationException("The provided step contains a lambda bi-function: " + step, traversal);
         }
     }
 
-    private final boolean hasLambda(final String objectString) {
-        return objectString.contains("$") || objectString.toLowerCase().contains("lambda");
-    }
-
     public static LambdaRestrictionStrategy instance() {
         return INSTANCE;
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/46ac055f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/StringFactory.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/StringFactory.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/StringFactory.java
index bcead2d..6d2b680 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/StringFactory.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/StringFactory.java
@@ -224,7 +224,7 @@ public final class StringFactory {
                 })
                 .map(o -> {
                     final String string = o.toString();
-                    return string.contains("$") ? "lambda" : string;
+                    return hasLambda(string) ? "lambda" : string;
                 }).collect(Collectors.toList());
         if (!strings.isEmpty()) {
             builder.append('(');
@@ -236,6 +236,12 @@ public final class StringFactory {
         return builder.toString();
     }
 
+    private static boolean hasLambda(final String objectString) {
+        return objectString.contains("$Lambda$") || // JAVA (org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraphPlayTest$$Lambda$1/1711574013@61a52fb)
+                objectString.contains("$_run_closure") || // GROOVY (groovysh_evaluate$_run_closure1@db44aa2)
+                objectString.contains("<lambda>");  // PYTHON (<function <lambda> at 0x10dfaec80>)
+    }
+
     public static String traversalString(final Traversal.Admin<?, ?> traversal) {
         return traversal.getSteps().toString();
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/46ac055f/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategyTest.java
index 1804ddf..767211c 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategyTest.java
@@ -37,6 +37,7 @@ import java.util.Arrays;
 
 import static org.apache.tinkerpop.gremlin.process.traversal.Operator.sum;
 import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.outE;
+import static org.apache.tinkerpop.gremlin.structure.Column.values;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -54,14 +55,16 @@ public class LambdaRestrictionStrategyTest {
                 {"sideEffect(x -> {int i = 1+1;})", __.sideEffect(x -> {
                     int i = 1 + 1;
                 }), false},
+                {"select('a').by(values)", __.select("a").by(values), true},
                 {"select('a','b').by(Object::toString)", __.select("a", "b").by(Object::toString), false},
                 {"order().by((a,b)->a.compareTo(b))", __.order().by((a, b) -> ((Integer) a).compareTo((Integer) b)), false},
                 {"order(local).by((a,b)->a.compareTo(b))", __.order(Scope.local).by((a, b) -> ((Integer) a).compareTo((Integer) b)), false},
                 {"__.choose(v->v.toString().equals(\"marko\"),__.out(),__.in())", __.choose(v -> v.toString().equals("marko"), __.out(), __.in()), false},
-                {"order(local).by(values,decr)", __.order(Scope.local).by(Column.values, (a, b) -> ((Double) a).compareTo((Double) b)), false},
-                //
-                {"order(local).by(values,decr)", __.order(Scope.local).by(Column.values, Order.decr), true},
                 {"order().by(label,decr)", __.order().by(T.label, Order.decr), true},
+                {"order(local).by(values)", __.order(Scope.local).by(values), true},
+                {"order(local).by(values,decr)", __.order(Scope.local).by(values,Order.decr), true},
+                {"order(local).by(values,(a,b) -> a.compareTo(b))", __.order(Scope.local).by(values, (a, b) -> ((Double) a).compareTo((Double) b)), false},
+                //
                 {"groupCount().by(label)", __.groupCount().by(T.label), true},
                 //
                 {"sack(sum).by('age')", __.sack(sum).by("age"), true},


[2/4] tinkerpop git commit: Corrected hard-coded test suite number - CTR

Posted by ok...@apache.org.
Corrected hard-coded test suite number - CTR


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

Branch: refs/heads/master
Commit: 463767774c97a55f9f0c5bcee1bfc62da20dc846
Parents: c13bf94
Author: Robert Dale <ro...@gmail.com>
Authored: Tue Oct 17 14:12:05 2017 -0400
Committer: Robert Dale <ro...@gmail.com>
Committed: Tue Oct 17 14:12:05 2017 -0400

----------------------------------------------------------------------
 .../gremlin/console/jsr223/UtilitiesGremlinPluginScript.groovy     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/46376777/gremlin-console/src/main/resources/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginScript.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/resources/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginScript.groovy b/gremlin-console/src/main/resources/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginScript.groovy
index bfa6690..1c4022a 100644
--- a/gremlin-console/src/main/resources/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginScript.groovy
+++ b/gremlin-console/src/main/resources/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginScript.groovy
@@ -38,7 +38,7 @@ describeGraph = { Class<? extends org.apache.tinkerpop.gremlin.structure.Graph>
     return "${lf}" +
 "IMPLEMENTATION - ${c.getCanonicalName()} ${lf}" +
 "TINKERPOP TEST SUITE ${lf}" +
-"- Compliant with ($optInCount of 10 suites) ${lf}" +
+"- Compliant with ($optInCount of 11 suites) ${lf}" +
 "$suitesSupported ${lf}" +
 "- Opts out of $optOutCount individual tests ${lf}" +
 "$testsOptedOut ${lf}" +


[4/4] tinkerpop git commit: Merge branch 'tp32'

Posted by ok...@apache.org.
Merge branch 'tp32'


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

Branch: refs/heads/master
Commit: 66a7856bd1bc1829cb0db670886accc428df82d7
Parents: d669d44 19e261c
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Oct 18 15:52:04 2017 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Oct 18 15:52:04 2017 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  2 +-
 .../jsr223/UtilitiesGremlinPluginScript.groovy  |  1 +
 .../step/sideEffect/SackValueStep.java          |  5 +++--
 .../verification/LambdaRestrictionStrategy.java | 20 +-------------------
 .../gremlin/structure/util/StringFactory.java   |  8 +++++++-
 .../LambdaRestrictionStrategyTest.java          |  9 ++++++---
 6 files changed, 19 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/66a7856b/gremlin-console/src/main/resources/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginScript.groovy
----------------------------------------------------------------------
diff --cc gremlin-console/src/main/resources/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginScript.groovy
index f98f285,1c4022a..aa17a5e
--- a/gremlin-console/src/main/resources/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginScript.groovy
+++ b/gremlin-console/src/main/resources/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginScript.groovy
@@@ -38,7 -38,7 +38,8 @@@ describeGraph = { Class<? extends org.a
      return "${lf}" +
  "IMPLEMENTATION - ${c.getCanonicalName()} ${lf}" +
  "TINKERPOP TEST SUITE ${lf}" +
 +"- Compliant with ($optInCount of 4 suites) ${lf}" +
+ "- Compliant with ($optInCount of 11 suites) ${lf}" +
  "$suitesSupported ${lf}" +
  "- Opts out of $optOutCount individual tests ${lf}" +
  "$testsOptedOut ${lf}" +

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/66a7856b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/StringFactory.java
----------------------------------------------------------------------


[3/4] tinkerpop git commit: Merge branch 'TINKERPOP-1797' into tp32

Posted by ok...@apache.org.
Merge branch 'TINKERPOP-1797' into tp32


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

Branch: refs/heads/master
Commit: 19e261c53fa4c95a5e12c49dc572cc280c3cb0ec
Parents: 4637677 46ac055
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Oct 18 13:15:30 2017 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Oct 18 13:15:30 2017 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  2 +-
 .../step/sideEffect/SackValueStep.java          |  5 +++--
 .../verification/LambdaRestrictionStrategy.java | 20 +-------------------
 .../gremlin/structure/util/StringFactory.java   |  8 +++++++-
 .../LambdaRestrictionStrategyTest.java          |  9 ++++++---
 5 files changed, 18 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


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