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 fashionexhaustMerge
: merge the parallel traversals by exhaustively getting the objects of the first, then the second, etc.
```text
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.
```text
g.v(1).out(‘knows’).copySplit(
_().out(‘created’).name,
_().age
).fairMerge
```