Skip to content

Instantly share code, notes, and snippets.

@davideanastasia
Created June 5, 2018 22:34
Show Gist options
  • Save davideanastasia/ae58b2bb74ffa2c340945c3846870931 to your computer and use it in GitHub Desktop.
Save davideanastasia/ae58b2bb74ffa2c340945c3846870931 to your computer and use it in GitHub Desktop.
Apache Beam Getting Started - #4
public class ReduceFn extends Combine.CombineFn<Metadata, Index, Index> {
@Override
public Index createAccumulator() {
return new Index();
}
@Override
public Index addInput(Index accumulator, Metadata input) {
accumulator.add(input);
return accumulator;
}
@Override
public Index mergeAccumulators(Iterable<Index> accumulators) {
Index accum = new Index();
for (Index currentAccum : accumulators) {
accum.add(currentAccum);
}
return accum;
}
@Override
public Index extractOutput(Index accumulator) {
return accumulator;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment