Search in sources :

Example 1 with KvCoderComponents

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

the class ModelCodersTest method kvCoderComponentsToConstructor.

@Test
public void kvCoderComponentsToConstructor() throws IOException {
    KvCoder<byte[], Iterable<Long>> javaCoder = KvCoder.of(ByteArrayCoder.of(), IterableCoder.of(LengthPrefixCoder.of(VarLongCoder.of())));
    MessageWithComponents coderAndComponents = CoderTranslation.toProto(javaCoder);
    KvCoderComponents kvCoderComponents = ModelCoders.getKvCoderComponents(coderAndComponents.getCoder());
    Coder kvCoder = ModelCoders.kvCoder(kvCoderComponents.keyCoderId(), kvCoderComponents.valueCoderId());
    assertThat(kvCoder, equalTo(coderAndComponents.getCoder()));
}
Also used : 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) KvCoderComponents(org.apache.beam.runners.core.construction.ModelCoders.KvCoderComponents) 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 KvCoderComponents (org.apache.beam.runners.core.construction.ModelCoders.KvCoderComponents)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