Skip to content

Gremlin Steps

okram edited this page Aug 28, 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. Gremlin/Pipes processes elements in a linked-list.
  • Gremlin/Faunus is inherently parallel with each vertex being operated on simultaneously. Gremlin is inherently serial with one element at a time being pushed through the pipeline.

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

Gremlin/Faunus step Description Reduce?
_() the identity step that simply updates Hadoop counters false
filters
filter(class,closure) g.V.filter{closure}.sideEffect{g.removeVertex(it)}
propertyFilter(class,key,compare,value) g.V.has(key,compare,value).sideEffect{g.removeVertex(it)}
directionFilter(direction) no equivalent as this is a Faunus-specific optimization
labelFilter(action,labels) g.E.filter{labels.contains(it.label)}.sideEffect{g.removeEdge(it)}
loopFilter(action,labels) g.E.filter{it.inV == it.outV}.sideEffect{g.removeEdge(it)}
side-effects
sideEffect(class,closure) g.V.sideEffect{closure}
properties(class,action,keys) g.V.sideEffect{v -> keys.each{v.removeProperty(it)}}
transpose(label1,label2,action) g.E.has('label',label1).sideEffect{g.addEdge(it.inV,it.outV,label2)}
traverse(direction,label1,direction,label2,label3,action) g.V.sideEffect{x=it}.out(label).out(label).sideEffect{g.addEdge(x,it,label)}
Clone this wiki locally