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 2016/06/29 03:23:35 UTC

tinkerpop git commit: moer work on Symbols and StepTranslator...the endless tedium..... EmptyGraphTravesal is never used and has no real purpose -- removed.

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1278 4feecbd60 -> 7240b54c8


moer work on Symbols and StepTranslator...the endless tedium..... EmptyGraphTravesal is never used and has no real purpose -- removed.


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

Branch: refs/heads/TINKERPOP-1278
Commit: 7240b54c8a9a3f9dcd05f96df7d408db35aaa4b2
Parents: 4feecbd
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue Jun 28 21:23:28 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue Jun 28 21:23:28 2016 -0600

----------------------------------------------------------------------
 .../dsl/graph/EmptyGraphTraversal.java          |  59 ---------
 .../traversal/dsl/graph/StepTranslator.java     | 122 +++++++++++++++++--
 .../process/traversal/dsl/graph/Symbols.java    |  19 ++-
 3 files changed, 133 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7240b54c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/EmptyGraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/EmptyGraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/EmptyGraphTraversal.java
deleted file mode 100644
index b69cc74..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/EmptyGraphTraversal.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.dsl.graph;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Step;
-import org.apache.tinkerpop.gremlin.process.traversal.util.EmptyTraversal;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class EmptyGraphTraversal<S, E> extends EmptyTraversal<S, E> implements GraphTraversal.Admin<S, E>, GraphTraversal<S, E> {
-
-    private static final EmptyGraphTraversal INSTANCE = new EmptyGraphTraversal<>();
-
-    public static <A, B> EmptyGraphTraversal<A, B> instance() {
-        return INSTANCE;
-    }
-
-    private EmptyGraphTraversal() {
-
-    }
-
-    @Override
-    public GraphTraversal.Admin<S, E> asAdmin() {
-        return this;
-    }
-
-    @Override
-    public <E2> GraphTraversal.Admin<S, E2> addStep(final Step<?, E2> step) {
-        return instance();
-    }
-
-    @Override
-    public GraphTraversal<S, E> iterate() {
-        return this;
-    }
-
-    @Override
-    @SuppressWarnings("CloneDoesntCallSuperClone")
-    public EmptyGraphTraversal<S, E> clone() {
-        return instance();
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7240b54c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/StepTranslator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/StepTranslator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/StepTranslator.java
index 9b52144..140488e 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/StepTranslator.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/StepTranslator.java
@@ -28,11 +28,18 @@ import org.apache.tinkerpop.gremlin.process.traversal.lambda.ColumnTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.AndStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.CoinStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.CyclicPathStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DedupGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DropStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.IsStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.LambdaFilterStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NotStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.SampleGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.SimplePathStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.TailGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.TimeLimitStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.TraversalFilterStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.WherePredicateStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.WhereTraversalStep;
@@ -69,19 +76,33 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertyKeyStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertyMapStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertyValueStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.RangeLocalStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.SackStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.SampleLocalStep;
 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.step.map.SumGlobalStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.SumLocalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.TailLocalStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.TraversalFlatMapStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.TraversalMapStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.TreeStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.UnfoldStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.AddPropertyStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.AggregateStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupSideEffectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupSideEffectStepV3d0;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IdentityStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.LambdaSideEffectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ProfileSideEffectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SackValueStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectCapStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StoreStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SubgraphStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.TraversalSideEffectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.TreeSideEffectStep;
 import org.apache.tinkerpop.gremlin.structure.Column;
 import org.apache.tinkerpop.gremlin.structure.Direction;
 import org.apache.tinkerpop.gremlin.structure.Edge;
@@ -90,6 +111,7 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
 
 import java.util.Optional;
 import java.util.function.BiFunction;
+import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.function.Predicate;
 import java.util.function.Supplier;
@@ -234,7 +256,14 @@ public final class StepTranslator implements Translator {
                 traversal.addStep(new MatchStep<>(traversal, ConnectiveStep.Connective.AND, (Traversal[]) arguments[0]));
                 return;
             case Symbols.sack:
-                traversal.addStep(new SackStep<>(traversal));
+                if (0 == arguments.length)
+                    traversal.addStep(new SackStep<>(traversal));
+                else {
+                    final SackValueStep<?, ?, ?> sackValueStep = new SackValueStep<>(traversal, (BiFunction) arguments[0]);
+                    if (2 == arguments.length)
+                        sackValueStep.modulateBy((String) arguments[1]);
+                    traversal.addStep(sackValueStep);
+                }
                 return;
             case Symbols.loops:
                 traversal.addStep(new LoopsStep<>(traversal));
@@ -279,16 +308,24 @@ public final class StepTranslator implements Translator {
                         new MeanLocalStep<>(traversal));
                 return;
             case Symbols.group:
-                traversal.addStep(new GroupStep<>(traversal));
+                traversal.addStep(0 == arguments.length ?
+                        new GroupStep<>(traversal) :
+                        new GroupSideEffectStep<>(traversal, (String) arguments[0]));
                 return;
             case Symbols.groupV3d0:
-                traversal.addStep(new GroupStepV3d0<>(traversal));
+                traversal.addStep(0 == arguments.length ?
+                        new GroupStepV3d0<>(traversal) :
+                        new GroupSideEffectStepV3d0<>(traversal, (String) arguments[0]));
                 return;
             case Symbols.groupCount:
-                traversal.addStep(new GroupCountStep<>(traversal));
+                traversal.addStep(0 == arguments.length ?
+                        new GroupCountStep<>(traversal) :
+                        new GroupSideEffectStep<>(traversal, (String) arguments[0]));
                 return;
             case Symbols.tree:
-                traversal.addStep(new TreeStep<>(traversal));
+                traversal.addStep(0 == arguments.length ?
+                        new TreeStep<>(traversal) :
+                        new TreeSideEffectStep<>(traversal, (String) arguments[0]));
                 return;
             case Symbols.addV:
                 traversal.addStep(1 == arguments.length ?
@@ -343,12 +380,83 @@ public final class StepTranslator implements Translator {
             case Symbols.not:
                 traversal.addStep(new NotStep<>(traversal, (Traversal) arguments[0]));
                 return;
+            case Symbols.range:
+                if (2 == arguments.length)
+                    traversal.addStep(new RangeGlobalStep<>(traversal, (long) arguments[0], (long) arguments[1]));
+                else
+                    traversal.addStep(Scope.global == arguments[0] ?
+                            new RangeGlobalStep<>(traversal, (long) arguments[1], (long) arguments[2]) :
+                            new RangeLocalStep<>(traversal, (long) arguments[1], (long) arguments[2]));
+                return;
+            case Symbols.limit:
+                if (1 == arguments.length)
+                    traversal.addStep(new RangeGlobalStep<>(traversal, 0, (int) arguments[0]));
+                else
+                    traversal.addStep(Scope.global == arguments[0] ?
+                            new RangeGlobalStep<>(traversal, 0, (int) arguments[1]) :
+                            new RangeLocalStep<>(traversal, 0, (int) arguments[1]));
+                return;
+            case Symbols.tail:
+                if (0 == arguments.length)
+                    traversal.addStep(new TailGlobalStep<>(traversal, 1L));
+                if (arguments[0] instanceof Long)
+                    traversal.addStep(new TailGlobalStep<>(traversal, (long) arguments[0]));
+                else if (1 == arguments.length)
+                    traversal.addStep(Scope.global == arguments[0] ?
+                            new TailGlobalStep<>(traversal, 1L) :
+                            new TailLocalStep<>(traversal, 1L));
+                else
+                    traversal.addStep(Scope.global == arguments[0] ?
+                            new TailGlobalStep<>(traversal, (long) arguments[1]) :
+                            new TailLocalStep<>(traversal, (long) arguments[1]));
+                return;
             case Symbols.coin:
-                traversal.addStep(new CoinStep<>(traversal, (Double) arguments[0]));
+                traversal.addStep(new CoinStep<>(traversal, (double) arguments[0]));
+                return;
+            case Symbols.timeLimit:
+                traversal.addStep(new TimeLimitStep<>(traversal, (long) arguments[0]));
+                return;
+            case Symbols.simplePath:
+                traversal.addStep(new SimplePathStep<>(traversal));
+                return;
+            case Symbols.cyclicPath:
+                traversal.addStep(new CyclicPathStep<>(traversal));
+                return;
+            case Symbols.sample:
+                if (1 == arguments.length)
+                    traversal.addStep(new SampleGlobalStep<>(traversal, (int) arguments[0]));
+                else
+                    traversal.addStep(Scope.global == arguments[0] ?
+                            new SampleGlobalStep<>(traversal, (int) arguments[1]) :
+                            new SampleLocalStep<>(traversal, (int) arguments[1]));
+                return;
+            case Symbols.drop:
+                traversal.addStep(new DropStep<>(traversal));
                 return;
+            case Symbols.sideEffect:
+                traversal.addStep(arguments[0] instanceof Traversal ?
+                        new TraversalSideEffectStep<>(traversal, (Traversal) arguments[0]) :
+                        new LambdaSideEffectStep<>(traversal, (Consumer) arguments[0]));
+                return;
+            case Symbols.cap:
+                traversal.addStep(new SideEffectCapStep<>(traversal, (String) arguments[0], (String[]) arguments[1]));
+                return;
+            case Symbols.aggregate:
+                traversal.addStep(new AggregateStep<>(traversal, (String) arguments[0]));
+                return;
+            case Symbols.store:
+                traversal.addStep(new StoreStep<>(traversal, (String) arguments[0]));
+                return;
+            case Symbols.subgraph:
+                traversal.addStep(new SubgraphStep(traversal, (String) arguments[0]));
+            case Symbols.profile:
+                traversal.addStep(new ProfileSideEffectStep<>(traversal, 0 == arguments.length ?
+                        ProfileSideEffectStep.DEFAULT_METRICS_KEY :
+                        (String) arguments[0]));
+                if (0 == arguments.length)
+                    traversal.addStep(new SideEffectCapStep<>(traversal, ProfileSideEffectStep.DEFAULT_METRICS_KEY));
             default:
                 throw new IllegalArgumentException("The provided step name is not supported by " + StepTranslator.class.getSimpleName() + ": " + stepName);
-
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7240b54c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/Symbols.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/Symbols.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/Symbols.java
index 8ef5896..d3ce01a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/Symbols.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/Symbols.java
@@ -60,7 +60,6 @@ public final class Symbols {
     public static final String mapKeys = "mapKeys";
     public static final String key = "key";
     public static final String value = "value";
-    public static final String from = "from";
     public static final String path = "path";
     public static final String match = "match";
     public static final String sack = "sack";
@@ -90,5 +89,23 @@ public final class Symbols {
     public static final String has = "has";
     public static final String is = "is";
     public static final String not = "not";
+    public static final String range = "range";
+    public static final String limit = "limit";
+    public static final String tail = "tail";
     public static final String coin = "coin";
+
+    public static final String timeLimit = "timeLimit";
+    public static final String simplePath = "simplePath";
+    public static final String cyclicPath = "cyclicPath";
+    public static final String sample = "sample";
+
+    public static final String drop = "drop";
+
+    public static final String sideEffect = "sideEffect";
+    public static final String cap = "cap";
+    public static final String store = "store";
+    public static final String aggregate = "aggregate";
+    public static final String subgraph = "subgraph";
+
+    public static final String profile = "profile";
 }