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/01 20:29:19 UTC
[1/3] incubator-tinkerpop git commit: More cleanup...
gremlin-python-3.2.1-SNAPSHOT.py is published to
gremlin-variant/variants/python/ directory for easy access by users.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/TINKERPOP-1278 762c2c84e -> 487d992ea
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/487d992e/gremlin-variant/variants/python/gremlin-python-3.2.1-SNAPSHOT.py
----------------------------------------------------------------------
diff --git a/gremlin-variant/variants/python/gremlin-python-3.2.1-SNAPSHOT.py b/gremlin-variant/variants/python/gremlin-python-3.2.1-SNAPSHOT.py
new file mode 100644
index 0000000..1039483
--- /dev/null
+++ b/gremlin-variant/variants/python/gremlin-python-3.2.1-SNAPSHOT.py
@@ -0,0 +1,906 @@
+'''
+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.
+'''
+
+class Helper(object):
+ @staticmethod
+ def stringOrObject(arg):
+ if (type(arg) is str and
+ not(arg.startswith("VertexProperty.Cardinality.")) and
+ not(arg.startswith("P.")) and
+ not(arg.startswith("Order.")) and
+ not(arg.startswith("Scope.")) and
+ not(arg.startswith("Pop.")) and
+ not(arg.startswith("Column.")) and
+ not(arg.startswith("T.")) and
+ not(arg.startswith("Operator.")) and
+ not(arg.startswith("SackFunctions.Barrier.")) and
+ not(arg.startswith("Direction."))):
+ return "\"" + arg + "\""
+ elif type(arg) is bool:
+ return str(arg).lower()
+ elif type(arg) is long:
+ return str(arg) + "L"
+ elif type(arg) is float:
+ return str(arg) + "f"
+ else:
+ return str(arg)
+ @staticmethod
+ def stringify(*args):
+ if len(args) == 0:
+ return ""
+ elif len(args) == 1:
+ return Helper.stringOrObject(args[0])
+ else:
+ return ", ".join(Helper.stringOrObject(i) for i in args)
+class Cardinality(object):
+ single = "VertexProperty.Cardinality.single"
+ list = "VertexProperty.Cardinality.list"
+ set = "VertexProperty.Cardinality.set"
+
+
+class Column(object):
+ keys = "Column.keys"
+ values = "Column.values"
+
+
+class Direction(object):
+ IN = "Direction.IN"
+ OUT = "Direction.OUT"
+ BOTH = "Direction.BOTH"
+
+
+class Operator(object):
+ sum = "Operator.sum"
+ minus = "Operator.minus"
+ mult = "Operator.mult"
+ div = "Operator.div"
+ min = "Operator.min"
+ max = "Operator.max"
+ assign = "Operator.assign"
+ _and = "Operator.and"
+ _or = "Operator.or"
+ addAll = "Operator.addAll"
+ sumLong = "Operator.sumLong"
+
+
+class Order(object):
+ incr = "Order.incr"
+ decr = "Order.decr"
+ shuffle = "Order.shuffle"
+ keyIncr = "Order.keyIncr"
+ keyDecr = "Order.keyDecr"
+ valueIncr = "Order.valueIncr"
+ valueDecr = "Order.valueDecr"
+
+
+class P(object):
+ @staticmethod
+ def equals(*args):
+ return "P.equals(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def toString(*args):
+ return "P.toString(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def hashCode(*args):
+ return "P.hashCode(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def clone(*args):
+ return "P.clone(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def lt(*args):
+ return "P.lt(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def getValue(*args):
+ return "P.getValue(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def setValue(*args):
+ return "P.setValue(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def test(*args):
+ return "P.test(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def eq(*args):
+ return "P.eq(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def _and(*args):
+ return "P._and(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def _or(*args):
+ return "P._or(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def without(*args):
+ return "P.without(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def within(*args):
+ return "P.within(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def neq(*args):
+ return "P.neq(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def _not(*args):
+ return "P._not(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def negate(*args):
+ return "P.negate(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def gte(*args):
+ return "P.gte(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def gt(*args):
+ return "P.gt(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def inside(*args):
+ return "P.inside(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def lte(*args):
+ return "P.lte(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def getBiPredicate(*args):
+ return "P.getBiPredicate(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def between(*args):
+ return "P.between(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def outside(*args):
+ return "P.outside(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def getOriginalValue(*args):
+ return "P.getOriginalValue(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def wait(*args):
+ return "P.wait(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def getClass(*args):
+ return "P.getClass(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def notify(*args):
+ return "P.notify(" + Helper.stringify(*args) + ")"
+ @staticmethod
+ def notifyAll(*args):
+ return "P.notifyAll(" + Helper.stringify(*args) + ")"
+
+
+class Pop(object):
+ first = "Pop.first"
+ last = "Pop.last"
+ all = "Pop.all"
+
+
+class Barrier(object):
+ normSack = "SackFunctions.Barrier.normSack"
+
+
+class Scope(object):
+ _local = "Scope.local"
+ _global = "Scope.global"
+
+
+class T(object):
+ label = "T.label"
+ id = "T.id"
+ key = "T.key"
+ value = "T.value"
+
+
+class PythonGraphTraversalSource(object):
+ def __init__(self, traversalSourceString):
+ self.traversalSourceString = traversalSourceString
+ def __repr__(self):
+ return "graphtraversalsource[" + self.traversalSourceString + "]"
+ def toString(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".toString(" + Helper.stringify(*args) + ")")
+ def clone(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".clone(" + Helper.stringify(*args) + ")")
+ def V(self, *args):
+ return PythonGraphTraversal(self.traversalSourceString + ".V(" + Helper.stringify(*args) + ")")
+ def E(self, *args):
+ return PythonGraphTraversal(self.traversalSourceString + ".E(" + Helper.stringify(*args) + ")")
+ def withSideEffect(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".withSideEffect(" + Helper.stringify(*args) + ")")
+ def addV(self, *args):
+ return PythonGraphTraversal(self.traversalSourceString + ".addV(" + Helper.stringify(*args) + ")")
+ def computer(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".computer(" + Helper.stringify(*args) + ")")
+ def inject(self, *args):
+ return PythonGraphTraversal(self.traversalSourceString + ".inject(" + Helper.stringify(*args) + ")")
+ def withBulk(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".withBulk(" + Helper.stringify(*args) + ")")
+ def withSack(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".withSack(" + Helper.stringify(*args) + ")")
+ def build(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".build(" + Helper.stringify(*args) + ")")
+ def getStrategies(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".getStrategies(" + Helper.stringify(*args) + ")")
+ def standard(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".standard(" + Helper.stringify(*args) + ")")
+ def withStrategies(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".withStrategies(" + Helper.stringify(*args) + ")")
+ def withPath(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".withPath(" + Helper.stringify(*args) + ")")
+ def getGraph(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".getGraph(" + Helper.stringify(*args) + ")")
+ def withComputer(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".withComputer(" + Helper.stringify(*args) + ")")
+ def withoutStrategies(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".withoutStrategies(" + Helper.stringify(*args) + ")")
+ def tx(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".tx(" + Helper.stringify(*args) + ")")
+ def wait(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".wait(" + Helper.stringify(*args) + ")")
+ def equals(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".equals(" + Helper.stringify(*args) + ")")
+ def hashCode(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".hashCode(" + Helper.stringify(*args) + ")")
+ def getClass(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".getClass(" + Helper.stringify(*args) + ")")
+ def notify(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".notify(" + Helper.stringify(*args) + ")")
+ def notifyAll(self, *args):
+ return PythonGraphTraversalSource(self.traversalSourceString + ".notifyAll(" + Helper.stringify(*args) + ")")
+
+
+class PythonGraphTraversal(object):
+ def __init__(self, traversalString):
+ self.traversalString = traversalString
+ def __repr__(self):
+ return self.traversalString;
+ def __getitem__(self,index):
+ if type(index) is int:
+ return self.range(index,index+1)
+ elif type(index) is slice:
+ return self.range(index.start,index.stop)
+ else:
+ raise TypeError("index must be int or slice")
+ def __getattr__(self,key):
+ return self.values(key)
+ def group(self, *args):
+ self.traversalString = self.traversalString + ".group(" + Helper.stringify(*args) + ")"
+ return self
+ def limit(self, *args):
+ self.traversalString = self.traversalString + ".limit(" + Helper.stringify(*args) + ")"
+ return self
+ def value(self, *args):
+ self.traversalString = self.traversalString + ".value(" + Helper.stringify(*args) + ")"
+ return self
+ def count(self, *args):
+ self.traversalString = self.traversalString + ".count(" + Helper.stringify(*args) + ")"
+ return self
+ def profile(self, *args):
+ self.traversalString = self.traversalString + ".profile(" + Helper.stringify(*args) + ")"
+ return self
+ def values(self, *args):
+ self.traversalString = self.traversalString + ".values(" + Helper.stringify(*args) + ")"
+ return self
+ def min(self, *args):
+ self.traversalString = self.traversalString + ".min(" + Helper.stringify(*args) + ")"
+ return self
+ def max(self, *args):
+ self.traversalString = self.traversalString + ".max(" + Helper.stringify(*args) + ")"
+ return self
+ def V(self, *args):
+ self.traversalString = self.traversalString + ".V(" + Helper.stringify(*args) + ")"
+ return self
+ def identity(self, *args):
+ self.traversalString = self.traversalString + ".identity(" + Helper.stringify(*args) + ")"
+ return self
+ def _in(self, *args):
+ self.traversalString = self.traversalString + ".in(" + Helper.stringify(*args) + ")"
+ return self
+ def out(self, *args):
+ self.traversalString = self.traversalString + ".out(" + Helper.stringify(*args) + ")"
+ return self
+ def key(self, *args):
+ self.traversalString = self.traversalString + ".key(" + Helper.stringify(*args) + ")"
+ return self
+ def store(self, *args):
+ self.traversalString = self.traversalString + ".store(" + Helper.stringify(*args) + ")"
+ return self
+ def path(self, *args):
+ self.traversalString = self.traversalString + ".path(" + Helper.stringify(*args) + ")"
+ return self
+ def sum(self, *args):
+ self.traversalString = self.traversalString + ".sum(" + Helper.stringify(*args) + ")"
+ return self
+ def toV(self, *args):
+ self.traversalString = self.traversalString + ".toV(" + Helper.stringify(*args) + ")"
+ return self
+ def filter(self, *args):
+ self.traversalString = self.traversalString + ".filter(" + Helper.stringify(*args) + ")"
+ return self
+ def tree(self, *args):
+ self.traversalString = self.traversalString + ".tree(" + Helper.stringify(*args) + ")"
+ return self
+ def match(self, *args):
+ self.traversalString = self.traversalString + ".match(" + Helper.stringify(*args) + ")"
+ return self
+ def range(self, *args):
+ self.traversalString = self.traversalString + ".range(" + Helper.stringify(*args) + ")"
+ return self
+ def order(self, *args):
+ self.traversalString = self.traversalString + ".order(" + Helper.stringify(*args) + ")"
+ return self
+ def map(self, *args):
+ self.traversalString = self.traversalString + ".map(" + Helper.stringify(*args) + ")"
+ return self
+ def tail(self, *args):
+ self.traversalString = self.traversalString + ".tail(" + Helper.stringify(*args) + ")"
+ return self
+ def _and(self, *args):
+ self.traversalString = self.traversalString + ".and(" + Helper.stringify(*args) + ")"
+ return self
+ def _or(self, *args):
+ self.traversalString = self.traversalString + ".or(" + Helper.stringify(*args) + ")"
+ return self
+ def id(self, *args):
+ self.traversalString = self.traversalString + ".id(" + Helper.stringify(*args) + ")"
+ return self
+ def addInE(self, *args):
+ self.traversalString = self.traversalString + ".addInE(" + Helper.stringify(*args) + ")"
+ return self
+ def addOutE(self, *args):
+ self.traversalString = self.traversalString + ".addOutE(" + Helper.stringify(*args) + ")"
+ return self
+ def unfold(self, *args):
+ self.traversalString = self.traversalString + ".unfold(" + Helper.stringify(*args) + ")"
+ return self
+ def addE(self, *args):
+ self.traversalString = self.traversalString + ".addE(" + Helper.stringify(*args) + ")"
+ return self
+ def sample(self, *args):
+ self.traversalString = self.traversalString + ".sample(" + Helper.stringify(*args) + ")"
+ return self
+ def simplePath(self, *args):
+ self.traversalString = self.traversalString + ".simplePath(" + Helper.stringify(*args) + ")"
+ return self
+ def _not(self, *args):
+ self.traversalString = self.traversalString + ".not(" + Helper.stringify(*args) + ")"
+ return self
+ def addV(self, *args):
+ self.traversalString = self.traversalString + ".addV(" + Helper.stringify(*args) + ")"
+ return self
+ def coalesce(self, *args):
+ self.traversalString = self.traversalString + ".coalesce(" + Helper.stringify(*args) + ")"
+ return self
+ def mean(self, *args):
+ self.traversalString = self.traversalString + ".mean(" + Helper.stringify(*args) + ")"
+ return self
+ def pageRank(self, *args):
+ self.traversalString = self.traversalString + ".pageRank(" + Helper.stringify(*args) + ")"
+ return self
+ def sideEffect(self, *args):
+ self.traversalString = self.traversalString + ".sideEffect(" + Helper.stringify(*args) + ")"
+ return self
+ def project(self, *args):
+ self.traversalString = self.traversalString + ".project(" + Helper.stringify(*args) + ")"
+ return self
+ def properties(self, *args):
+ self.traversalString = self.traversalString + ".properties(" + Helper.stringify(*args) + ")"
+ return self
+ def to(self, *args):
+ self.traversalString = self.traversalString + ".to(" + Helper.stringify(*args) + ")"
+ return self
+ def _from(self, *args):
+ self.traversalString = self.traversalString + ".from(" + Helper.stringify(*args) + ")"
+ return self
+ def has(self, *args):
+ self.traversalString = self.traversalString + ".has(" + Helper.stringify(*args) + ")"
+ return self
+ def union(self, *args):
+ self.traversalString = self.traversalString + ".union(" + Helper.stringify(*args) + ")"
+ return self
+ def iterate(self, *args):
+ self.traversalString = self.traversalString + ".iterate(" + Helper.stringify(*args) + ")"
+ return self
+ def asAdmin(self, *args):
+ self.traversalString = self.traversalString + ".asAdmin(" + Helper.stringify(*args) + ")"
+ return self
+ def groupV3d0(self, *args):
+ self.traversalString = self.traversalString + ".groupV3d0(" + Helper.stringify(*args) + ")"
+ return self
+ def inject(self, *args):
+ self.traversalString = self.traversalString + ".inject(" + Helper.stringify(*args) + ")"
+ return self
+ def sack(self, *args):
+ self.traversalString = self.traversalString + ".sack(" + Helper.stringify(*args) + ")"
+ return self
+ def barrier(self, *args):
+ self.traversalString = self.traversalString + ".barrier(" + Helper.stringify(*args) + ")"
+ return self
+ def subgraph(self, *args):
+ self.traversalString = self.traversalString + ".subgraph(" + Helper.stringify(*args) + ")"
+ return self
+ def propertyMap(self, *args):
+ self.traversalString = self.traversalString + ".propertyMap(" + Helper.stringify(*args) + ")"
+ return self
+ def hasValue(self, *args):
+ self.traversalString = self.traversalString + ".hasValue(" + Helper.stringify(*args) + ")"
+ return self
+ def branch(self, *args):
+ self.traversalString = self.traversalString + ".branch(" + Helper.stringify(*args) + ")"
+ return self
+ def option(self, *args):
+ self.traversalString = self.traversalString + ".option(" + Helper.stringify(*args) + ")"
+ return self
+ def optional(self, *args):
+ self.traversalString = self.traversalString + ".optional(" + Helper.stringify(*args) + ")"
+ return self
+ def flatMap(self, *args):
+ self.traversalString = self.traversalString + ".flatMap(" + Helper.stringify(*args) + ")"
+ return self
+ def outE(self, *args):
+ self.traversalString = self.traversalString + ".outE(" + Helper.stringify(*args) + ")"
+ return self
+ def _as(self, *args):
+ self.traversalString = self.traversalString + ".as(" + Helper.stringify(*args) + ")"
+ return self
+ def inV(self, *args):
+ self.traversalString = self.traversalString + ".inV(" + Helper.stringify(*args) + ")"
+ return self
+ def select(self, *args):
+ self.traversalString = self.traversalString + ".select(" + Helper.stringify(*args) + ")"
+ return self
+ def choose(self, *args):
+ self.traversalString = self.traversalString + ".choose(" + Helper.stringify(*args) + ")"
+ return self
+ def valueMap(self, *args):
+ self.traversalString = self.traversalString + ".valueMap(" + Helper.stringify(*args) + ")"
+ return self
+ def hasLabel(self, *args):
+ self.traversalString = self.traversalString + ".hasLabel(" + Helper.stringify(*args) + ")"
+ return self
+ def by(self, *args):
+ self.traversalString = self.traversalString + ".by(" + Helper.stringify(*args) + ")"
+ return self
+ def local(self, *args):
+ self.traversalString = self.traversalString + ".local(" + Helper.stringify(*args) + ")"
+ return self
+ def bothE(self, *args):
+ self.traversalString = self.traversalString + ".bothE(" + Helper.stringify(*args) + ")"
+ return self
+ def otherV(self, *args):
+ self.traversalString = self.traversalString + ".otherV(" + Helper.stringify(*args) + ")"
+ return self
+ def inE(self, *args):
+ self.traversalString = self.traversalString + ".inE(" + Helper.stringify(*args) + ")"
+ return self
+ def outV(self, *args):
+ self.traversalString = self.traversalString + ".outV(" + Helper.stringify(*args) + ")"
+ return self
+ def times(self, *args):
+ self.traversalString = self.traversalString + ".times(" + Helper.stringify(*args) + ")"
+ return self
+ def repeat(self, *args):
+ self.traversalString = self.traversalString + ".repeat(" + Helper.stringify(*args) + ")"
+ return self
+ def emit(self, *args):
+ self.traversalString = self.traversalString + ".emit(" + Helper.stringify(*args) + ")"
+ return self
+ def groupCount(self, *args):
+ self.traversalString = self.traversalString + ".groupCount(" + Helper.stringify(*args) + ")"
+ return self
+ def cap(self, *args):
+ self.traversalString = self.traversalString + ".cap(" + Helper.stringify(*args) + ")"
+ return self
+ def both(self, *args):
+ self.traversalString = self.traversalString + ".both(" + Helper.stringify(*args) + ")"
+ return self
+ def until(self, *args):
+ self.traversalString = self.traversalString + ".until(" + Helper.stringify(*args) + ")"
+ return self
+ def loops(self, *args):
+ self.traversalString = self.traversalString + ".loops(" + Helper.stringify(*args) + ")"
+ return self
+ def bothV(self, *args):
+ self.traversalString = self.traversalString + ".bothV(" + Helper.stringify(*args) + ")"
+ return self
+ def aggregate(self, *args):
+ self.traversalString = self.traversalString + ".aggregate(" + Helper.stringify(*args) + ")"
+ return self
+ def label(self, *args):
+ self.traversalString = self.traversalString + ".label(" + Helper.stringify(*args) + ")"
+ return self
+ def property(self, *args):
+ self.traversalString = self.traversalString + ".property(" + Helper.stringify(*args) + ")"
+ return self
+ def coin(self, *args):
+ self.traversalString = self.traversalString + ".coin(" + Helper.stringify(*args) + ")"
+ return self
+ def cyclicPath(self, *args):
+ self.traversalString = self.traversalString + ".cyclicPath(" + Helper.stringify(*args) + ")"
+ return self
+ def dedup(self, *args):
+ self.traversalString = self.traversalString + ".dedup(" + Helper.stringify(*args) + ")"
+ return self
+ def fold(self, *args):
+ self.traversalString = self.traversalString + ".fold(" + Helper.stringify(*args) + ")"
+ return self
+ def drop(self, *args):
+ self.traversalString = self.traversalString + ".drop(" + Helper.stringify(*args) + ")"
+ return self
+ def hasId(self, *args):
+ self.traversalString = self.traversalString + ".hasId(" + Helper.stringify(*args) + ")"
+ return self
+ def where(self, *args):
+ self.traversalString = self.traversalString + ".where(" + Helper.stringify(*args) + ")"
+ return self
+ def mapKeys(self, *args):
+ self.traversalString = self.traversalString + ".mapKeys(" + Helper.stringify(*args) + ")"
+ return self
+ def mapValues(self, *args):
+ self.traversalString = self.traversalString + ".mapValues(" + Helper.stringify(*args) + ")"
+ return self
+ def toE(self, *args):
+ self.traversalString = self.traversalString + ".toE(" + Helper.stringify(*args) + ")"
+ return self
+ def hasNot(self, *args):
+ self.traversalString = self.traversalString + ".hasNot(" + Helper.stringify(*args) + ")"
+ return self
+ def hasKey(self, *args):
+ self.traversalString = self.traversalString + ".hasKey(" + Helper.stringify(*args) + ")"
+ return self
+ def timeLimit(self, *args):
+ self.traversalString = self.traversalString + ".timeLimit(" + Helper.stringify(*args) + ")"
+ return self
+ def peerPressure(self, *args):
+ self.traversalString = self.traversalString + ".peerPressure(" + Helper.stringify(*args) + ")"
+ return self
+ def program(self, *args):
+ self.traversalString = self.traversalString + ".program(" + Helper.stringify(*args) + ")"
+ return self
+ def constant(self, *args):
+ self.traversalString = self.traversalString + ".constant(" + Helper.stringify(*args) + ")"
+ return self
+ def _is(self, *args):
+ self.traversalString = self.traversalString + ".is(" + Helper.stringify(*args) + ")"
+ return self
+ def next(self, *args):
+ self.traversalString = self.traversalString + ".next(" + Helper.stringify(*args) + ")"
+ return self.toList()
+ def fill(self, *args):
+ self.traversalString = self.traversalString + ".fill(" + Helper.stringify(*args) + ")"
+ return self.toList()
+ def forEachRemaining(self, *args):
+ self.traversalString = self.traversalString + ".forEachRemaining(" + Helper.stringify(*args) + ")"
+ return self.toList()
+ def toSet(self, *args):
+ self.traversalString = self.traversalString + ".toSet(" + Helper.stringify(*args) + ")"
+ return self.toList()
+ def tryNext(self, *args):
+ self.traversalString = self.traversalString + ".tryNext(" + Helper.stringify(*args) + ")"
+ return self.toList()
+ def toBulkSet(self, *args):
+ self.traversalString = self.traversalString + ".toBulkSet(" + Helper.stringify(*args) + ")"
+ return self.toList()
+ def toStream(self, *args):
+ self.traversalString = self.traversalString + ".toStream(" + Helper.stringify(*args) + ")"
+ return self.toList()
+ def explain(self, *args):
+ self.traversalString = self.traversalString + ".explain(" + Helper.stringify(*args) + ")"
+ return self.toList()
+ def remove(self, *args):
+ self.traversalString = self.traversalString + ".remove(" + Helper.stringify(*args) + ")"
+ return self.toList()
+ def hasNext(self, *args):
+ self.traversalString = self.traversalString + ".hasNext(" + Helper.stringify(*args) + ")"
+ return self.toList()
+
+
+class __(object):
+ @staticmethod
+ def group(*args):
+ return PythonGraphTraversal("__").group(*args)
+ @staticmethod
+ def limit(*args):
+ return PythonGraphTraversal("__").limit(*args)
+ @staticmethod
+ def value(*args):
+ return PythonGraphTraversal("__").value(*args)
+ @staticmethod
+ def count(*args):
+ return PythonGraphTraversal("__").count(*args)
+ @staticmethod
+ def values(*args):
+ return PythonGraphTraversal("__").values(*args)
+ @staticmethod
+ def min(*args):
+ return PythonGraphTraversal("__").min(*args)
+ @staticmethod
+ def max(*args):
+ return PythonGraphTraversal("__").max(*args)
+ @staticmethod
+ def V(*args):
+ return PythonGraphTraversal("__").V(*args)
+ @staticmethod
+ def identity(*args):
+ return PythonGraphTraversal("__").identity(*args)
+ @staticmethod
+ def _in(*args):
+ return PythonGraphTraversal("__")._in(*args)
+ @staticmethod
+ def out(*args):
+ return PythonGraphTraversal("__").out(*args)
+ @staticmethod
+ def key(*args):
+ return PythonGraphTraversal("__").key(*args)
+ @staticmethod
+ def start(*args):
+ return PythonGraphTraversal("__").start(*args)
+ @staticmethod
+ def store(*args):
+ return PythonGraphTraversal("__").store(*args)
+ @staticmethod
+ def path(*args):
+ return PythonGraphTraversal("__").path(*args)
+ @staticmethod
+ def sum(*args):
+ return PythonGraphTraversal("__").sum(*args)
+ @staticmethod
+ def toV(*args):
+ return PythonGraphTraversal("__").toV(*args)
+ @staticmethod
+ def filter(*args):
+ return PythonGraphTraversal("__").filter(*args)
+ @staticmethod
+ def tree(*args):
+ return PythonGraphTraversal("__").tree(*args)
+ @staticmethod
+ def match(*args):
+ return PythonGraphTraversal("__").match(*args)
+ @staticmethod
+ def range(*args):
+ return PythonGraphTraversal("__").range(*args)
+ @staticmethod
+ def order(*args):
+ return PythonGraphTraversal("__").order(*args)
+ @staticmethod
+ def map(*args):
+ return PythonGraphTraversal("__").map(*args)
+ @staticmethod
+ def tail(*args):
+ return PythonGraphTraversal("__").tail(*args)
+ @staticmethod
+ def _and(*args):
+ return PythonGraphTraversal("__")._and(*args)
+ @staticmethod
+ def _or(*args):
+ return PythonGraphTraversal("__")._or(*args)
+ @staticmethod
+ def id(*args):
+ return PythonGraphTraversal("__").id(*args)
+ @staticmethod
+ def addInE(*args):
+ return PythonGraphTraversal("__").addInE(*args)
+ @staticmethod
+ def addOutE(*args):
+ return PythonGraphTraversal("__").addOutE(*args)
+ @staticmethod
+ def unfold(*args):
+ return PythonGraphTraversal("__").unfold(*args)
+ @staticmethod
+ def addE(*args):
+ return PythonGraphTraversal("__").addE(*args)
+ @staticmethod
+ def sample(*args):
+ return PythonGraphTraversal("__").sample(*args)
+ @staticmethod
+ def simplePath(*args):
+ return PythonGraphTraversal("__").simplePath(*args)
+ @staticmethod
+ def _not(*args):
+ return PythonGraphTraversal("__")._not(*args)
+ @staticmethod
+ def addV(*args):
+ return PythonGraphTraversal("__").addV(*args)
+ @staticmethod
+ def coalesce(*args):
+ return PythonGraphTraversal("__").coalesce(*args)
+ @staticmethod
+ def mean(*args):
+ return PythonGraphTraversal("__").mean(*args)
+ @staticmethod
+ def sideEffect(*args):
+ return PythonGraphTraversal("__").sideEffect(*args)
+ @staticmethod
+ def project(*args):
+ return PythonGraphTraversal("__").project(*args)
+ @staticmethod
+ def properties(*args):
+ return PythonGraphTraversal("__").properties(*args)
+ @staticmethod
+ def to(*args):
+ return PythonGraphTraversal("__").to(*args)
+ @staticmethod
+ def has(*args):
+ return PythonGraphTraversal("__").has(*args)
+ @staticmethod
+ def union(*args):
+ return PythonGraphTraversal("__").union(*args)
+ @staticmethod
+ def groupV3d0(*args):
+ return PythonGraphTraversal("__").groupV3d0(*args)
+ @staticmethod
+ def inject(*args):
+ return PythonGraphTraversal("__").inject(*args)
+ @staticmethod
+ def sack(*args):
+ return PythonGraphTraversal("__").sack(*args)
+ @staticmethod
+ def barrier(*args):
+ return PythonGraphTraversal("__").barrier(*args)
+ @staticmethod
+ def subgraph(*args):
+ return PythonGraphTraversal("__").subgraph(*args)
+ @staticmethod
+ def propertyMap(*args):
+ return PythonGraphTraversal("__").propertyMap(*args)
+ @staticmethod
+ def hasValue(*args):
+ return PythonGraphTraversal("__").hasValue(*args)
+ @staticmethod
+ def branch(*args):
+ return PythonGraphTraversal("__").branch(*args)
+ @staticmethod
+ def optional(*args):
+ return PythonGraphTraversal("__").optional(*args)
+ @staticmethod
+ def flatMap(*args):
+ return PythonGraphTraversal("__").flatMap(*args)
+ @staticmethod
+ def outE(*args):
+ return PythonGraphTraversal("__").outE(*args)
+ @staticmethod
+ def _as(*args):
+ return PythonGraphTraversal("__")._as(*args)
+ @staticmethod
+ def inV(*args):
+ return PythonGraphTraversal("__").inV(*args)
+ @staticmethod
+ def select(*args):
+ return PythonGraphTraversal("__").select(*args)
+ @staticmethod
+ def choose(*args):
+ return PythonGraphTraversal("__").choose(*args)
+ @staticmethod
+ def valueMap(*args):
+ return PythonGraphTraversal("__").valueMap(*args)
+ @staticmethod
+ def hasLabel(*args):
+ return PythonGraphTraversal("__").hasLabel(*args)
+ @staticmethod
+ def local(*args):
+ return PythonGraphTraversal("__").local(*args)
+ @staticmethod
+ def bothE(*args):
+ return PythonGraphTraversal("__").bothE(*args)
+ @staticmethod
+ def otherV(*args):
+ return PythonGraphTraversal("__").otherV(*args)
+ @staticmethod
+ def inE(*args):
+ return PythonGraphTraversal("__").inE(*args)
+ @staticmethod
+ def outV(*args):
+ return PythonGraphTraversal("__").outV(*args)
+ @staticmethod
+ def times(*args):
+ return PythonGraphTraversal("__").times(*args)
+ @staticmethod
+ def repeat(*args):
+ return PythonGraphTraversal("__").repeat(*args)
+ @staticmethod
+ def emit(*args):
+ return PythonGraphTraversal("__").emit(*args)
+ @staticmethod
+ def groupCount(*args):
+ return PythonGraphTraversal("__").groupCount(*args)
+ @staticmethod
+ def cap(*args):
+ return PythonGraphTraversal("__").cap(*args)
+ @staticmethod
+ def both(*args):
+ return PythonGraphTraversal("__").both(*args)
+ @staticmethod
+ def until(*args):
+ return PythonGraphTraversal("__").until(*args)
+ @staticmethod
+ def loops(*args):
+ return PythonGraphTraversal("__").loops(*args)
+ @staticmethod
+ def bothV(*args):
+ return PythonGraphTraversal("__").bothV(*args)
+ @staticmethod
+ def aggregate(*args):
+ return PythonGraphTraversal("__").aggregate(*args)
+ @staticmethod
+ def label(*args):
+ return PythonGraphTraversal("__").label(*args)
+ @staticmethod
+ def __(*args):
+ return PythonGraphTraversal("__").__(*args)
+ @staticmethod
+ def property(*args):
+ return PythonGraphTraversal("__").property(*args)
+ @staticmethod
+ def coin(*args):
+ return PythonGraphTraversal("__").coin(*args)
+ @staticmethod
+ def cyclicPath(*args):
+ return PythonGraphTraversal("__").cyclicPath(*args)
+ @staticmethod
+ def dedup(*args):
+ return PythonGraphTraversal("__").dedup(*args)
+ @staticmethod
+ def fold(*args):
+ return PythonGraphTraversal("__").fold(*args)
+ @staticmethod
+ def drop(*args):
+ return PythonGraphTraversal("__").drop(*args)
+ @staticmethod
+ def hasId(*args):
+ return PythonGraphTraversal("__").hasId(*args)
+ @staticmethod
+ def where(*args):
+ return PythonGraphTraversal("__").where(*args)
+ @staticmethod
+ def mapKeys(*args):
+ return PythonGraphTraversal("__").mapKeys(*args)
+ @staticmethod
+ def mapValues(*args):
+ return PythonGraphTraversal("__").mapValues(*args)
+ @staticmethod
+ def toE(*args):
+ return PythonGraphTraversal("__").toE(*args)
+ @staticmethod
+ def hasNot(*args):
+ return PythonGraphTraversal("__").hasNot(*args)
+ @staticmethod
+ def hasKey(*args):
+ return PythonGraphTraversal("__").hasKey(*args)
+ @staticmethod
+ def timeLimit(*args):
+ return PythonGraphTraversal("__").timeLimit(*args)
+ @staticmethod
+ def constant(*args):
+ return PythonGraphTraversal("__").constant(*args)
+ @staticmethod
+ def _is(*args):
+ return PythonGraphTraversal("__")._is(*args)
+ @staticmethod
+ def wait(*args):
+ return PythonGraphTraversal("__").wait(*args)
+ @staticmethod
+ def equals(*args):
+ return PythonGraphTraversal("__").equals(*args)
+ @staticmethod
+ def toString(*args):
+ return PythonGraphTraversal("__").toString(*args)
+ @staticmethod
+ def hashCode(*args):
+ return PythonGraphTraversal("__").hashCode(*args)
+ @staticmethod
+ def getClass(*args):
+ return PythonGraphTraversal("__").getClass(*args)
+ @staticmethod
+ def notify(*args):
+ return PythonGraphTraversal("__").notify(*args)
+ @staticmethod
+ def notifyAll(*args):
+ return PythonGraphTraversal("__").notifyAll(*args)
+
+
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/487d992e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 870025c..ecaaae1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -117,6 +117,7 @@ limitations under the License.
<module>gremlin-groovy</module>
<module>gremlin-groovy-test</module>
<module>tinkergraph-gremlin</module>
+ <module>gremlin-variant</module>
<module>hadoop-gremlin</module>
<module>spark-gremlin</module>
<module>giraph-gremlin</module>
@@ -125,7 +126,6 @@ limitations under the License.
<module>gremlin-console</module>
<module>gremlin-server</module>
<module>gremlin-archetype</module>
- <module>gremlin-variant</module>
</modules>
<scm>
<connection>scm:git:git@git-wip-us.apache.org:repos/asf/incubator-tinkerpop.git</connection>
[2/3] incubator-tinkerpop git commit: More cleanup...
gremlin-python-3.2.1-SNAPSHOT.py is published to
gremlin-variant/variants/python/ directory for easy access by users.
Posted by ok...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/487d992e/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphTraversal.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphTraversal.java
new file mode 100644
index 0000000..0245d5a
--- /dev/null
+++ b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphTraversal.java
@@ -0,0 +1,968 @@
+/*
+ * 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.variant;
+
+import org.apache.tinkerpop.gremlin.process.computer.VertexProgram;
+import org.apache.tinkerpop.gremlin.process.traversal.Order;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.Path;
+import org.apache.tinkerpop.gremlin.process.traversal.Pop;
+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.dsl.graph.DefaultGraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.TraverserSet;
+import org.apache.tinkerpop.gremlin.structure.Column;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
+import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
+
+import javax.script.Bindings;
+import javax.script.ScriptEngine;
+import javax.script.SimpleBindings;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.function.BiFunction;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.Predicate;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class VariantGraphTraversal<S, E> extends DefaultGraphTraversal<S, E> {
+
+
+ public StringBuilder variantString;
+ protected VariantConverter variantConverter;
+
+ public VariantGraphTraversal(final Graph graph, final StringBuilder variantString, final VariantConverter variantConverter) {
+ super(graph);
+ this.variantConverter = variantConverter;
+ this.variantString = variantString;
+ __.EMPTY_GRAPH_TRAVERSAL = () -> {
+ final StringBuilder builder = new StringBuilder("__");
+ return new VariantGraphTraversal<>(EmptyGraph.instance(), builder, this.variantConverter);
+ };
+ }
+
+ public StringBuilder getVariantString() {
+ return this.variantString;
+ }
+
+ public String toString() {
+ return this.steps.isEmpty() ? this.variantString.toString() : super.toString();
+ }
+
+ @Override
+ public void applyStrategies() {
+ if (!(this.getParent() instanceof EmptyStep)) {
+ return;
+ }
+ try {
+ final String jythonString = this.variantConverter.generateGremlinGroovy(this.variantString);
+ __.EMPTY_GRAPH_TRAVERSAL = DefaultGraphTraversal::new;
+ ScriptEngine groovy = ScriptEngineCache.get("gremlin-groovy");
+ final Bindings groovyBindings = new SimpleBindings();
+ groovyBindings.put("g", new GraphTraversalSource(this.getGraph().get(), this.getStrategies()));
+ Traversal.Admin<S, E> traversal = (Traversal.Admin<S, E>) groovy.eval(jythonString, groovyBindings);
+ assert !traversal.isLocked();
+ this.sideEffects = traversal.getSideEffects();
+ this.strategies = traversal.getStrategies();
+ traversal.getSteps().forEach(step -> this.addStep(step));
+ super.applyStrategies();
+ } catch (final Exception e) {
+ throw new IllegalArgumentException(e.getMessage(), e);
+ }
+ }
+
+ private static String getMethodName() {
+ return Thread.currentThread().getStackTrace()[2].getMethodName();
+ }
+
+ //////////////////////////
+
+ public <E2> GraphTraversal<S, E2> map(final Function<Traverser<E>, E2> function) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), function);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> map(final Traversal<?, E2> mapTraversal) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), mapTraversal);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> flatMap(final Function<Traverser<E>, Iterator<E2>> function) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), function);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> flatMap(final Traversal<?, E2> flatMapTraversal) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), flatMapTraversal);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Object> id() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, String> label() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> identity() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> constant(final E2 e) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), e);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Vertex> V(final Object... vertexIdsOrElements) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), vertexIdsOrElements);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Vertex> to(final Direction direction, final String... edgeLabels) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), direction, edgeLabels);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Vertex> out(final String... edgeLabels) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), edgeLabels);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Vertex> in(final String... edgeLabels) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), edgeLabels);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Vertex> both(final String... edgeLabels) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), edgeLabels);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Edge> toE(final Direction direction, final String... edgeLabels) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), direction, edgeLabels);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Edge> outE(final String... edgeLabels) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), edgeLabels);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Edge> inE(final String... edgeLabels) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), edgeLabels);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Edge> bothE(final String... edgeLabels) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), edgeLabels);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Vertex> toV(final Direction direction) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), direction);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Vertex> inV() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Vertex> outV() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Vertex> bothV() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Vertex> otherV() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> order() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> order(final Scope scope) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), scope);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, ? extends Property<E2>> properties(final String... propertyKeys) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), propertyKeys);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> values(final String... propertyKeys) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), propertyKeys);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, Map<String, E2>> propertyMap(final String... propertyKeys) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), propertyKeys);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, Map<String, E2>> valueMap(final String... propertyKeys) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), propertyKeys);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, Map<String, E2>> valueMap(final boolean includeTokens, final String... propertyKeys) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), includeTokens, propertyKeys);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, Collection<E2>> select(final Column column) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), column);
+ return (GraphTraversal) this;
+ }
+
+ @Deprecated
+ public <E2> GraphTraversal<S, E2> mapValues() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ @Deprecated
+ public <E2> GraphTraversal<S, E2> mapKeys() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, String> key() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> value() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Path> path() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, Map<String, E2>> match(final Traversal<?, ?>... matchTraversals) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), matchTraversals);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> sack() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Integer> loops() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, Map<String, E2>> project(final String projectKey, final String... otherProjectKeys) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), projectKey, otherProjectKeys);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, Map<String, E2>> select(final Pop pop, final String selectKey1, final String selectKey2, String... otherSelectKeys) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), pop, selectKey1, selectKey2, otherSelectKeys);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, Map<String, E2>> select(final String selectKey1, final String selectKey2, String... otherSelectKeys) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), selectKey1, selectKey2, otherSelectKeys);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> select(final Pop pop, final String selectKey) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), pop, selectKey);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> select(final String selectKey) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), selectKey);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> unfold() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, List<E>> fold() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> fold(final E2 seed, final BiFunction<E2, E, E2> foldFunction) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), seed, foldFunction);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Long> count() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Long> count(final Scope scope) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), scope);
+ return (GraphTraversal) this;
+ }
+
+ public <E2 extends Number> GraphTraversal<S, E2> sum() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public <E2 extends Number> GraphTraversal<S, E2> sum(final Scope scope) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), scope);
+ return (GraphTraversal) this;
+ }
+
+ public <E2 extends Number> GraphTraversal<S, E2> max() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public <E2 extends Number> GraphTraversal<S, E2> max(final Scope scope) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), scope);
+ return (GraphTraversal) this;
+ }
+
+ public <E2 extends Number> GraphTraversal<S, E2> min() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public <E2 extends Number> GraphTraversal<S, E2> min(final Scope scope) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), scope);
+ return (GraphTraversal) this;
+ }
+
+ public <E2 extends Number> GraphTraversal<S, E2> mean() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public <E2 extends Number> GraphTraversal<S, E2> mean(final Scope scope) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), scope);
+ return (GraphTraversal) this;
+ }
+
+ public <K, V> GraphTraversal<S, Map<K, V>> group() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ @Deprecated
+ public <K, V> GraphTraversal<S, Map<K, V>> groupV3d0() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public <K> GraphTraversal<S, Map<K, Long>> groupCount() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Tree> tree() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Vertex> addV(final String vertexLabel) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), vertexLabel);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Vertex> addV() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ @Deprecated
+ public GraphTraversal<S, Vertex> addV(final Object... propertyKeyValues) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), propertyKeyValues);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Edge> addE(final String edgeLabel) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), edgeLabel);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> to(final String toStepLabel) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), toStepLabel);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> from(final String fromStepLabel) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), fromStepLabel);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> to(final Traversal<E, Vertex> toVertex) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), toVertex);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> from(final Traversal<E, Vertex> fromVertex) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), fromVertex);
+ return (GraphTraversal) this;
+ }
+
+ @Deprecated
+ public GraphTraversal<S, Edge> addE(final Direction direction, final String firstVertexKeyOrEdgeLabel, final String edgeLabelOrSecondVertexKey, final Object... propertyKeyValues) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), direction, firstVertexKeyOrEdgeLabel, edgeLabelOrSecondVertexKey, propertyKeyValues);
+ return (GraphTraversal) this;
+ }
+
+ @Deprecated
+ public GraphTraversal<S, Edge> addOutE(final String firstVertexKeyOrEdgeLabel, final String edgeLabelOrSecondVertexKey, final Object... propertyKeyValues) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), firstVertexKeyOrEdgeLabel, edgeLabelOrSecondVertexKey, propertyKeyValues);
+ return (GraphTraversal) this;
+ }
+
+ @Deprecated
+ public GraphTraversal<S, Edge> addInE(final String firstVertexKeyOrEdgeLabel, final String edgeLabelOrSecondVertexKey, final Object... propertyKeyValues) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), firstVertexKeyOrEdgeLabel, edgeLabelOrSecondVertexKey, propertyKeyValues);
+ return (GraphTraversal) this;
+ }
+
+ ///////////////////// FILTER STEPS /////////////////////
+
+ public GraphTraversal<S, E> filter(final Predicate<Traverser<E>> predicate) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), predicate);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> filter(final Traversal<?, ?> filterTraversal) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), filterTraversal);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> or(final Traversal<?, ?>... orTraversals) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), orTraversals);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> and(final Traversal<?, ?>... andTraversals) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), andTraversals);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> inject(final E... injections) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), injections);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> dedup(final Scope scope, final String... dedupLabels) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), scope, dedupLabels);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> dedup(final String... dedupLabels) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), dedupLabels);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> where(final String startKey, final P<String> predicate) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), startKey, predicate);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> where(final P<String> predicate) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), predicate);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> where(final Traversal<?, ?> whereTraversal) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), whereTraversal);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> has(final String propertyKey, final P<?> predicate) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), propertyKey, predicate);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> has(final T accessor, final P<?> predicate) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), accessor, predicate);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> has(final String propertyKey, final Object value) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), propertyKey, value);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> has(final T accessor, final Object value) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), accessor, value);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> has(final String label, final String propertyKey, final P<?> predicate) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), label, propertyKey, predicate);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> has(final String label, final String propertyKey, final Object value) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), label, propertyKey, value);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> has(final T accessor, final Traversal<?, ?> propertyTraversal) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), accessor, propertyTraversal);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> has(final String propertyKey, final Traversal<?, ?> propertyTraversal) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), propertyKey, propertyTraversal);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> has(final String propertyKey) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), propertyKey);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> hasNot(final String propertyKey) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), propertyKey);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> hasLabel(final String... labels) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), labels);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> hasId(final Object... ids) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), ids);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> hasKey(final String... keys) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), keys);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> hasValue(final Object... values) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), values);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> is(final P<E> predicate) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), predicate);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> is(final Object value) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), value);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> not(final Traversal<?, ?> notTraversal) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), notTraversal);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> coin(final double probability) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), probability);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> range(final long low, final long high) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), low, high);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> range(final Scope scope, final long low, final long high) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), scope, low, high);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> limit(final long limit) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), limit);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> limit(final Scope scope, final long limit) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), scope, limit);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> tail() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> tail(final long limit) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), limit);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> tail(final Scope scope) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), scope);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> tail(final Scope scope, final long limit) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), scope, limit);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> timeLimit(final long timeLimit) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), timeLimit);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> simplePath() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> cyclicPath() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> sample(final int amountToSample) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), amountToSample);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> sample(final Scope scope, final int amountToSample) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), scope, amountToSample);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> drop() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ ///////////////////// SIDE-EFFECT STEPS /////////////////////
+
+ public GraphTraversal<S, E> sideEffect(final Consumer<Traverser<E>> consumer) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), consumer);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> sideEffect(final Traversal<?, ?> sideEffectTraversal) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectTraversal);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> cap(final String sideEffectKey, final String... sideEffectKeys) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey, sideEffectKeys);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, Edge> subgraph(final String sideEffectKey) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> aggregate(final String sideEffectKey) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> group(final String sideEffectKey) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> groupV3d0(final String sideEffectKey) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> groupCount(final String sideEffectKey) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> tree(final String sideEffectKey) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey);
+ return (GraphTraversal) this;
+ }
+
+ public <V, U> GraphTraversal<S, E> sack(final BiFunction<V, U, V> sackOperator) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), sackOperator);
+ return (GraphTraversal) this;
+ }
+
+
+ @Deprecated
+ public <V, U> GraphTraversal<S, E> sack(final BiFunction<V, U, V> sackOperator, final String elementPropertyKey) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), sackOperator, elementPropertyKey);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> store(final String sideEffectKey) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> profile(final String sideEffectKey) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> property(final VertexProperty.Cardinality cardinality, final Object key, final Object value, final Object... keyValues) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), cardinality, key, value, keyValues);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> property(final Object key, final Object value, final Object... keyValues) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), key, value, keyValues);
+ return (GraphTraversal) this;
+ }
+
+ ///////////////////// BRANCH STEPS /////////////////////
+
+ public <M, E2> GraphTraversal<S, E2> branch(final Traversal<?, M> branchTraversal) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), branchTraversal);
+ return (GraphTraversal) this;
+ }
+
+ public <M, E2> GraphTraversal<S, E2> branch(final Function<Traverser<E>, M> function) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), function);
+ return (GraphTraversal) this;
+ }
+
+ public <M, E2> GraphTraversal<S, E2> choose(final Traversal<?, M> choiceTraversal) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), choiceTraversal);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> choose(final Traversal<?, ?> traversalPredicate,
+ final Traversal<?, E2> trueChoice, final Traversal<?, E2> falseChoice) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), traversalPredicate, trueChoice, falseChoice);
+ return (GraphTraversal) this;
+ }
+
+ public <M, E2> GraphTraversal<S, E2> choose(final Function<E, M> choiceFunction) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), choiceFunction);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> choose(final Predicate<E> choosePredicate,
+ final Traversal<?, E2> trueChoice, final Traversal<?, E2> falseChoice) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), choosePredicate, trueChoice, falseChoice);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> optional(final Traversal<?, E2> optionalTraversal) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), optionalTraversal);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> union(final Traversal<?, E2>... unionTraversals) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), unionTraversals);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> coalesce(final Traversal<?, E2>... coalesceTraversals) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), coalesceTraversals);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> repeat(final Traversal<?, E> repeatTraversal) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), repeatTraversal);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> emit(final Traversal<?, ?> emitTraversal) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), emitTraversal);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> emit(final Predicate<Traverser<E>> emitPredicate) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), emitPredicate);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> emit() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> until(final Traversal<?, ?> untilTraversal) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), untilTraversal);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> until(final Predicate<Traverser<E>> untilPredicate) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), untilPredicate);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> times(final int maxLoops) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), maxLoops);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E2> local(final Traversal<?, E2> localTraversal) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), localTraversal);
+ return (GraphTraversal) this;
+ }
+
+ /////////////////// VERTEX PROGRAM STEPS ////////////////
+
+ public GraphTraversal<S, E> pageRank() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> pageRank(final double alpha) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), alpha);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> peerPressure() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> program(final VertexProgram<?> vertexProgram) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), vertexProgram);
+ return (GraphTraversal) this;
+ }
+
+ ///////////////////// UTILITY STEPS /////////////////////
+
+ public GraphTraversal<S, E> as(final String stepLabel, final String... stepLabels) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), stepLabel, stepLabels);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> barrier() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> barrier(final int maxBarrierSize) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), maxBarrierSize);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> barrier(final Consumer<TraverserSet<Object>> barrierConsumer) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), barrierConsumer);
+ return (GraphTraversal) this;
+ }
+
+
+ //// BY-MODULATORS
+
+ public GraphTraversal<S, E> by() {
+ this.variantConverter.addStep(this.variantString, getMethodName());
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> by(final Traversal<?, ?> traversal) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), traversal);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> by(final T token) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), token);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> by(final String key) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), key);
+ return (GraphTraversal) this;
+ }
+
+ public <V> GraphTraversal<S, E> by(final Function<V, Object> function) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), function);
+ return (GraphTraversal) this;
+ }
+
+ //// COMPARATOR BY-MODULATORS
+
+ public <V> GraphTraversal<S, E> by(final Traversal<?, ?> traversal, final Comparator<V> comparator) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), traversal, comparator);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> by(final Comparator<E> comparator) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), comparator);
+ return (GraphTraversal) this;
+ }
+
+ public GraphTraversal<S, E> by(final Order order) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), order);
+ return (GraphTraversal) this;
+ }
+
+ public <V> GraphTraversal<S, E> by(final String key, final Comparator<V> comparator) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), key, comparator);
+ return (GraphTraversal) this;
+ }
+
+ public <U> GraphTraversal<S, E> by(final Function<U, Object> function, final Comparator comparator) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), function, comparator);
+ return (GraphTraversal) this;
+ }
+
+ ////
+
+ public <M, E2> GraphTraversal<S, E> option(final M pickToken, final Traversal<E, E2> traversalOption) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), pickToken, traversalOption);
+ return (GraphTraversal) this;
+ }
+
+ public <E2> GraphTraversal<S, E> option(final Traversal<E, E2> traversalOption) {
+ this.variantConverter.addStep(this.variantString, getMethodName(), traversalOption);
+ return (GraphTraversal) this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/487d992e/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphTraversalSource.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphTraversalSource.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphTraversalSource.java
new file mode 100644
index 0000000..9e4382f
--- /dev/null
+++ b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphTraversalSource.java
@@ -0,0 +1,219 @@
+/*
+ * 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.variant;
+
+import org.apache.tinkerpop.gremlin.process.computer.Computer;
+import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.AddVertexStartStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Transaction;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+
+import java.util.function.BinaryOperator;
+import java.util.function.Supplier;
+import java.util.function.UnaryOperator;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class VariantGraphTraversalSource extends GraphTraversalSource {
+
+ private VariantConverter variantConverter;
+ private StringBuilder sourceString = new StringBuilder("g");
+
+ public VariantGraphTraversalSource(final VariantConverter variantConverter, final Graph graph, final TraversalStrategies traversalStrategies) {
+ super(graph, traversalStrategies);
+ this.variantConverter = variantConverter;
+ }
+
+ private static String getMethodName() {
+ return Thread.currentThread().getStackTrace()[2].getMethodName();
+ }
+
+ ///
+
+ @Override
+ public GraphTraversal<Edge, Edge> E(final Object... edgeIds) {
+ final StringBuilder temp = new StringBuilder(this.sourceString.toString());
+ this.variantConverter.addStep(temp, getMethodName(), edgeIds);
+ return new VariantGraphTraversal<>(this.getGraph(), temp, this.variantConverter);
+ }
+
+ @Override
+ public GraphTraversal<Vertex, Vertex> V(final Object... vertexIds) {
+ final StringBuilder temp = new StringBuilder(this.sourceString.toString());
+ this.variantConverter.addStep(temp, getMethodName(), vertexIds);
+ return new VariantGraphTraversal<>(this.getGraph(), temp, this.variantConverter);
+ }
+
+ @Deprecated
+ public GraphTraversal<Vertex, Vertex> addV(final Object... keyValues) {
+ final StringBuilder temp = new StringBuilder(this.sourceString.toString());
+ this.variantConverter.addStep(temp, getMethodName(), keyValues);
+ return new VariantGraphTraversal<>(this.getGraph(), temp, this.variantConverter);
+ }
+
+ public GraphTraversal<Vertex, Vertex> addV(final String label) {
+ final StringBuilder temp = new StringBuilder(this.sourceString.toString());
+ this.variantConverter.addStep(temp, getMethodName(), label);
+ return new VariantGraphTraversal<>(this.getGraph(), temp, this.variantConverter);
+ }
+
+ public GraphTraversal<Vertex, Vertex> addV() {
+ final StringBuilder temp = new StringBuilder(this.sourceString.toString());
+ this.variantConverter.addStep(temp, getMethodName());
+ return new VariantGraphTraversal<>(this.getGraph(), temp, this.variantConverter);
+ }
+
+ public <S> GraphTraversal<S, S> inject(S... starts) {
+ final StringBuilder temp = new StringBuilder(this.sourceString.toString());
+ this.variantConverter.addStep(temp, getMethodName(), starts);
+ return new VariantGraphTraversal<>(this.getGraph(), temp, this.variantConverter);
+ }
+
+ ///
+
+ @Override
+ public GraphTraversalSource withComputer(final Computer computer) {
+ this.variantConverter.addStep(this.sourceString, getMethodName(), computer);
+ return this;
+ }
+
+ @Override
+ public GraphTraversalSource withComputer(final Class<? extends GraphComputer> graphComputerClass) {
+ this.variantConverter.addStep(this.sourceString, getMethodName(), graphComputerClass);
+ return this;
+ }
+
+ @Override
+ public GraphTraversalSource withComputer() {
+ this.variantConverter.addStep(this.sourceString, getMethodName());
+ return this;
+ }
+
+ @Override
+ public GraphTraversalSource withStrategies(final TraversalStrategy... traversalStrategies) {
+ return super.withStrategies(traversalStrategies);
+ //this.variantConverter.addStep(this.sourceString, getMethodName(), traversalStrategies);
+ //return this;
+ }
+
+ @Override
+ @SuppressWarnings({"unchecked", "varargs"})
+ public GraphTraversalSource withoutStrategies(final Class<? extends TraversalStrategy>... traversalStrategyClasses) {
+ this.variantConverter.addStep(this.sourceString, getMethodName(), traversalStrategyClasses);
+ return this;
+ }
+
+ @Override
+ public <A> GraphTraversalSource withSack(final Supplier<A> initialValue, final UnaryOperator<A> splitOperator, final BinaryOperator<A> mergeOperator) {
+ this.variantConverter.addStep(this.sourceString, getMethodName(), splitOperator, mergeOperator);
+ return this;
+ }
+
+ @Override
+ public <A> GraphTraversalSource withSack(final A initialValue, final UnaryOperator<A> splitOperator, final BinaryOperator<A> mergeOperator) {
+ this.variantConverter.addStep(this.sourceString, getMethodName(), initialValue, splitOperator, mergeOperator);
+ return this;
+ }
+
+ @Override
+ public <A> GraphTraversalSource withSack(final A initialValue) {
+ this.variantConverter.addStep(this.sourceString, getMethodName(), initialValue);
+ return this;
+ }
+
+ @Override
+ public <A> GraphTraversalSource withSack(final Supplier<A> initialValue) {
+ this.variantConverter.addStep(this.sourceString, getMethodName(), initialValue);
+ return this;
+ }
+
+ @Override
+ public <A> GraphTraversalSource withSack(final Supplier<A> initialValue, final UnaryOperator<A> splitOperator) {
+ this.variantConverter.addStep(this.sourceString, getMethodName(), initialValue, splitOperator);
+ return this;
+ }
+
+ @Override
+ public <A> GraphTraversalSource withSack(final A initialValue, final UnaryOperator<A> splitOperator) {
+ this.variantConverter.addStep(this.sourceString, getMethodName(), initialValue, splitOperator);
+ return this;
+ }
+
+ @Override
+ public <A> GraphTraversalSource withSack(final Supplier<A> initialValue, final BinaryOperator<A> mergeOperator) {
+ this.variantConverter.addStep(this.sourceString, getMethodName(), initialValue, mergeOperator);
+ return this;
+ }
+
+ @Override
+ public <A> GraphTraversalSource withSack(final A initialValue, final BinaryOperator<A> mergeOperator) {
+ this.variantConverter.addStep(this.sourceString, getMethodName(), initialValue, mergeOperator);
+ return this;
+ }
+
+ /////
+
+ @Override
+ public <A> GraphTraversalSource withSideEffect(final String key, final Supplier<A> initialValue, final BinaryOperator<A> reducer) {
+ this.variantConverter.addStep(this.sourceString, getMethodName(), key, initialValue, reducer);
+ return this;
+ }
+
+ @Override
+ public <A> GraphTraversalSource withSideEffect(final String key, final A initialValue, final BinaryOperator<A> reducer) {
+ this.variantConverter.addStep(this.sourceString, getMethodName(), key, initialValue, reducer);
+ return this;
+ }
+
+ @Override
+ public <A> GraphTraversalSource withSideEffect(final String key, final A initialValue) {
+ this.variantConverter.addStep(this.sourceString, getMethodName(), key, initialValue);
+ return this;
+ }
+
+ @Override
+ public <A> GraphTraversalSource withSideEffect(final String key, final Supplier<A> initialValue) {
+ this.variantConverter.addStep(this.sourceString, getMethodName(), key, initialValue);
+ return this;
+ }
+
+ /////
+
+ @Override
+ public GraphTraversalSource withBulk(final boolean useBulk) {
+ this.variantConverter.addStep(this.sourceString, getMethodName(), useBulk);
+ return this;
+ }
+
+ @Override
+ public GraphTraversalSource withPath() {
+ this.variantConverter.addStep(this.sourceString, getMethodName());
+ return this;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/487d992e/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonVariantConverter.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonVariantConverter.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonVariantConverter.java
new file mode 100644
index 0000000..b5810ac
--- /dev/null
+++ b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonVariantConverter.java
@@ -0,0 +1,161 @@
+/*
+ * 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.variant.python;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Operator;
+import org.apache.tinkerpop.gremlin.process.traversal.Order;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.Pop;
+import org.apache.tinkerpop.gremlin.process.traversal.SackFunctions;
+import org.apache.tinkerpop.gremlin.process.traversal.Scope;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.VerificationException;
+import org.apache.tinkerpop.gremlin.process.traversal.util.EmptyTraversal;
+import org.apache.tinkerpop.gremlin.process.variant.VariantConverter;
+import org.apache.tinkerpop.gremlin.process.variant.VariantGraphTraversal;
+import org.apache.tinkerpop.gremlin.structure.Column;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.util.Gremlin;
+import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
+import org.apache.tinkerpop.gremlin.util.iterator.ArrayIterator;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
+
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import javax.script.SimpleBindings;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Stream;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class PythonVariantConverter implements VariantConverter {
+
+ private static ScriptEngine JYTHON_ENGINE = ScriptEngineCache.get("jython");
+
+ static {
+ try {
+ final String fileName = (new File("variants/python").exists() ? "variants/python/" : "gremlin-variants/variants/python/") + "gremlin-python-" + Gremlin.version() + ".py";
+ GremlinPythonGenerator.create(fileName);
+ JYTHON_ENGINE.eval("execfile(\"" + fileName + "\")");
+ } catch (final ScriptException e) {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+ }
+
+ private static final Set<String> PREFIX_NAMES = new HashSet<>(Arrays.asList("as", "in", "and", "or", "is", "not", "from"));
+
+ @Override
+ public String generateGremlinGroovy(final StringBuilder currentTraversal) throws ScriptException {
+ if (currentTraversal.toString().contains("$") || currentTraversal.toString().contains("@"))
+ throw new VerificationException("Lambdas are currently not supported: " + currentTraversal.toString(), EmptyTraversal.instance());
+
+ final Bindings jythonBindings = new SimpleBindings();
+ jythonBindings.put("g", JYTHON_ENGINE.eval("PythonGraphTraversalSource(\"g\")"));
+ JYTHON_ENGINE.getContext().setBindings(jythonBindings, ScriptContext.GLOBAL_SCOPE);
+ return JYTHON_ENGINE.eval(currentTraversal.toString()).toString();
+ }
+
+ @Override
+ public void addStep(final StringBuilder currentTraversal, final String stepName, final Object... arguments) {
+ // flatten the arguments into a single array
+ final Object[] objects = Stream.of(arguments)
+ .flatMap(arg ->
+ IteratorUtils.stream(arg instanceof Object[] ?
+ new ArrayIterator<>((Object[]) arg) :
+ IteratorUtils.of(arg)))
+ .toArray();
+ if (objects.length == 0)
+ currentTraversal.append(".").append(convertStepName(stepName)).append("()");
+ else if (stepName.equals("range") && 2 == objects.length)
+ currentTraversal.append("[").append(objects[0]).append(":").append(objects[1]).append("]");
+ else if (stepName.equals("limit") && 1 == objects.length)
+ currentTraversal.append("[0:").append(objects[0]).append("]");
+ else if (stepName.equals("values") && 1 == objects.length && !currentTraversal.toString().equals("__"))
+ currentTraversal.append(".").append(objects[0]);
+ else {
+ String temp = "." + convertStepName(stepName) + "(";
+ for (final Object object : objects) {
+ temp = temp + convertToString(object) + ",";
+ }
+ currentTraversal.append(temp.substring(0, temp.length() - 1) + ")");
+ }
+ }
+
+ private static String convertToString(final Object object) {
+ if (object instanceof String)
+ return "\"" + object + "\"";
+ else if (object instanceof List) {
+ final List list = new ArrayList<>(((List) object).size());
+ for (final Object item : (List) object) {
+ list.add(item instanceof String ? "'" + item + "'" : convertToString(item)); // hack
+ }
+ return list.toString();
+ } else if (object instanceof Long)
+ return object + "L";
+ else if (object instanceof Class)
+ return ((Class) object).getCanonicalName();
+ else if (object instanceof SackFunctions.Barrier)
+ return "Barrier." + object.toString();
+ else if (object instanceof VertexProperty.Cardinality)
+ return "Cardinality." + object.toString();
+ else if (object instanceof Direction)
+ return "Direction." + object.toString();
+ else if (object instanceof Operator)
+ return ((object == Operator.and || object == Operator.or) ? "Operator._" : "Operator.") + object.toString();
+ else if (object instanceof Pop)
+ return "Pop." + object.toString();
+ else if (object instanceof Column)
+ return "Column." + object.toString();
+ else if (object instanceof P)
+ return "P." + ((P) object).getBiPredicate() + "(" + (((P) object).getValue() instanceof String ? "'" + ((P) object).getValue() + "'" : convertToString(((P) object).getValue())) + ")";
+ else if (object instanceof T)
+ return "T." + object.toString();
+ else if (object instanceof Order)
+ return "Order." + object.toString();
+ else if (object instanceof Scope)
+ return "Scope._" + object.toString();
+ else if (object instanceof Element)
+ return convertToString(((Element) object).id()); // hack
+ else if (object instanceof VariantGraphTraversal)
+ return ((VariantGraphTraversal) object).getVariantString().toString();
+ else if (object instanceof Boolean)
+ return object.equals(Boolean.TRUE) ? "True" : "False";
+ else
+ return null == object ? "" : object.toString();
+ }
+
+ private static String convertStepName(final String stepName) {
+ if (PREFIX_NAMES.contains(stepName))
+ return "_" + stepName;
+ else
+ return stepName;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/487d992e/gremlin-variant/src/test/resources/log4j-test.properties
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/resources/log4j-test.properties b/gremlin-variant/src/test/resources/log4j-test.properties
index f9035ba..79038b1 100644
--- a/gremlin-variant/src/test/resources/log4j-test.properties
+++ b/gremlin-variant/src/test/resources/log4j-test.properties
@@ -17,7 +17,7 @@
# under the License.
#
-log4j.rootLogger=INFO, stdout
+log4j.rootLogger=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%p] %C - %m%n
\ No newline at end of file
[3/3] incubator-tinkerpop git commit: More cleanup...
gremlin-python-3.2.1-SNAPSHOT.py is published to
gremlin-variant/variants/python/ directory for easy access by users.
Posted by ok...@apache.org.
More cleanup... gremlin-python-3.2.1-SNAPSHOT.py is published to gremlin-variant/variants/python/ directory for easy access by users.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/487d992e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/487d992e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/487d992e
Branch: refs/heads/TINKERPOP-1278
Commit: 487d992ea967ddc0625f112cc12d6147768039a3
Parents: 762c2c8
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Jun 1 14:29:12 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Jun 1 14:29:12 2016 -0600
----------------------------------------------------------------------
.../step/sideEffect/GroovyStoreTest.groovy | 2 +-
.../traversal/step/sideEffect/StoreTest.java | 8 +-
.../python/GremlinPythonGenerator.groovy | 25 +-
.../process/variant/VariantConverter.java | 32 -
.../process/variant/VariantGraphTraversal.java | 968 -------------------
.../variant/VariantGraphTraversalSource.java | 219 -----
.../variant/python/PythonVariantConverter.java | 160 ---
.../process/variant/VariantConverter.java | 32 +
.../process/variant/VariantGraphTraversal.java | 968 +++++++++++++++++++
.../variant/VariantGraphTraversalSource.java | 219 +++++
.../variant/python/PythonVariantConverter.java | 161 +++
.../src/test/resources/log4j-test.properties | 2 +-
.../python/gremlin-python-3.2.1-SNAPSHOT.py | 906 +++++++++++++++++
pom.xml | 2 +-
14 files changed, 2315 insertions(+), 1389 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/487d992e/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyStoreTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyStoreTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyStoreTest.groovy
index 24bc1ea..5a24f07 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyStoreTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyStoreTest.groovy
@@ -41,7 +41,7 @@ public abstract class GroovyStoreTest {
}
@Override
- public Traversal<Vertex, Set<String>> get_g_V_withSideEffectXa_setX_both_name_storeXaX_capXaX() {
+ public Traversal<Vertex, Set<String>> get_g_withSideEffectXa_setX_V_both_name_storeXaX_capXaX() {
new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('a'){[] as Set}.V.both.name.store('a').cap('a')");
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/487d992e/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/StoreTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/StoreTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/StoreTest.java
index 32c294b..40b03ef 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/StoreTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/StoreTest.java
@@ -47,7 +47,7 @@ public abstract class StoreTest extends AbstractGremlinProcessTest {
public abstract Traversal<Vertex, Collection> get_g_VX1X_storeXaX_byXnameX_out_storeXaX_byXnameX_name_capXaX(final Object v1Id);
- public abstract Traversal<Vertex, Set<String>> get_g_V_withSideEffectXa_setX_both_name_storeXaX_capXaX();
+ public abstract Traversal<Vertex, Set<String>> get_g_withSideEffectXa_setX_V_both_name_storeXaX_capXaX();
public abstract Traversal<Vertex, Collection> get_g_V_storeXaX_byXoutEXcreatedX_countX_out_out_storeXaX_byXinEXcreatedX_weight_sumX_capXaX();
@@ -83,8 +83,8 @@ public abstract class StoreTest extends AbstractGremlinProcessTest {
@Test
@LoadGraphWith(MODERN)
- public void g_V_withSideEffectXa_setX_both_name_storeXaX_capXaX() {
- final Traversal<Vertex, Set<String>> traversal = get_g_V_withSideEffectXa_setX_both_name_storeXaX_capXaX();
+ public void g_withSideEffectXa_setX_V_both_name_storeXaX_capXaX() {
+ final Traversal<Vertex, Set<String>> traversal = get_g_withSideEffectXa_setX_V_both_name_storeXaX_capXaX();
printTraversalForm(traversal);
final Set<String> names = traversal.next();
assertFalse(traversal.hasNext());
@@ -126,7 +126,7 @@ public abstract class StoreTest extends AbstractGremlinProcessTest {
}
@Override
- public Traversal<Vertex, Set<String>> get_g_V_withSideEffectXa_setX_both_name_storeXaX_capXaX() {
+ public Traversal<Vertex, Set<String>> get_g_withSideEffectXa_setX_V_both_name_storeXaX_capXaX() {
return g.withSideEffect("a", HashSetSupplier.instance()).V().both().<String>values("name").store("a").cap("a");
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/487d992e/gremlin-variant/src/main/groovy/org/apache/tinkerpop/gremlin/process/variant/python/GremlinPythonGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/groovy/org/apache/tinkerpop/gremlin/process/variant/python/GremlinPythonGenerator.groovy b/gremlin-variant/src/main/groovy/org/apache/tinkerpop/gremlin/process/variant/python/GremlinPythonGenerator.groovy
index 64f378e..36e7375 100644
--- a/gremlin-variant/src/main/groovy/org/apache/tinkerpop/gremlin/process/variant/python/GremlinPythonGenerator.groovy
+++ b/gremlin-variant/src/main/groovy/org/apache/tinkerpop/gremlin/process/variant/python/GremlinPythonGenerator.groovy
@@ -24,15 +24,34 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
-import org.apache.tinkerpop.gremlin.util.Gremlin
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
class GremlinPythonGenerator {
- public static void create(final String outputFileLocation) {
+ public static void create(final String gremlinPythonFile) {
final StringBuilder pythonClass = new StringBuilder()
+ pythonClass.append("""'''
+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.
+'''
+""")
+
pythonClass.append("""
class Helper(object):
@staticmethod
@@ -239,7 +258,7 @@ class Helper(object):
pythonClass.append("\n\n")
// save to a python file
- final File file = new File("${outputFileLocation}/gremlin-python-${Gremlin.version()}.py");
+ final File file = new File(gremlinPythonFile);
file.delete()
pythonClass.eachLine { file.append(it + "\n") }
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/487d992e/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/process/variant/VariantConverter.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/process/variant/VariantConverter.java b/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/process/variant/VariantConverter.java
deleted file mode 100644
index 110a1ef..0000000
--- a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/process/variant/VariantConverter.java
+++ /dev/null
@@ -1,32 +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.variant;
-
-import javax.script.ScriptException;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public interface VariantConverter {
-
- public void addStep(final StringBuilder currentTraversal, final String stepName, final Object... arguments);
-
- public String generateGremlinGroovy(final StringBuilder currentTraversal) throws ScriptException;
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/487d992e/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphTraversal.java b/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphTraversal.java
deleted file mode 100644
index 0245d5a..0000000
--- a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphTraversal.java
+++ /dev/null
@@ -1,968 +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.variant;
-
-import org.apache.tinkerpop.gremlin.process.computer.VertexProgram;
-import org.apache.tinkerpop.gremlin.process.traversal.Order;
-import org.apache.tinkerpop.gremlin.process.traversal.P;
-import org.apache.tinkerpop.gremlin.process.traversal.Path;
-import org.apache.tinkerpop.gremlin.process.traversal.Pop;
-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.dsl.graph.DefaultGraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
-import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.TraverserSet;
-import org.apache.tinkerpop.gremlin.structure.Column;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Property;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
-import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
-
-import javax.script.Bindings;
-import javax.script.ScriptEngine;
-import javax.script.SimpleBindings;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.function.BiFunction;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import java.util.function.Predicate;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class VariantGraphTraversal<S, E> extends DefaultGraphTraversal<S, E> {
-
-
- public StringBuilder variantString;
- protected VariantConverter variantConverter;
-
- public VariantGraphTraversal(final Graph graph, final StringBuilder variantString, final VariantConverter variantConverter) {
- super(graph);
- this.variantConverter = variantConverter;
- this.variantString = variantString;
- __.EMPTY_GRAPH_TRAVERSAL = () -> {
- final StringBuilder builder = new StringBuilder("__");
- return new VariantGraphTraversal<>(EmptyGraph.instance(), builder, this.variantConverter);
- };
- }
-
- public StringBuilder getVariantString() {
- return this.variantString;
- }
-
- public String toString() {
- return this.steps.isEmpty() ? this.variantString.toString() : super.toString();
- }
-
- @Override
- public void applyStrategies() {
- if (!(this.getParent() instanceof EmptyStep)) {
- return;
- }
- try {
- final String jythonString = this.variantConverter.generateGremlinGroovy(this.variantString);
- __.EMPTY_GRAPH_TRAVERSAL = DefaultGraphTraversal::new;
- ScriptEngine groovy = ScriptEngineCache.get("gremlin-groovy");
- final Bindings groovyBindings = new SimpleBindings();
- groovyBindings.put("g", new GraphTraversalSource(this.getGraph().get(), this.getStrategies()));
- Traversal.Admin<S, E> traversal = (Traversal.Admin<S, E>) groovy.eval(jythonString, groovyBindings);
- assert !traversal.isLocked();
- this.sideEffects = traversal.getSideEffects();
- this.strategies = traversal.getStrategies();
- traversal.getSteps().forEach(step -> this.addStep(step));
- super.applyStrategies();
- } catch (final Exception e) {
- throw new IllegalArgumentException(e.getMessage(), e);
- }
- }
-
- private static String getMethodName() {
- return Thread.currentThread().getStackTrace()[2].getMethodName();
- }
-
- //////////////////////////
-
- public <E2> GraphTraversal<S, E2> map(final Function<Traverser<E>, E2> function) {
- this.variantConverter.addStep(this.variantString, getMethodName(), function);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> map(final Traversal<?, E2> mapTraversal) {
- this.variantConverter.addStep(this.variantString, getMethodName(), mapTraversal);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> flatMap(final Function<Traverser<E>, Iterator<E2>> function) {
- this.variantConverter.addStep(this.variantString, getMethodName(), function);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> flatMap(final Traversal<?, E2> flatMapTraversal) {
- this.variantConverter.addStep(this.variantString, getMethodName(), flatMapTraversal);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Object> id() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, String> label() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> identity() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> constant(final E2 e) {
- this.variantConverter.addStep(this.variantString, getMethodName(), e);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Vertex> V(final Object... vertexIdsOrElements) {
- this.variantConverter.addStep(this.variantString, getMethodName(), vertexIdsOrElements);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Vertex> to(final Direction direction, final String... edgeLabels) {
- this.variantConverter.addStep(this.variantString, getMethodName(), direction, edgeLabels);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Vertex> out(final String... edgeLabels) {
- this.variantConverter.addStep(this.variantString, getMethodName(), edgeLabels);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Vertex> in(final String... edgeLabels) {
- this.variantConverter.addStep(this.variantString, getMethodName(), edgeLabels);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Vertex> both(final String... edgeLabels) {
- this.variantConverter.addStep(this.variantString, getMethodName(), edgeLabels);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Edge> toE(final Direction direction, final String... edgeLabels) {
- this.variantConverter.addStep(this.variantString, getMethodName(), direction, edgeLabels);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Edge> outE(final String... edgeLabels) {
- this.variantConverter.addStep(this.variantString, getMethodName(), edgeLabels);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Edge> inE(final String... edgeLabels) {
- this.variantConverter.addStep(this.variantString, getMethodName(), edgeLabels);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Edge> bothE(final String... edgeLabels) {
- this.variantConverter.addStep(this.variantString, getMethodName(), edgeLabels);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Vertex> toV(final Direction direction) {
- this.variantConverter.addStep(this.variantString, getMethodName(), direction);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Vertex> inV() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Vertex> outV() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Vertex> bothV() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Vertex> otherV() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> order() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> order(final Scope scope) {
- this.variantConverter.addStep(this.variantString, getMethodName(), scope);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, ? extends Property<E2>> properties(final String... propertyKeys) {
- this.variantConverter.addStep(this.variantString, getMethodName(), propertyKeys);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> values(final String... propertyKeys) {
- this.variantConverter.addStep(this.variantString, getMethodName(), propertyKeys);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, Map<String, E2>> propertyMap(final String... propertyKeys) {
- this.variantConverter.addStep(this.variantString, getMethodName(), propertyKeys);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, Map<String, E2>> valueMap(final String... propertyKeys) {
- this.variantConverter.addStep(this.variantString, getMethodName(), propertyKeys);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, Map<String, E2>> valueMap(final boolean includeTokens, final String... propertyKeys) {
- this.variantConverter.addStep(this.variantString, getMethodName(), includeTokens, propertyKeys);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, Collection<E2>> select(final Column column) {
- this.variantConverter.addStep(this.variantString, getMethodName(), column);
- return (GraphTraversal) this;
- }
-
- @Deprecated
- public <E2> GraphTraversal<S, E2> mapValues() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- @Deprecated
- public <E2> GraphTraversal<S, E2> mapKeys() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, String> key() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> value() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Path> path() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, Map<String, E2>> match(final Traversal<?, ?>... matchTraversals) {
- this.variantConverter.addStep(this.variantString, getMethodName(), matchTraversals);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> sack() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Integer> loops() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, Map<String, E2>> project(final String projectKey, final String... otherProjectKeys) {
- this.variantConverter.addStep(this.variantString, getMethodName(), projectKey, otherProjectKeys);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, Map<String, E2>> select(final Pop pop, final String selectKey1, final String selectKey2, String... otherSelectKeys) {
- this.variantConverter.addStep(this.variantString, getMethodName(), pop, selectKey1, selectKey2, otherSelectKeys);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, Map<String, E2>> select(final String selectKey1, final String selectKey2, String... otherSelectKeys) {
- this.variantConverter.addStep(this.variantString, getMethodName(), selectKey1, selectKey2, otherSelectKeys);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> select(final Pop pop, final String selectKey) {
- this.variantConverter.addStep(this.variantString, getMethodName(), pop, selectKey);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> select(final String selectKey) {
- this.variantConverter.addStep(this.variantString, getMethodName(), selectKey);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> unfold() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, List<E>> fold() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> fold(final E2 seed, final BiFunction<E2, E, E2> foldFunction) {
- this.variantConverter.addStep(this.variantString, getMethodName(), seed, foldFunction);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Long> count() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Long> count(final Scope scope) {
- this.variantConverter.addStep(this.variantString, getMethodName(), scope);
- return (GraphTraversal) this;
- }
-
- public <E2 extends Number> GraphTraversal<S, E2> sum() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public <E2 extends Number> GraphTraversal<S, E2> sum(final Scope scope) {
- this.variantConverter.addStep(this.variantString, getMethodName(), scope);
- return (GraphTraversal) this;
- }
-
- public <E2 extends Number> GraphTraversal<S, E2> max() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public <E2 extends Number> GraphTraversal<S, E2> max(final Scope scope) {
- this.variantConverter.addStep(this.variantString, getMethodName(), scope);
- return (GraphTraversal) this;
- }
-
- public <E2 extends Number> GraphTraversal<S, E2> min() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public <E2 extends Number> GraphTraversal<S, E2> min(final Scope scope) {
- this.variantConverter.addStep(this.variantString, getMethodName(), scope);
- return (GraphTraversal) this;
- }
-
- public <E2 extends Number> GraphTraversal<S, E2> mean() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public <E2 extends Number> GraphTraversal<S, E2> mean(final Scope scope) {
- this.variantConverter.addStep(this.variantString, getMethodName(), scope);
- return (GraphTraversal) this;
- }
-
- public <K, V> GraphTraversal<S, Map<K, V>> group() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- @Deprecated
- public <K, V> GraphTraversal<S, Map<K, V>> groupV3d0() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public <K> GraphTraversal<S, Map<K, Long>> groupCount() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Tree> tree() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Vertex> addV(final String vertexLabel) {
- this.variantConverter.addStep(this.variantString, getMethodName(), vertexLabel);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Vertex> addV() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- @Deprecated
- public GraphTraversal<S, Vertex> addV(final Object... propertyKeyValues) {
- this.variantConverter.addStep(this.variantString, getMethodName(), propertyKeyValues);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Edge> addE(final String edgeLabel) {
- this.variantConverter.addStep(this.variantString, getMethodName(), edgeLabel);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> to(final String toStepLabel) {
- this.variantConverter.addStep(this.variantString, getMethodName(), toStepLabel);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> from(final String fromStepLabel) {
- this.variantConverter.addStep(this.variantString, getMethodName(), fromStepLabel);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> to(final Traversal<E, Vertex> toVertex) {
- this.variantConverter.addStep(this.variantString, getMethodName(), toVertex);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> from(final Traversal<E, Vertex> fromVertex) {
- this.variantConverter.addStep(this.variantString, getMethodName(), fromVertex);
- return (GraphTraversal) this;
- }
-
- @Deprecated
- public GraphTraversal<S, Edge> addE(final Direction direction, final String firstVertexKeyOrEdgeLabel, final String edgeLabelOrSecondVertexKey, final Object... propertyKeyValues) {
- this.variantConverter.addStep(this.variantString, getMethodName(), direction, firstVertexKeyOrEdgeLabel, edgeLabelOrSecondVertexKey, propertyKeyValues);
- return (GraphTraversal) this;
- }
-
- @Deprecated
- public GraphTraversal<S, Edge> addOutE(final String firstVertexKeyOrEdgeLabel, final String edgeLabelOrSecondVertexKey, final Object... propertyKeyValues) {
- this.variantConverter.addStep(this.variantString, getMethodName(), firstVertexKeyOrEdgeLabel, edgeLabelOrSecondVertexKey, propertyKeyValues);
- return (GraphTraversal) this;
- }
-
- @Deprecated
- public GraphTraversal<S, Edge> addInE(final String firstVertexKeyOrEdgeLabel, final String edgeLabelOrSecondVertexKey, final Object... propertyKeyValues) {
- this.variantConverter.addStep(this.variantString, getMethodName(), firstVertexKeyOrEdgeLabel, edgeLabelOrSecondVertexKey, propertyKeyValues);
- return (GraphTraversal) this;
- }
-
- ///////////////////// FILTER STEPS /////////////////////
-
- public GraphTraversal<S, E> filter(final Predicate<Traverser<E>> predicate) {
- this.variantConverter.addStep(this.variantString, getMethodName(), predicate);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> filter(final Traversal<?, ?> filterTraversal) {
- this.variantConverter.addStep(this.variantString, getMethodName(), filterTraversal);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> or(final Traversal<?, ?>... orTraversals) {
- this.variantConverter.addStep(this.variantString, getMethodName(), orTraversals);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> and(final Traversal<?, ?>... andTraversals) {
- this.variantConverter.addStep(this.variantString, getMethodName(), andTraversals);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> inject(final E... injections) {
- this.variantConverter.addStep(this.variantString, getMethodName(), injections);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> dedup(final Scope scope, final String... dedupLabels) {
- this.variantConverter.addStep(this.variantString, getMethodName(), scope, dedupLabels);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> dedup(final String... dedupLabels) {
- this.variantConverter.addStep(this.variantString, getMethodName(), dedupLabels);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> where(final String startKey, final P<String> predicate) {
- this.variantConverter.addStep(this.variantString, getMethodName(), startKey, predicate);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> where(final P<String> predicate) {
- this.variantConverter.addStep(this.variantString, getMethodName(), predicate);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> where(final Traversal<?, ?> whereTraversal) {
- this.variantConverter.addStep(this.variantString, getMethodName(), whereTraversal);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> has(final String propertyKey, final P<?> predicate) {
- this.variantConverter.addStep(this.variantString, getMethodName(), propertyKey, predicate);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> has(final T accessor, final P<?> predicate) {
- this.variantConverter.addStep(this.variantString, getMethodName(), accessor, predicate);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> has(final String propertyKey, final Object value) {
- this.variantConverter.addStep(this.variantString, getMethodName(), propertyKey, value);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> has(final T accessor, final Object value) {
- this.variantConverter.addStep(this.variantString, getMethodName(), accessor, value);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> has(final String label, final String propertyKey, final P<?> predicate) {
- this.variantConverter.addStep(this.variantString, getMethodName(), label, propertyKey, predicate);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> has(final String label, final String propertyKey, final Object value) {
- this.variantConverter.addStep(this.variantString, getMethodName(), label, propertyKey, value);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> has(final T accessor, final Traversal<?, ?> propertyTraversal) {
- this.variantConverter.addStep(this.variantString, getMethodName(), accessor, propertyTraversal);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> has(final String propertyKey, final Traversal<?, ?> propertyTraversal) {
- this.variantConverter.addStep(this.variantString, getMethodName(), propertyKey, propertyTraversal);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> has(final String propertyKey) {
- this.variantConverter.addStep(this.variantString, getMethodName(), propertyKey);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> hasNot(final String propertyKey) {
- this.variantConverter.addStep(this.variantString, getMethodName(), propertyKey);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> hasLabel(final String... labels) {
- this.variantConverter.addStep(this.variantString, getMethodName(), labels);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> hasId(final Object... ids) {
- this.variantConverter.addStep(this.variantString, getMethodName(), ids);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> hasKey(final String... keys) {
- this.variantConverter.addStep(this.variantString, getMethodName(), keys);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> hasValue(final Object... values) {
- this.variantConverter.addStep(this.variantString, getMethodName(), values);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> is(final P<E> predicate) {
- this.variantConverter.addStep(this.variantString, getMethodName(), predicate);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> is(final Object value) {
- this.variantConverter.addStep(this.variantString, getMethodName(), value);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> not(final Traversal<?, ?> notTraversal) {
- this.variantConverter.addStep(this.variantString, getMethodName(), notTraversal);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> coin(final double probability) {
- this.variantConverter.addStep(this.variantString, getMethodName(), probability);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> range(final long low, final long high) {
- this.variantConverter.addStep(this.variantString, getMethodName(), low, high);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> range(final Scope scope, final long low, final long high) {
- this.variantConverter.addStep(this.variantString, getMethodName(), scope, low, high);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> limit(final long limit) {
- this.variantConverter.addStep(this.variantString, getMethodName(), limit);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> limit(final Scope scope, final long limit) {
- this.variantConverter.addStep(this.variantString, getMethodName(), scope, limit);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> tail() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> tail(final long limit) {
- this.variantConverter.addStep(this.variantString, getMethodName(), limit);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> tail(final Scope scope) {
- this.variantConverter.addStep(this.variantString, getMethodName(), scope);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> tail(final Scope scope, final long limit) {
- this.variantConverter.addStep(this.variantString, getMethodName(), scope, limit);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> timeLimit(final long timeLimit) {
- this.variantConverter.addStep(this.variantString, getMethodName(), timeLimit);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> simplePath() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> cyclicPath() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> sample(final int amountToSample) {
- this.variantConverter.addStep(this.variantString, getMethodName(), amountToSample);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> sample(final Scope scope, final int amountToSample) {
- this.variantConverter.addStep(this.variantString, getMethodName(), scope, amountToSample);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> drop() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- ///////////////////// SIDE-EFFECT STEPS /////////////////////
-
- public GraphTraversal<S, E> sideEffect(final Consumer<Traverser<E>> consumer) {
- this.variantConverter.addStep(this.variantString, getMethodName(), consumer);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> sideEffect(final Traversal<?, ?> sideEffectTraversal) {
- this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectTraversal);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> cap(final String sideEffectKey, final String... sideEffectKeys) {
- this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey, sideEffectKeys);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, Edge> subgraph(final String sideEffectKey) {
- this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> aggregate(final String sideEffectKey) {
- this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> group(final String sideEffectKey) {
- this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> groupV3d0(final String sideEffectKey) {
- this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> groupCount(final String sideEffectKey) {
- this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> tree(final String sideEffectKey) {
- this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey);
- return (GraphTraversal) this;
- }
-
- public <V, U> GraphTraversal<S, E> sack(final BiFunction<V, U, V> sackOperator) {
- this.variantConverter.addStep(this.variantString, getMethodName(), sackOperator);
- return (GraphTraversal) this;
- }
-
-
- @Deprecated
- public <V, U> GraphTraversal<S, E> sack(final BiFunction<V, U, V> sackOperator, final String elementPropertyKey) {
- this.variantConverter.addStep(this.variantString, getMethodName(), sackOperator, elementPropertyKey);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> store(final String sideEffectKey) {
- this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> profile(final String sideEffectKey) {
- this.variantConverter.addStep(this.variantString, getMethodName(), sideEffectKey);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> property(final VertexProperty.Cardinality cardinality, final Object key, final Object value, final Object... keyValues) {
- this.variantConverter.addStep(this.variantString, getMethodName(), cardinality, key, value, keyValues);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> property(final Object key, final Object value, final Object... keyValues) {
- this.variantConverter.addStep(this.variantString, getMethodName(), key, value, keyValues);
- return (GraphTraversal) this;
- }
-
- ///////////////////// BRANCH STEPS /////////////////////
-
- public <M, E2> GraphTraversal<S, E2> branch(final Traversal<?, M> branchTraversal) {
- this.variantConverter.addStep(this.variantString, getMethodName(), branchTraversal);
- return (GraphTraversal) this;
- }
-
- public <M, E2> GraphTraversal<S, E2> branch(final Function<Traverser<E>, M> function) {
- this.variantConverter.addStep(this.variantString, getMethodName(), function);
- return (GraphTraversal) this;
- }
-
- public <M, E2> GraphTraversal<S, E2> choose(final Traversal<?, M> choiceTraversal) {
- this.variantConverter.addStep(this.variantString, getMethodName(), choiceTraversal);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> choose(final Traversal<?, ?> traversalPredicate,
- final Traversal<?, E2> trueChoice, final Traversal<?, E2> falseChoice) {
- this.variantConverter.addStep(this.variantString, getMethodName(), traversalPredicate, trueChoice, falseChoice);
- return (GraphTraversal) this;
- }
-
- public <M, E2> GraphTraversal<S, E2> choose(final Function<E, M> choiceFunction) {
- this.variantConverter.addStep(this.variantString, getMethodName(), choiceFunction);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> choose(final Predicate<E> choosePredicate,
- final Traversal<?, E2> trueChoice, final Traversal<?, E2> falseChoice) {
- this.variantConverter.addStep(this.variantString, getMethodName(), choosePredicate, trueChoice, falseChoice);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> optional(final Traversal<?, E2> optionalTraversal) {
- this.variantConverter.addStep(this.variantString, getMethodName(), optionalTraversal);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> union(final Traversal<?, E2>... unionTraversals) {
- this.variantConverter.addStep(this.variantString, getMethodName(), unionTraversals);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> coalesce(final Traversal<?, E2>... coalesceTraversals) {
- this.variantConverter.addStep(this.variantString, getMethodName(), coalesceTraversals);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> repeat(final Traversal<?, E> repeatTraversal) {
- this.variantConverter.addStep(this.variantString, getMethodName(), repeatTraversal);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> emit(final Traversal<?, ?> emitTraversal) {
- this.variantConverter.addStep(this.variantString, getMethodName(), emitTraversal);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> emit(final Predicate<Traverser<E>> emitPredicate) {
- this.variantConverter.addStep(this.variantString, getMethodName(), emitPredicate);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> emit() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> until(final Traversal<?, ?> untilTraversal) {
- this.variantConverter.addStep(this.variantString, getMethodName(), untilTraversal);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> until(final Predicate<Traverser<E>> untilPredicate) {
- this.variantConverter.addStep(this.variantString, getMethodName(), untilPredicate);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> times(final int maxLoops) {
- this.variantConverter.addStep(this.variantString, getMethodName(), maxLoops);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E2> local(final Traversal<?, E2> localTraversal) {
- this.variantConverter.addStep(this.variantString, getMethodName(), localTraversal);
- return (GraphTraversal) this;
- }
-
- /////////////////// VERTEX PROGRAM STEPS ////////////////
-
- public GraphTraversal<S, E> pageRank() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> pageRank(final double alpha) {
- this.variantConverter.addStep(this.variantString, getMethodName(), alpha);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> peerPressure() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> program(final VertexProgram<?> vertexProgram) {
- this.variantConverter.addStep(this.variantString, getMethodName(), vertexProgram);
- return (GraphTraversal) this;
- }
-
- ///////////////////// UTILITY STEPS /////////////////////
-
- public GraphTraversal<S, E> as(final String stepLabel, final String... stepLabels) {
- this.variantConverter.addStep(this.variantString, getMethodName(), stepLabel, stepLabels);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> barrier() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> barrier(final int maxBarrierSize) {
- this.variantConverter.addStep(this.variantString, getMethodName(), maxBarrierSize);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> barrier(final Consumer<TraverserSet<Object>> barrierConsumer) {
- this.variantConverter.addStep(this.variantString, getMethodName(), barrierConsumer);
- return (GraphTraversal) this;
- }
-
-
- //// BY-MODULATORS
-
- public GraphTraversal<S, E> by() {
- this.variantConverter.addStep(this.variantString, getMethodName());
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> by(final Traversal<?, ?> traversal) {
- this.variantConverter.addStep(this.variantString, getMethodName(), traversal);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> by(final T token) {
- this.variantConverter.addStep(this.variantString, getMethodName(), token);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> by(final String key) {
- this.variantConverter.addStep(this.variantString, getMethodName(), key);
- return (GraphTraversal) this;
- }
-
- public <V> GraphTraversal<S, E> by(final Function<V, Object> function) {
- this.variantConverter.addStep(this.variantString, getMethodName(), function);
- return (GraphTraversal) this;
- }
-
- //// COMPARATOR BY-MODULATORS
-
- public <V> GraphTraversal<S, E> by(final Traversal<?, ?> traversal, final Comparator<V> comparator) {
- this.variantConverter.addStep(this.variantString, getMethodName(), traversal, comparator);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> by(final Comparator<E> comparator) {
- this.variantConverter.addStep(this.variantString, getMethodName(), comparator);
- return (GraphTraversal) this;
- }
-
- public GraphTraversal<S, E> by(final Order order) {
- this.variantConverter.addStep(this.variantString, getMethodName(), order);
- return (GraphTraversal) this;
- }
-
- public <V> GraphTraversal<S, E> by(final String key, final Comparator<V> comparator) {
- this.variantConverter.addStep(this.variantString, getMethodName(), key, comparator);
- return (GraphTraversal) this;
- }
-
- public <U> GraphTraversal<S, E> by(final Function<U, Object> function, final Comparator comparator) {
- this.variantConverter.addStep(this.variantString, getMethodName(), function, comparator);
- return (GraphTraversal) this;
- }
-
- ////
-
- public <M, E2> GraphTraversal<S, E> option(final M pickToken, final Traversal<E, E2> traversalOption) {
- this.variantConverter.addStep(this.variantString, getMethodName(), pickToken, traversalOption);
- return (GraphTraversal) this;
- }
-
- public <E2> GraphTraversal<S, E> option(final Traversal<E, E2> traversalOption) {
- this.variantConverter.addStep(this.variantString, getMethodName(), traversalOption);
- return (GraphTraversal) this;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/487d992e/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphTraversalSource.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphTraversalSource.java b/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphTraversalSource.java
deleted file mode 100644
index 9e4382f..0000000
--- a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphTraversalSource.java
+++ /dev/null
@@ -1,219 +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.variant;
-
-import org.apache.tinkerpop.gremlin.process.computer.Computer;
-import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.AddVertexStartStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Transaction;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-
-import java.util.function.BinaryOperator;
-import java.util.function.Supplier;
-import java.util.function.UnaryOperator;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class VariantGraphTraversalSource extends GraphTraversalSource {
-
- private VariantConverter variantConverter;
- private StringBuilder sourceString = new StringBuilder("g");
-
- public VariantGraphTraversalSource(final VariantConverter variantConverter, final Graph graph, final TraversalStrategies traversalStrategies) {
- super(graph, traversalStrategies);
- this.variantConverter = variantConverter;
- }
-
- private static String getMethodName() {
- return Thread.currentThread().getStackTrace()[2].getMethodName();
- }
-
- ///
-
- @Override
- public GraphTraversal<Edge, Edge> E(final Object... edgeIds) {
- final StringBuilder temp = new StringBuilder(this.sourceString.toString());
- this.variantConverter.addStep(temp, getMethodName(), edgeIds);
- return new VariantGraphTraversal<>(this.getGraph(), temp, this.variantConverter);
- }
-
- @Override
- public GraphTraversal<Vertex, Vertex> V(final Object... vertexIds) {
- final StringBuilder temp = new StringBuilder(this.sourceString.toString());
- this.variantConverter.addStep(temp, getMethodName(), vertexIds);
- return new VariantGraphTraversal<>(this.getGraph(), temp, this.variantConverter);
- }
-
- @Deprecated
- public GraphTraversal<Vertex, Vertex> addV(final Object... keyValues) {
- final StringBuilder temp = new StringBuilder(this.sourceString.toString());
- this.variantConverter.addStep(temp, getMethodName(), keyValues);
- return new VariantGraphTraversal<>(this.getGraph(), temp, this.variantConverter);
- }
-
- public GraphTraversal<Vertex, Vertex> addV(final String label) {
- final StringBuilder temp = new StringBuilder(this.sourceString.toString());
- this.variantConverter.addStep(temp, getMethodName(), label);
- return new VariantGraphTraversal<>(this.getGraph(), temp, this.variantConverter);
- }
-
- public GraphTraversal<Vertex, Vertex> addV() {
- final StringBuilder temp = new StringBuilder(this.sourceString.toString());
- this.variantConverter.addStep(temp, getMethodName());
- return new VariantGraphTraversal<>(this.getGraph(), temp, this.variantConverter);
- }
-
- public <S> GraphTraversal<S, S> inject(S... starts) {
- final StringBuilder temp = new StringBuilder(this.sourceString.toString());
- this.variantConverter.addStep(temp, getMethodName(), starts);
- return new VariantGraphTraversal<>(this.getGraph(), temp, this.variantConverter);
- }
-
- ///
-
- @Override
- public GraphTraversalSource withComputer(final Computer computer) {
- this.variantConverter.addStep(this.sourceString, getMethodName(), computer);
- return this;
- }
-
- @Override
- public GraphTraversalSource withComputer(final Class<? extends GraphComputer> graphComputerClass) {
- this.variantConverter.addStep(this.sourceString, getMethodName(), graphComputerClass);
- return this;
- }
-
- @Override
- public GraphTraversalSource withComputer() {
- this.variantConverter.addStep(this.sourceString, getMethodName());
- return this;
- }
-
- @Override
- public GraphTraversalSource withStrategies(final TraversalStrategy... traversalStrategies) {
- return super.withStrategies(traversalStrategies);
- //this.variantConverter.addStep(this.sourceString, getMethodName(), traversalStrategies);
- //return this;
- }
-
- @Override
- @SuppressWarnings({"unchecked", "varargs"})
- public GraphTraversalSource withoutStrategies(final Class<? extends TraversalStrategy>... traversalStrategyClasses) {
- this.variantConverter.addStep(this.sourceString, getMethodName(), traversalStrategyClasses);
- return this;
- }
-
- @Override
- public <A> GraphTraversalSource withSack(final Supplier<A> initialValue, final UnaryOperator<A> splitOperator, final BinaryOperator<A> mergeOperator) {
- this.variantConverter.addStep(this.sourceString, getMethodName(), splitOperator, mergeOperator);
- return this;
- }
-
- @Override
- public <A> GraphTraversalSource withSack(final A initialValue, final UnaryOperator<A> splitOperator, final BinaryOperator<A> mergeOperator) {
- this.variantConverter.addStep(this.sourceString, getMethodName(), initialValue, splitOperator, mergeOperator);
- return this;
- }
-
- @Override
- public <A> GraphTraversalSource withSack(final A initialValue) {
- this.variantConverter.addStep(this.sourceString, getMethodName(), initialValue);
- return this;
- }
-
- @Override
- public <A> GraphTraversalSource withSack(final Supplier<A> initialValue) {
- this.variantConverter.addStep(this.sourceString, getMethodName(), initialValue);
- return this;
- }
-
- @Override
- public <A> GraphTraversalSource withSack(final Supplier<A> initialValue, final UnaryOperator<A> splitOperator) {
- this.variantConverter.addStep(this.sourceString, getMethodName(), initialValue, splitOperator);
- return this;
- }
-
- @Override
- public <A> GraphTraversalSource withSack(final A initialValue, final UnaryOperator<A> splitOperator) {
- this.variantConverter.addStep(this.sourceString, getMethodName(), initialValue, splitOperator);
- return this;
- }
-
- @Override
- public <A> GraphTraversalSource withSack(final Supplier<A> initialValue, final BinaryOperator<A> mergeOperator) {
- this.variantConverter.addStep(this.sourceString, getMethodName(), initialValue, mergeOperator);
- return this;
- }
-
- @Override
- public <A> GraphTraversalSource withSack(final A initialValue, final BinaryOperator<A> mergeOperator) {
- this.variantConverter.addStep(this.sourceString, getMethodName(), initialValue, mergeOperator);
- return this;
- }
-
- /////
-
- @Override
- public <A> GraphTraversalSource withSideEffect(final String key, final Supplier<A> initialValue, final BinaryOperator<A> reducer) {
- this.variantConverter.addStep(this.sourceString, getMethodName(), key, initialValue, reducer);
- return this;
- }
-
- @Override
- public <A> GraphTraversalSource withSideEffect(final String key, final A initialValue, final BinaryOperator<A> reducer) {
- this.variantConverter.addStep(this.sourceString, getMethodName(), key, initialValue, reducer);
- return this;
- }
-
- @Override
- public <A> GraphTraversalSource withSideEffect(final String key, final A initialValue) {
- this.variantConverter.addStep(this.sourceString, getMethodName(), key, initialValue);
- return this;
- }
-
- @Override
- public <A> GraphTraversalSource withSideEffect(final String key, final Supplier<A> initialValue) {
- this.variantConverter.addStep(this.sourceString, getMethodName(), key, initialValue);
- return this;
- }
-
- /////
-
- @Override
- public GraphTraversalSource withBulk(final boolean useBulk) {
- this.variantConverter.addStep(this.sourceString, getMethodName(), useBulk);
- return this;
- }
-
- @Override
- public GraphTraversalSource withPath() {
- this.variantConverter.addStep(this.sourceString, getMethodName());
- return this;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/487d992e/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonVariantConverter.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonVariantConverter.java b/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonVariantConverter.java
deleted file mode 100644
index 879a14c..0000000
--- a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonVariantConverter.java
+++ /dev/null
@@ -1,160 +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.variant.python;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Operator;
-import org.apache.tinkerpop.gremlin.process.traversal.Order;
-import org.apache.tinkerpop.gremlin.process.traversal.P;
-import org.apache.tinkerpop.gremlin.process.traversal.Pop;
-import org.apache.tinkerpop.gremlin.process.traversal.SackFunctions;
-import org.apache.tinkerpop.gremlin.process.traversal.Scope;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.VerificationException;
-import org.apache.tinkerpop.gremlin.process.traversal.util.EmptyTraversal;
-import org.apache.tinkerpop.gremlin.process.variant.VariantConverter;
-import org.apache.tinkerpop.gremlin.process.variant.VariantGraphTraversal;
-import org.apache.tinkerpop.gremlin.structure.Column;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Element;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
-import org.apache.tinkerpop.gremlin.util.iterator.ArrayIterator;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
-
-import javax.script.Bindings;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import javax.script.SimpleBindings;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Stream;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class PythonVariantConverter implements VariantConverter {
-
- private static ScriptEngine JYTHON_ENGINE = ScriptEngineCache.get("jython");
-
- static {
- try {
- GremlinPythonGenerator.create("/tmp");
- JYTHON_ENGINE.eval("execfile(\"/tmp/gremlin-python-3.2.1-SNAPSHOT.py\")");
- } catch (final ScriptException e) {
- throw new IllegalStateException(e.getMessage(), e);
- }
- }
-
- private static final Set<String> PREFIX_NAMES = new HashSet<>(Arrays.asList("as", "in", "and", "or", "is", "not", "from"));
-
- @Override
- public String generateGremlinGroovy(final StringBuilder currentTraversal) throws ScriptException {
- if (currentTraversal.toString().contains("$") || currentTraversal.toString().contains("@"))
- throw new VerificationException("Lambdas are currently not supported: " + currentTraversal.toString(), EmptyTraversal.instance());
-
- final Bindings jythonBindings = new SimpleBindings();
- jythonBindings.put("g", JYTHON_ENGINE.eval("PythonGraphTraversalSource(\"g\")"));
- JYTHON_ENGINE.getContext().setBindings(jythonBindings, ScriptContext.GLOBAL_SCOPE);
- return JYTHON_ENGINE.eval(currentTraversal.toString()).toString();
- }
-
- @Override
- public void addStep(final StringBuilder currentTraversal, final String stepName, final Object... arguments) {
- // flatten the arguments into a single array
- final Object[] objects = Stream.of(arguments)
- .flatMap(arg ->
- IteratorUtils.stream(arg instanceof Object[] ?
- new ArrayIterator<>((Object[]) arg) :
- IteratorUtils.of(arg)))
- .toArray();
- if (objects.length == 0)
- currentTraversal.append(".").append(convertStepName(stepName)).append("()");
- else if (stepName.equals("range") && 2 == objects.length)
- currentTraversal.append("[").append(objects[0]).append(":").append(objects[1]).append("]");
- else if (stepName.equals("limit") && 1 == objects.length)
- currentTraversal.append("[0:").append(objects[0]).append("]");
- else if (stepName.equals("values") && 1 == objects.length && !currentTraversal.toString().equals("__"))
- currentTraversal.append(".").append(objects[0]);
- else {
- String temp = "." + convertStepName(stepName) + "(";
- for (final Object object : objects) {
-
- temp = temp + convertToString(object) + ",";
-
- }
- currentTraversal.append(temp.substring(0, temp.length() - 1) + ")");
- }
- }
-
- private static String convertToString(final Object object) {
- if (object instanceof String)
- return "\"" + object + "\"";
- else if (object instanceof List) {
- final List list = new ArrayList<>(((List) object).size());
- for (final Object item : (List) object) {
- list.add(item instanceof String ? "'" + item + "'" : convertToString(item)); // hack
- }
- return list.toString();
- } else if (object instanceof Long)
- return object + "L";
- else if (object instanceof Class)
- return ((Class) object).getCanonicalName();
- else if (object instanceof SackFunctions.Barrier)
- return "Barrier." + object.toString();
- else if (object instanceof VertexProperty.Cardinality)
- return "Cardinality." + object.toString();
- else if (object instanceof Direction)
- return "Direction." + object.toString();
- else if (object instanceof Operator)
- return ((object == Operator.and || object == Operator.or) ? "Operator._" : "Operator.") + object.toString();
- else if (object instanceof Pop)
- return "Pop." + object.toString();
- else if (object instanceof Column)
- return "Column." + object.toString();
- else if (object instanceof P)
- return "P." + ((P) object).getBiPredicate() + "(" + (((P) object).getValue() instanceof String ? "'" + ((P) object).getValue() + "'" : convertToString(((P) object).getValue())) + ")";
- else if (object instanceof T)
- return "T." + object.toString();
- else if (object instanceof Order)
- return "Order." + object.toString();
- else if (object instanceof Scope)
- return "Scope._" + object.toString();
- else if (object instanceof Element)
- return convertToString(((Element) object).id()); // hack
- else if (object instanceof VariantGraphTraversal)
- return ((VariantGraphTraversal) object).getVariantString().toString();
- else if (object instanceof Boolean)
- return object.equals(Boolean.TRUE) ? "True" : "False";
- else
- return null == object ? "" : object.toString();
- }
-
- private static String convertStepName(final String stepName) {
- if (PREFIX_NAMES.contains(stepName))
- return "_" + stepName;
- else
- return stepName;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/487d992e/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/VariantConverter.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/VariantConverter.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/VariantConverter.java
new file mode 100644
index 0000000..110a1ef
--- /dev/null
+++ b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/VariantConverter.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.variant;
+
+import javax.script.ScriptException;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface VariantConverter {
+
+ public void addStep(final StringBuilder currentTraversal, final String stepName, final Object... arguments);
+
+ public String generateGremlinGroovy(final StringBuilder currentTraversal) throws ScriptException;
+}