use of org.apache.beam.sdk.coders.StringUtf8Coder 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);
}
use of org.apache.beam.sdk.coders.StringUtf8Coder in project beam by apache.
the class LocalDeserializerProviderTest method testInferKeyCoder.
@Test
public void testInferKeyCoder() {
CoderRegistry registry = CoderRegistry.createDefault();
assertTrue(LocalDeserializerProvider.of(LongDeserializer.class).getCoder(registry).getValueCoder() instanceof VarLongCoder);
assertTrue(LocalDeserializerProvider.of(StringDeserializer.class).getCoder(registry).getValueCoder() instanceof StringUtf8Coder);
assertTrue(LocalDeserializerProvider.of(InstantDeserializer.class).getCoder(registry).getValueCoder() instanceof InstantCoder);
assertTrue(LocalDeserializerProvider.of(DeserializerWithInterfaces.class).getCoder(registry).getValueCoder() instanceof VarLongCoder);
}
Aggregations