stratosphere/stratosphere — pull request #638 by StephanEwen (2014-03-28 02:01:25+00:00)
Title: First Version of Spargel (Pregel style API) for Java

To get a feel of the api, check out this example (connected components)

```
public class SpargelConnectedComponents {

public static void main(String[] args) throws Exception {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

DataSet vertexIds = env.generateSequence(0, 10);
DataSet> edges = env.fromElements(new Tuple2(0L, 2L), new Tuple2(2L, 4L), new Tuple2(4L, 8L),
new Tuple2(1L, 5L), new Tuple2(3L, 7L), new Tuple2(3L, 9L));

DataSet> initialVertices = vertexIds.map(new IdAssigner());

DataSet> result = initialVertices.runOperation(SpargelIteration.withPlainEdges(edges, new CCUpdater(), new CCMessager(), 100));

result.print();
env.execute("Spargel Connected Components");
}

public static final class CCUpdater extends VertexUpdateFunction {
@Override
public void updateVertex(Long vertexKey, Long vertexValue, MessageIterator inMessages) {
long min = Long.MAX_VALUE;
for (long msg : inMessages) {
min = Math.min(min, msg);
}
if (min < vertexValue) {
setNewVertexValue(min);
}
}
}

public static final class CCMessager extends MessagingFunction {
@Override
public void sendMessages(Long vertexId, Long componentId) {
sendMessageToAllNeighbors(componentId);
}
}

public static final class IdAssigner extends MapFunction> {

@Override
public Tuple2 map(Long value) throws Exception {
return new Tuple2(value, value);
}
}
}
```
From https://github.com/StephanEwen/stratosphere/blob/spargel/stratosphere-addons/spargel/src/main/java/eu/stratosphere/spargel/java/examples/SpargelConnectedComponents.java