use of org.apache.beam.sdk.transforms.CombineWithContext.Context in project beam by apache.
the class CombineFnUtilTest method testToFnWithContext.
@Test
public void testToFnWithContext() throws Exception {
CombineFnWithContext<Integer, int[], Integer> fnWithContext = CombineFnUtil.toFnWithContext(Sum.ofIntegers());
List<Integer> inputs = ImmutableList.of(1, 2, 3, 4);
Context nullContext = CombineContextFactory.nullContext();
int[] accum = fnWithContext.createAccumulator(nullContext);
for (Integer i : inputs) {
accum = fnWithContext.addInput(accum, i, nullContext);
}
assertEquals(10, fnWithContext.extractOutput(accum, nullContext).intValue());
}
Aggregations