tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ok...@apache.org
Subject tinkerpop git commit: Add a slight optimization to ScopingStrategy that will not compute step labels if no Scoping steps are defined. Also added JavaDoc and comments accordingly.
Date Mon, 06 Mar 2017 15:07:43 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1642 be9314d78 -> d5038631b


Add a slight optimization to ScopingStrategy that will not compute step labels if no Scoping
steps are defined. Also added JavaDoc and comments accordingly.


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

Branch: refs/heads/TINKERPOP-1642
Commit: d5038631bf204ec54922e6fcc3a50ea96286c592
Parents: be9314d
Author: Marko A. Rodriguez <okrammarko@gmail.com>
Authored: Mon Mar 6 08:07:39 2017 -0700
Committer: Marko A. Rodriguez <okrammarko@gmail.com>
Committed: Mon Mar 6 08:07:39 2017 -0700

----------------------------------------------------------------------
 .../gremlin/process/traversal/step/Scoping.java         |  5 +++++
 .../strategy/finalization/ScopingStrategy.java          | 12 ++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d5038631/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java
index 68655e4..fae52d7 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java
@@ -69,6 +69,11 @@ public interface Scoping {
         return null;
     }
 
+    /**
+     * Get the labels that this scoping step will access during the traversal
+     *
+     * @return the accessed labels of the scoping step
+     */
     public Set<String> getScopeKeys();
 
     /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d5038631/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/ScopingStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/ScopingStrategy.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/ScopingStrategy.java
index ce66da4..073f45e 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/ScopingStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/ScopingStrategy.java
@@ -19,6 +19,7 @@
 
 package org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization;
 
+import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.step.Scoping;
@@ -29,6 +30,10 @@ import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
 import java.util.Set;
 
 /**
+ * ScopingStrategy will analyze the traversal for step labels (e.g. as()) and provide {@link
Scoping} steps that information.
+ * This enables Scoping steps to avoid  having to generate step label data at {@link Step#getRequirements()}
and thus,
+ * may significantly reduce compilation times.
+ *
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
 public final class ScopingStrategy extends AbstractTraversalStrategy<TraversalStrategy.FinalizationStrategy>
implements TraversalStrategy.FinalizationStrategy {
@@ -41,11 +46,14 @@ public final class ScopingStrategy extends AbstractTraversalStrategy<TraversalSt
 
     @Override
     public void apply(final Traversal.Admin<?, ?> traversal) {
-        // only operate on the root traversal and apply global step labels recursively
-        if (!(traversal.getParent() instanceof EmptyStep))
+        // only operate on the root traversal and only if it contains scoping steps
+        if (!(traversal.getParent() instanceof EmptyStep) ||
+                !TraversalHelper.hasStepOfAssignableClassRecursively(Scoping.class, traversal))
             return;
 
+        // get the labels associated with the traveral
         final Set<String> labels = TraversalHelper.getLabels(traversal);
+        // tell all scoping steps what those labels are
         for (final Scoping scoping : TraversalHelper.getStepsOfAssignableClassRecursively(Scoping.class,
traversal)) {
             scoping.setPathLabels(labels);
         }


Mime
View raw message