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/04 14:02:28 UTC

[1/3] tinkerpop git commit: fixed a bug in LambdaRestrictionStrategy where named @ steps were considered lambda. Came up with a different way to check lambdas in .toString(). Works for Groovy, Java, and Python.

Repository: tinkerpop
Updated Branches:
  refs/heads/master e21540169 -> 9aaf49e3e


fixed a bug in LambdaRestrictionStrategy where named @ steps were considered lambda. Came up with a different way to check lambdas in .toString(). Works for Groovy, Java, and Python.


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

Branch: refs/heads/master
Commit: beae74c43505d1f7732f92a500dc58fc4b142af1
Parents: 1cd042b
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Mon Oct 2 15:23:33 2017 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Mon Oct 2 15:23:33 2017 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                    |  1 +
 .../verification/LambdaRestrictionStrategy.java       | 14 +++++++-------
 .../verification/LambdaRestrictionStrategyTest.java   |  6 ++++++
 3 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/beae74c4/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index e48dfb5..f1ad017 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -23,6 +23,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 [[release-3-2-7]]
 === TinkerPop 3.2.7 (Release Date: NOT OFFICIALLY RELEASED YET)
 
+* Fixed a bug in `LambdaRestrictionStrategy` where named steps with `@` were being considered lambdas.
 * `ReferenceVertex` was missing its `label()` string. `ReferenceElement` now supports all label handling.
 * Added `GraphHelper.cloneElements(Graph original, Graph clone)` to the `gremlin-test` module to quickly clone a graph.
 * Bump to GMavenPlus 1.6.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/beae74c4/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 33b29ff..134a852 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
@@ -61,19 +61,19 @@ public final class LambdaRestrictionStrategy extends AbstractTraversalStrategy<T
                 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()) {
-                    final String comparatorString = comparator.toString();
-                    if (comparatorString.contains("$") || comparatorString.contains("@"))
+                    if (hasLambda(comparator.toString()))
                         throw new VerificationException("The provided step contains a lambda comparator: " + step, traversal);
                 }
             }
-            if (step instanceof SackValueStep) {
-                final String sackString = ((SackValueStep) step).getSackFunction().toString();
-                if (sackString.contains("$") || sackString.contains("@"))
-                    throw new VerificationException("The provided step contains a lambda bi-function: " + 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/beae74c4/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 9bb251c..1804ddf 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
@@ -24,8 +24,10 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.ProfileStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies;
 import org.apache.tinkerpop.gremlin.structure.Column;
+import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.T;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -34,6 +36,7 @@ import org.junit.runners.Parameterized;
 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.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -63,6 +66,8 @@ public class LambdaRestrictionStrategyTest {
                 //
                 {"sack(sum).by('age')", __.sack(sum).by("age"), true},
                 {"sack{a,b -> a+b}.by('age')", __.sack((a, b) -> (int) a + (int) b).by("age"), false},
+                //
+                {"order().by(outE('rating').values('stars').mean()).profile()", __.order().by(outE("ratings").values("stars").mean()).profile(), true}
         });
     }
 
@@ -78,6 +83,7 @@ public class LambdaRestrictionStrategyTest {
     @Test
     public void shouldBeVerifiedIllegal() {
         final TraversalStrategies strategies = new DefaultTraversalStrategies();
+        strategies.addStrategies(ProfileStrategy.instance());
         strategies.addStrategies(LambdaRestrictionStrategy.instance());
         traversal.asAdmin().setStrategies(strategies);
         if (allow) {


[2/3] tinkerpop git commit: Merge branch 'TINKERPOP-1795' into tp32

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


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

Branch: refs/heads/master
Commit: a278edd85cfff9028004cc37c95ecac1219bb954
Parents: b3e301e beae74c
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Oct 4 07:29:17 2017 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Oct 4 07:29:17 2017 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                    |  1 +
 .../verification/LambdaRestrictionStrategy.java       | 14 +++++++-------
 .../verification/LambdaRestrictionStrategyTest.java   |  6 ++++++
 3 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a278edd8/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --cc CHANGELOG.asciidoc
index 5ea3034,f1ad017..ec54cc2
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@@ -23,10 -23,8 +23,11 @@@ image::https://raw.githubusercontent.co
  [[release-3-2-7]]
  === 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.
  * `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.
  * Added `GraphHelper.cloneElements(Graph original, Graph clone)` to the `gremlin-test` module to quickly clone a graph.
  * Bump to GMavenPlus 1.6.
  * Added better error message for illegal use of `repeat()`-step.


[3/3] 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/9aaf49e3
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/9aaf49e3
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/9aaf49e3

Branch: refs/heads/master
Commit: 9aaf49e3eeefd1d3373765f6f0e6fe0005ea6b97
Parents: e215401 a278edd
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Oct 4 07:58:59 2017 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Oct 4 07:58:59 2017 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                    |  1 +
 .../verification/LambdaRestrictionStrategy.java       | 14 +++++++-------
 .../verification/LambdaRestrictionStrategyTest.java   |  6 ++++++
 3 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


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