Skip to content
ahzf edited this page Feb 23, 2011 · 3 revisions

A Pipeline<S, E> is a commonly used IPipe<S, E>, but also a pipe that “wraps” another pipe or multiple sequential pipes. For this a pipeline takes an ordered list of pipes in its constructor. At runtime it connects these pipes, whereby the input of pipe n is connected to the output of pipe n-1. Note that the output type of pipe n-1 must be the same type as the input to pipe n and this is again checked at runtime. This idea is elucidated in the following diagram.

The benefit of using Pipelines is that it greatly reduces the complexity of a process and allows for easy reuse even in recursive ways. It is analogous, in many ways, to creating a function to wrap a body of code/instructions. As such, the function serves as a blackbox with input and output.

The following piece of code shows a example how to create a pipeline:

var _Pipe1    = new VertexEdgePipe(VertexEdgePipe.Step.OUT_EDGES);
var _Pipe2    = new LabelFilterPipe("knows", ComparisonFilter.NOT_EQUAL);
var _Pipe3    = new EdgeVertexPipe(EdgeVertexPipe.Step.IN_VERTEX);
var _Pipe4    = new VertexPropertyPipe<String>("name");
var _Pipeline = new Pipeline<IVertex,String>(_Pipe1, _Pipe2, _Pipe3, _Pipe4);
_Pipeline.SetSource(new SingleEnumerator<IVertex>(_Graph.GetVertex(new VertexId(1)));

_Pipeline.ForEach(_Friend => Console.WriteLine(_Friend));
Sideeffect Pipes home Transformation Paths