Skip to content

Gremlin Steps

okram edited this page Aug 29, 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?
_() the identity step that simply updates Hadoop counters false
transforms
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) emit the the property value of current elements false
path() emit the path taken up to the current elements false
filters
filter(closure) A generic filter that takes a boolean-closure false
has(key,value) filter elements that don’t have key/value property false
has(key,compare,value..) filter elements that don’t have compared key/value property false
hasNot(key,value..) filter elements that do have key/value property false
hasNot(key,compare,value..) filter elements that do have compared key/value property 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
linkTo()
linkTo()
keep()
drop()
groupCount()
Clone this wiki locally