Search in sources :

Example 1 with WindowedValueCoderComponents

use of org.apache.beam.runners.core.construction.ModelCoders.WindowedValueCoderComponents in project beam by apache.

the class ModelCodersTest method windowedValueCoderComponentsToConstructor.

@Test
public void windowedValueCoderComponentsToConstructor() throws IOException {
    FullWindowedValueCoder<Iterable<KV<String, Integer>>> javaCoder = FullWindowedValueCoder.of(IterableCoder.of(KvCoder.of(StringUtf8Coder.of(), VarIntCoder.of())), IntervalWindowCoder.of());
    MessageWithComponents coderAndComponents = CoderTranslation.toProto(javaCoder);
    WindowedValueCoderComponents windowedValueCoderComponents = ModelCoders.getWindowedValueCoderComponents(coderAndComponents.getCoder());
    Coder windowedCoder = ModelCoders.windowedValueCoder(windowedValueCoderComponents.elementCoderId(), windowedValueCoderComponents.windowCoderId());
    assertThat(windowedCoder, equalTo(coderAndComponents.getCoder()));
}
Also used : WindowedValueCoderComponents(org.apache.beam.runners.core.construction.ModelCoders.WindowedValueCoderComponents) KvCoder(org.apache.beam.sdk.coders.KvCoder) Coder(org.apache.beam.model.pipeline.v1.RunnerApi.Coder) IterableCoder(org.apache.beam.sdk.coders.IterableCoder) FullWindowedValueCoder(org.apache.beam.sdk.util.WindowedValue.FullWindowedValueCoder) VarLongCoder(org.apache.beam.sdk.coders.VarLongCoder) StringUtf8Coder(org.apache.beam.sdk.coders.StringUtf8Coder) ByteArrayCoder(org.apache.beam.sdk.coders.ByteArrayCoder) VarIntCoder(org.apache.beam.sdk.coders.VarIntCoder) IntervalWindowCoder(org.apache.beam.sdk.transforms.windowing.IntervalWindow.IntervalWindowCoder) LengthPrefixCoder(org.apache.beam.sdk.coders.LengthPrefixCoder) MessageWithComponents(org.apache.beam.model.pipeline.v1.RunnerApi.MessageWithComponents) Test(org.junit.Test)

Aggregations

Coder (org.apache.beam.model.pipeline.v1.RunnerApi.Coder)1 MessageWithComponents (org.apache.beam.model.pipeline.v1.RunnerApi.MessageWithComponents)1 WindowedValueCoderComponents (org.apache.beam.runners.core.construction.ModelCoders.WindowedValueCoderComponents)1 ByteArrayCoder (org.apache.beam.sdk.coders.ByteArrayCoder)1 IterableCoder (org.apache.beam.sdk.coders.IterableCoder)1 KvCoder (org.apache.beam.sdk.coders.KvCoder)1 LengthPrefixCoder (org.apache.beam.sdk.coders.LengthPrefixCoder)1 StringUtf8Coder (org.apache.beam.sdk.coders.StringUtf8Coder)1 VarIntCoder (org.apache.beam.sdk.coders.VarIntCoder)1 VarLongCoder (org.apache.beam.sdk.coders.VarLongCoder)1 IntervalWindowCoder (org.apache.beam.sdk.transforms.windowing.IntervalWindow.IntervalWindowCoder)1 FullWindowedValueCoder (org.apache.beam.sdk.util.WindowedValue.FullWindowedValueCoder)1 Test (org.junit.Test)1