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 2015/05/07 19:20:06 UTC

incubator-tinkerpop git commit: added ScopingStrategy which automagically detects whether you want select(local) or select(global) based on whether the previous step works with Map or not. Updated MatchStepTest and docs accordingly. Now going to knock ou

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master 141af5aa3 -> 36f4a8711


added ScopingStrategy which automagically detects whether you want select(local) or select(global) based on whether the previous step works with Map or not. Updated MatchStepTest and docs accordingly. Now going to knock out where(global).


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

Branch: refs/heads/master
Commit: 36f4a8711a5d8682bdb4408c02b39a9223bafb6e
Parents: 141af5a
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu May 7 11:20:00 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu May 7 11:20:00 2015 -0600

----------------------------------------------------------------------
 docs/src/the-traversal.asciidoc                 | 20 +++----
 .../process/traversal/TraversalStrategies.java  |  2 +
 .../gremlin/process/traversal/step/Scoping.java | 32 +++++++++++
 .../traversal/step/filter/WhereStep.java        |  9 +++-
 .../traversal/step/map/SelectOneStep.java       | 14 ++++-
 .../process/traversal/step/map/SelectStep.java  | 14 ++++-
 .../traversal/step/map/match/MatchStep.java     | 17 ++++--
 .../strategy/finalization/ScopingStrategy.java  | 57 ++++++++++++++++++++
 .../traversal/step/map/GroovyMatchTest.groovy   | 15 +++---
 .../process/traversal/step/map/MatchTest.java   | 14 ++---
 .../TinkerGraphNoStrategyComputerProvider.java  |  2 +
 .../process/TinkerGraphNoStrategyProvider.java  |  7 ++-
 12 files changed, 167 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/36f4a871/docs/src/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/the-traversal.asciidoc b/docs/src/the-traversal.asciidoc
index a7f6e9d..2b7bde1 100644
--- a/docs/src/the-traversal.asciidoc
+++ b/docs/src/the-traversal.asciidoc
@@ -670,7 +670,7 @@ g.V().match('a',
         __.as('a').out('created').as('b'),
         __.as('b').has('name', 'lop'),
         __.as('b').in('created').as('c'),
-        __.as('c').has('age', 29)).select(local,'a','c').by('name')
+        __.as('c').has('age', 29)).select('a','c').by('name')
 ----
 
 Note that the above can also be more concisely written as below which demonstrates that imperative inner-traversals can be arbitrarily defined.
@@ -679,7 +679,7 @@ Note that the above can also be more concisely written as below which demonstrat
 ----
 g.V().match('a',
         __.as('a').out('created').has('name', 'lop').as('b'),
-        __.as('b').in('created').has('age', 29).as('c')).select(local,'a','c').by('name')
+        __.as('b').in('created').has('age', 29).as('c')).select('a','c').by('name')
 ----
 
 [[grateful-dead]]
@@ -695,7 +695,7 @@ g = graph.traversal(standard())
 g.V().match('a',
         __.as('a').has('name', 'Garcia'),
         __.as('a').in('writtenBy').as('b'),
-        __.as('a').in('sungBy').as('b')).select(local,'b').values('name')
+        __.as('a').in('sungBy').as('b')).select('b').values('name')
 ----
 
 Among the features which differentiate `match()` from SPARQL are:
@@ -706,7 +706,7 @@ g.V().match('a',
         __.as('a').out('created').has('name','lop').as('b'), <1>
         __.as('b').in('created').has('age', 29).as('c'),
         __.as('c').repeat(out()).times(2)). <2>
-          select(local,'c').out('knows').dedup().values('name') <3>
+          select('c').out('knows').dedup().values('name') <3>
 ----
 
 <1> *Patterns of arbitrary complexity*: `match()` is not restricted to triple patterns or property paths.
@@ -720,11 +720,11 @@ To extend point #3, it is possible to support going from imperative, to declarat
 g.V().match('a',
         __.as('a').out('knows').as('b'),
         __.as('b').out('created').has('name','lop')).
-        select(local,'b').out('created').
+        select('b').out('created').
           match('a',
             __.as('a').in('created').as('b'),
             __.as('b').out('knows').as('c')).
-            select(local,'c').values('name')
+            select('c').values('name')
 ----
 
 Like all other steps in Gremlin, `match()` is a function and thus, `match()` within `match()` is a natural consequence of Gremlin's functional foundation (i.e. recursive matching).
@@ -737,8 +737,8 @@ g.V().match('a',
         __.as('b').match('x',
                  __.as('x').out('created').as('y'),
                  __.as('y').has('name','ripple')).
-                 select(local,'y').as('c')).
-        select(local,'a','c').by('name')
+                 select('y').as('c')).
+        select('a','c').by('name')
 ----
 
 WARNING: Currently, `match()` does not operate within a multi-JVM <<graphcomputer,GraphComputer>> OLAP environment. Future work includes a linearization <<traversalstrategy,TraversalStrategy>> for `match()`.
@@ -754,7 +754,7 @@ Match is typically used in conjunction with both `select()` (demonstrated previo
 g.V().match('a',
         __.as('a').out('created').as('b'),
         __.as('b').in('created').as('c')).
-          where('a', neq('c')).select(local,'a','c').by('name')
+          where('a', neq('c')).select('a','c').by('name')
 ----
 
 The `where()`-step can take either a `BiPredicate` (first example below) or a `Traversal` (second example below). Using `MatchWhereStrategy`, `where()`-clauses can be automatically folded into `match()` and thus, subject to `match()`-steps budget-match algorithm.
@@ -765,7 +765,7 @@ traversal = g.V().match('a',
                     __.as('a').out('created').as('b'),
                     __.as('b').in('created').as('c')).
                       where(__.as('a').out('knows').as('c')). <1>
-                      select(local,'a','c').by('name'); null <2>
+                      select('a','c').by('name'); null <2>
 traversal.toString() <3>
 traversal <4> <5>
 traversal.toString() <6>

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/36f4a871/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
index 6697f10..99cfb93 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
@@ -22,6 +22,7 @@ import org.apache.tinkerpop.gremlin.process.computer.util.ShellGraph;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ConjunctionStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.EngineDependentStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.ProfileStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.ScopingStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.*;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ComputerVerificationStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserGeneratorFactory;
@@ -187,6 +188,7 @@ public interface TraversalStrategies extends Serializable, Cloneable {
                     ConjunctionStrategy.instance(),
                     EngineDependentStrategy.instance(),
                     ProfileStrategy.instance(),
+                    ScopingStrategy.instance(),
                     IncidentToAdjacentStrategy.instance(),
                     AdjacentToIncidentStrategy.instance(),
                     OrderGlobalRemovalStrategy.instance(),

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/36f4a871/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
new file mode 100644
index 0000000..4403bba
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java
@@ -0,0 +1,32 @@
+/*
+ *
+ *  * 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.
+ *
+ */
+
+package org.apache.tinkerpop.gremlin.process.traversal.step;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Scope;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface Scoping {
+
+    public Scope getScope();
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/36f4a871/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereStep.java
index 633283a..176389e 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereStep.java
@@ -18,9 +18,11 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal.step.filter;
 
+import org.apache.tinkerpop.gremlin.process.traversal.Scope;
 import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Scoping;
 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.TraversalHelper;
@@ -35,7 +37,7 @@ import java.util.function.BiPredicate;
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
-public final class WhereStep<E> extends FilterStep<Map<String, E>> implements TraversalParent {
+public final class WhereStep<E> extends FilterStep<Map<String, E>> implements TraversalParent, Scoping {
 
     private final String firstKey;
     private final String secondKey;
@@ -130,4 +132,9 @@ public final class WhereStep<E> extends FilterStep<Map<String, E>> implements Tr
     public Set<TraverserRequirement> getRequirements() {
         return this.getSelfAndChildRequirements(TraverserRequirement.OBJECT);
     }
+
+    @Override
+    public Scope getScope() {
+        return Scope.local;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/36f4a871/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectOneStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectOneStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectOneStep.java
index 2480de7..93a9a8f 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectOneStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectOneStep.java
@@ -22,6 +22,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Scope;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.lambda.IdentityTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Scoping;
 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.TraversalHelper;
@@ -35,9 +36,9 @@ import java.util.Set;
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
-public final class SelectOneStep<S, E> extends MapStep<S, E> implements TraversalParent {
+public final class SelectOneStep<S, E> extends MapStep<S, E> implements TraversalParent, Scoping {
 
-    private final Scope scope;
+    private Scope scope;
     private final String selectLabel;
     private Traversal.Admin<Object, Object> selectTraversal = new IdentityTraversal<>();
 
@@ -78,6 +79,15 @@ public final class SelectOneStep<S, E> extends MapStep<S, E> implements Traversa
     public Set<TraverserRequirement> getRequirements() {
         return this.getSelfAndChildRequirements(TraverserRequirement.OBJECT, TraverserRequirement.PATH);
     }
+
+    public void setScope(final Scope scope) {
+        this.scope = scope;
+    }
+
+    @Override
+    public Scope getScope() {
+        return this.scope;
+    }
 }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/36f4a871/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectStep.java
index 0e509fe..45ca08e 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectStep.java
@@ -22,6 +22,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Path;
 import org.apache.tinkerpop.gremlin.process.traversal.Scope;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Scoping;
 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.TraversalHelper;
@@ -37,10 +38,10 @@ import java.util.Set;
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
-public final class SelectStep<S, E> extends MapStep<S, Map<String, E>> implements TraversalParent {
+public final class SelectStep<S, E> extends MapStep<S, Map<String, E>> implements Scoping, TraversalParent {
 
     private TraversalRing<Object, Object> traversalRing = new TraversalRing<>();
-    private final Scope scope;
+    private Scope scope;
     private final List<String> selectLabels;
 
     public SelectStep(final Traversal.Admin traversal, final Scope scope, final String... selectLabels) {
@@ -106,4 +107,13 @@ public final class SelectStep<S, E> extends MapStep<S, Map<String, E>> implement
     public Set<TraverserRequirement> getRequirements() {
         return this.getSelfAndChildRequirements(TraverserRequirement.OBJECT, TraverserRequirement.PATH);
     }
+
+    public void setScope(final Scope scope) {
+        this.scope = scope;
+    }
+
+    @Override
+    public Scope getScope() {
+        return this.scope;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/36f4a871/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/match/MatchStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/match/MatchStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/match/MatchStep.java
index f366069..4e4a169 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/match/MatchStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/match/MatchStep.java
@@ -18,14 +18,16 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal.step.map.match;
 
-import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
+import org.apache.tinkerpop.gremlin.process.traversal.Scope;
 import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Scoping;
 import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.B_O_S_SE_SL_Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
+import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 
@@ -47,7 +49,7 @@ import java.util.function.Function;
 /**
  * @author Joshua Shinavier (http://fortytwo.net)
  */
-public final class MatchStep<S, E> extends AbstractStep<S, Map<String, E>> implements TraversalParent {
+public final class MatchStep<S, E> extends AbstractStep<S, Map<String, E>> implements Scoping, TraversalParent {
 
     static final BiConsumer<String, Object> TRIVIAL_CONSUMER = (s, t) -> {
     };
@@ -181,15 +183,15 @@ public final class MatchStep<S, E> extends AbstractStep<S, Map<String, E>> imple
     }
 
     private void addTraversalPrivate(final Traversal<S, S> traversal) {
-        final Step<S,?> startStep = traversal.asAdmin().getStartStep();
+        final Step<S, ?> startStep = traversal.asAdmin().getStartStep();
         if (startStep.getLabels().isEmpty())
             throw new IllegalArgumentException("Match traversals must have their start step labeled with as(): " + traversal);
         if (startStep.getLabels().size() > 1)
             throw new IllegalArgumentException("Match traversals can not have multiple labels on the start step: " + traversal);
         final String startAs = traversal.asAdmin().getStartStep().getLabels().iterator().next();
         ///
-        final Step<?,S> endStep = traversal.asAdmin().getEndStep();
-        if(endStep.getLabels().size() > 1)
+        final Step<?, S> endStep = traversal.asAdmin().getEndStep();
+        if (endStep.getLabels().size() > 1)
             throw new IllegalArgumentException("Match traversals can not have multiple labels on the end step: " + traversal);
 
         String endAs = endStep.getLabels().isEmpty() ? null : endStep.getLabels().iterator().next();
@@ -404,6 +406,11 @@ public final class MatchStep<S, E> extends AbstractStep<S, Map<String, E>> imple
         return this.traversals;
     }
 
+    @Override
+    public Scope getScope() {
+        return Scope.local;
+    }
+
     /**
      * A wrapper for a traversal in a query which maintains statistics about the traversal as
      * it consumes inputs and produces outputs.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/36f4a871/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
new file mode 100644
index 0000000..d988185
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/ScopingStrategy.java
@@ -0,0 +1,57 @@
+/*
+ *
+ *  * 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.
+ *
+ */
+
+package org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization;
+
+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;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.SelectOneStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.SelectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class ScopingStrategy extends AbstractTraversalStrategy<TraversalStrategy.FinalizationStrategy> implements TraversalStrategy.FinalizationStrategy {
+
+    private static final ScopingStrategy INSTANCE = new ScopingStrategy();
+
+    private ScopingStrategy() {
+    }
+
+    @Override
+    public void apply(final Traversal.Admin<?, ?> traversal) {
+        traversal.getSteps().stream().forEach(step -> {
+            if (step.getPreviousStep() instanceof Scoping) {
+                if (step instanceof SelectStep)
+                    ((SelectStep) step).setScope(((Scoping) step.getPreviousStep()).getScope());
+                else if (step instanceof SelectOneStep)
+                    ((SelectOneStep) step).setScope(((Scoping) step.getPreviousStep()).getScope());
+            }
+
+        });
+    }
+
+    public static ScopingStrategy instance() {
+        return INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/36f4a871/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy
index e6e2c0b..2cffab9 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy
@@ -25,7 +25,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
 import org.apache.tinkerpop.gremlin.structure.T
 import org.apache.tinkerpop.gremlin.structure.Vertex
 
-import static org.apache.tinkerpop.gremlin.process.traversal.Scope.local
 import static org.apache.tinkerpop.gremlin.structure.P.neq;
 
 /**
@@ -43,7 +42,7 @@ public abstract class GroovyMatchTest {
 
         @Override
         public Traversal<Vertex, Object> get_g_V_matchXa_out_bX_selectXb_idX() {
-            g.V().match('a', __.as('a').out().as('b')).select(local, 'b').by(T.id)
+            g.V().match('a', __.as('a').out().as('b')).select('b').by(T.id)
         }
 
         @Override
@@ -73,7 +72,7 @@ public abstract class GroovyMatchTest {
         public Traversal<Vertex, Map<String, String>> get_g_V_matchXa_created_b__a_repeatXoutX_timesX2XX_selectXab_nameX() {
             g.V().match('a',
                     __.as('a').out('created').as('b'),
-                    __.as('a').repeat(__.out).times(2).as('b')).select(local, 'a', 'b').by('name')
+                    __.as('a').repeat(__.out).times(2).as('b')).select('a', 'b').by('name')
         }
 
         @Override
@@ -81,14 +80,14 @@ public abstract class GroovyMatchTest {
             g.V().match('a',
                     __.as('a').out('created').has('name', 'lop').as('b'),
                     __.as('b').in('created').has('age', 29).as('c'),
-                    __.as('c').repeat(__.out).times(2)).select(local).by('name')
+                    __.as('c').repeat(__.out).times(2)).select.by('name')
         }
 
         @Override
         public Traversal<Vertex, String> get_g_V_out_out_matchXa_0created_b__b_0knows_cX_selectXcX_outXcreatedX_name() {
             g.V().out().out().match('a',
                     __.as('a').in('created').as('b'),
-                    __.as('b').in('knows').as('c')).select(local, 'c').out('created').name
+                    __.as('b').in('knows').as('c')).select('c').out('created').name
         }
 
         @Override
@@ -111,7 +110,7 @@ public abstract class GroovyMatchTest {
                     __.as('b').out('created').has('name', 'lop'),
                     __.as('b').match('a1',
                             __.as('a1').out('created').as('b1'),
-                            __.as('b1').in('created').as('c1')).select(local, 'c1').as('c')).select(local).by('name')
+                            __.as('b1').in('created').as('c1')).select('c1').as('c')).select.by('name')
         }
 
         @Override
@@ -159,7 +158,7 @@ public abstract class GroovyMatchTest {
                     __.as("a").out("created").has("name", "lop").as("b"),
                     __.as("b").in("created").has("age", 29).as("c"))
                     .where(__.as("c").repeat(__.out()).times(2))
-                    .select(local).by('name')
+                    .select().by('name')
         }
 
         @Override
@@ -168,7 +167,7 @@ public abstract class GroovyMatchTest {
                     __.as('a').out('created').as('b'),
                     __.as('b').in('created').as('c'))
                     .where('a', neq('c'))
-                    .select(local, 'a', 'c').by('name')
+                    .select('a', 'c').by('name')
         }
 
         /*@Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/36f4a871/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java
index 802dd16..74d40d5 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java
@@ -655,7 +655,7 @@ public abstract class MatchTest extends AbstractGremlinProcessTest {
 
         @Override
         public Traversal<Vertex, Object> get_g_V_matchXa_out_bX_selectXb_idX() {
-            return g.V().match("a", as("a").out().as("b")).select(Scope.local, "b").by(T.id);
+            return g.V().match("a", as("a").out().as("b")).select("b").by(T.id);
         }
 
         @Override
@@ -685,7 +685,7 @@ public abstract class MatchTest extends AbstractGremlinProcessTest {
         public Traversal<Vertex, Map<String, String>> get_g_V_matchXa_created_b__a_repeatXoutX_timesX2XX_selectXab_nameX() {
             return g.V().match("a",
                     as("a").out("created").as("b"),
-                    __.<Vertex>as("a").repeat(out()).times(2).as("b")).<String>select(Scope.local, "a", "b").by("name");
+                    __.<Vertex>as("a").repeat(out()).times(2).as("b")).<String>select("a", "b").by("name");
         }
 
         @Override
@@ -693,7 +693,7 @@ public abstract class MatchTest extends AbstractGremlinProcessTest {
             return g.V().match("a",
                     as("a").out("created").has("name", "lop").as("b"),
                     as("b").in("created").has("age", 29).as("c"),
-                    __.<Vertex>as("c").repeat(out()).times(2)).<String>select(Scope.local).by("name");
+                    __.<Vertex>as("c").repeat(out()).times(2)).<String>select().by("name");
         }
 
         @Override
@@ -701,14 +701,14 @@ public abstract class MatchTest extends AbstractGremlinProcessTest {
             return g.V().match("a",
                     as("a").out("created").has("name", "lop").as("b"),
                     as("b").in("created").has("age", 29).as("c"))
-                    .where(__.<Vertex>as("c").repeat(out()).times(2)).<String>select(Scope.local).by("name");
+                    .where(__.<Vertex>as("c").repeat(out()).times(2)).<String>select().by("name");
         }
 
         @Override
         public Traversal<Vertex, String> get_g_V_out_out_matchXa_0created_b__b_0knows_cX_selectXcX_outXcreatedX_name() {
             return g.V().out().out().match("a",
                     as("a").in("created").as("b"),
-                    as("b").in("knows").as("c")).select(Scope.local, "c").out("created").values("name");
+                    as("b").in("knows").as("c")).select("c").out("created").values("name");
         }
 
         @Override
@@ -731,7 +731,7 @@ public abstract class MatchTest extends AbstractGremlinProcessTest {
                     as("b").out("created").has("name", "lop"),
                     as("b").match("a1",
                             as("a1").out("created").as("b1"),
-                            as("b1").in("created").as("c1")).select(Scope.local, "c1").as("c")).<String>select(Scope.local).by("name");
+                            as("b1").in("created").as("c1")).select("c1").as("c")).<String>select().by("name");
         }
 
         @Override
@@ -779,7 +779,7 @@ public abstract class MatchTest extends AbstractGremlinProcessTest {
                     as("a").out("created").as("b"),
                     as("b").in("created").as("c"))
                     .where("a", neq("c"))
-                    .<String>select(Scope.local, "a", "c").by("name");
+                    .<String>select("a", "c").by("name");
         }
 
         /*@Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/36f4a871/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyComputerProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyComputerProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyComputerProvider.java
index 0611afd..6e79a76 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyComputerProvider.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyComputerProvider.java
@@ -27,6 +27,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.engine.ComputerTraversalEn
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ConjunctionStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.EngineDependentStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.ProfileStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.ScopingStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ComputerVerificationStrategy;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 
@@ -43,6 +44,7 @@ public class TinkerGraphNoStrategyComputerProvider extends TinkerGraphComputerPr
             EngineDependentStrategy.class,
             ProfileStrategy.class,
             ConjunctionStrategy.class,
+            ScopingStrategy.class,
             ComputerTraversalEngine.ComputerResultStrategy.class));
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/36f4a871/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProvider.java
index 578faec..6cb34cf 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProvider.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProvider.java
@@ -24,6 +24,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ConjunctionStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.ProfileStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.ScopingStrategy;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.tinkergraph.TinkerGraphProvider;
 import org.apache.tinkerpop.gremlin.tinkergraph.process.traversal.strategy.optimization.TinkerGraphStepStrategy;
@@ -39,7 +40,11 @@ import java.util.HashSet;
  */
 public class TinkerGraphNoStrategyProvider extends TinkerGraphProvider {
 
-    private static final HashSet<Class<? extends TraversalStrategy>> REQUIRED_STRATEGIES = new HashSet<>(Arrays.asList(TinkerGraphStepStrategy.class, ProfileStrategy.class, ConjunctionStrategy.class));
+    private static final HashSet<Class<? extends TraversalStrategy>> REQUIRED_STRATEGIES = new HashSet<>(Arrays.asList(
+            TinkerGraphStepStrategy.class,
+            ProfileStrategy.class,
+            ScopingStrategy.class,
+            ConjunctionStrategy.class));
 
     @Override
     public GraphTraversalSource traversal(final Graph graph) {