Search in sources :

Example 1 with GroupByKeyIterator

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);
}
Also used : WindowedValue(org.apache.beam.sdk.util.WindowedValue) Tuple2(scala.Tuple2) GroupByKeyIterator(org.apache.beam.runners.spark.translation.GroupNonMergingWindowsFunctions.GroupByKeyIterator) StringUtf8Coder(org.apache.beam.sdk.coders.StringUtf8Coder) KV(org.apache.beam.sdk.values.KV)

Aggregations

GroupByKeyIterator (org.apache.beam.runners.spark.translation.GroupNonMergingWindowsFunctions.GroupByKeyIterator)1 StringUtf8Coder (org.apache.beam.sdk.coders.StringUtf8Coder)1 WindowedValue (org.apache.beam.sdk.util.WindowedValue)1 KV (org.apache.beam.sdk.values.KV)1 Tuple2 (scala.Tuple2)1