use of org.apache.beam.runners.spark.translation.GroupNonMergingWindowsFunctions.GroupByKeyIterator in project beam by apache.
the class GroupNonMergingWindowsFunctionsTest method createGbkIterator.
private <W extends BoundedWindow> GroupByKeyIterator<String, Integer, W> createGbkIterator(W window, Coder<W> winCoder, WindowingStrategy<Object, W> winStrategy) throws Coder.NonDeterministicException {
StringUtf8Coder keyCoder = StringUtf8Coder.of();
final WindowedValue.FullWindowedValueCoder<KV<String, Integer>> winValCoder = WindowedValue.getFullCoder(KvCoder.of(StringUtf8Coder.of(), VarIntCoder.of()), winStrategy.getWindowFn().windowCoder());
ItemFactory<String, Integer, W> factory = ItemFactory.forWindow(keyCoder, winValCoder, winCoder, window);
List<Tuple2<ByteArray, byte[]>> items = Arrays.asList(factory.create("k1", 1), factory.create("k1", 2), factory.create("k2", 3), factory.create("k2", 4), factory.create("k2", 5));
return new GroupByKeyIterator<>(items.iterator(), keyCoder, winStrategy, winValCoder);
}
Aggregations