Skip to content

Split Merge Pattern

jbmusso edited this page Jul 11, 2016 · 5 revisions

Attention: this Wiki hosts an outdated version of the TinkerPop framework and Gremlin language documentation.


Most Gremlin pipelines are serial in that one step feeds to the next, so on and so forth. There are situations where it is desirable to split a pipeline and thus, have n-parallel steps that are later merged back into a serial flow. To support this type of traversal, there are split and merge steps.

  • Split
    • copySplit: copy the incoming object to each pipeline
  • Merge
    • fairMerge: merge the parallel traversals in a round-robin fashion
    • exhaustMerge: merge the parallel traversals by exhaustively getting the objects of the first, then the second, etc.
gremlin> g.v(1).out('knows').copySplit(_().out('created').name, _().age).fairMerge
==>ripple
==>27
==>lop
==>32
gremlin> g.v(1).out('knows').copySplit(_().out('created').name, _().age).exhaustMerge
==>ripple
==>lop
==>27
==>32

A useful representation of the the split/merge pattern is as follows.

g.v(1).out('knows').copySplit(
   _().out('created').name,
   _().age
).fairMerge