Skip to content

Gremlin Steps

okram edited this page Aug 31, 2012 · 23 revisions

Gremlin is a graph traversal language developed by TinkerPop. Faunus, as of the current release, provides a subset of the Gremlin steps. For sake of clarity, the Gremlin that compiles down to Pipes and is used for real-time traversals against a graph database is denoted Gremlin/Pipes. The Gremlin that is distributed with Faunus and compiles down to MapReduce is denoted Gremlin/Faunus.

There are major conceptual differences between Gremlin/Pipes and Gremlin/Faunus. These differences are itemized below.

  • Gremlin/Faunus is breadth-first. Gremlin/Pipes is depth-first.
  • Gremlin/Faunus processes rows of an adjacency matrix (vertex-centric). Gremlin/Pipes processes elements in a linked-list (element-centric).
  • Gremlin/Faunus is inherently parallel with each vertex being operated on simultaneously. Gremlin/Pipes is inherently serial with one element at a time being pushed through the pipeline.

The table below presents the steps provided with Gremlin/Faunus.

Gremlin/Faunus step Description Reduce?
transforms
_() the identity step that simply updates Hadoop counters false
transform(closure) call the closure with current elements as argument false
V() start a traversal at all vertices false
E() start a traversal at all edges false
v(id..) start a traversal a some vertices false
out(labels..) traverse out from current vertices to label-related vertices true
in(labels..) traverse in from current vertices to label-related vertices true
outE(labels..) traverse from current vertices to outgoing label edges true
inE(labels..) traverse from current vertices to incoming label edges true
outV() traverse from current edges to outgoing vertices false
inV() traverse from current edges to incoming vertices false
property(key,class?) emit the the property value of current elements (specify class? for optimization) false
path() emit the path taken up to the current elements false
order(order,key) order the previous properties and identify element by key true
filters
filter(closure) A generic filter that takes a boolean-closure false
has(key,values..) filter elements that don’t have key/value property (values or’d) false
has(key,compare,values..) filter elements that don’t have compared key/value property (values or’d) false
hasNot(key,values..) filter elements that do have key/value property (values or’d) false
hasNot(key,compare,values..) filter elements that do have compared key/value property (values or’d) false
interval(key,value1,value2) filter elements that don’t have value in range false
dedup() remove any duplicates in current traversal step false
back(step) go back to elements seen previous true
side-effects
sideEffect(closure) mutate the current element according to the provided closure false
as(name) name the previous step for future reference false
linkOut(step,label,key?) project an outgoing edge to a previous vertex with provided key being an optional weight true
linkIn(step,label,key?) project an incoming edge to a previous vertex with provided key being an optional weight true
keep() remove all elements not at current step (of current type) true/false
drop() remove all elements at current step (of current type) true/false
groupCount() count the number of previously specified properties true
groupCount(closure,closure) process current elements with closure and incr count with closure true
Clone this wiki locally