Search in sources :

Example 1 with ReadPayload

use of org.apache.beam.model.pipeline.v1.RunnerApi.ReadPayload in project beam by apache.

the class ReadTranslationTest method testToFromProtoUnbounded.

@Test
public void testToFromProtoUnbounded() throws Exception {
    assumeThat(source, instanceOf(UnboundedSource.class));
    UnboundedSource<?, ?> unboundedSource = (UnboundedSource<?, ?>) this.source;
    SplittableParDo.PrimitiveUnboundedRead<?> unboundedRead = new SplittableParDo.PrimitiveUnboundedRead<>(Read.from(unboundedSource));
    // No environment set for unbounded sources
    ReadPayload payload = ReadTranslation.toProto(unboundedRead);
    assertThat(payload.getIsBounded(), equalTo(RunnerApi.IsBounded.Enum.UNBOUNDED));
    UnboundedSource<?, ?> deserializedSource = ReadTranslation.unboundedSourceFromProto(payload);
    assertThat(deserializedSource, equalTo(source));
}
Also used : ReadPayload(org.apache.beam.model.pipeline.v1.RunnerApi.ReadPayload) UnboundedSource(org.apache.beam.sdk.io.UnboundedSource) Test(org.junit.Test)

Example 2 with ReadPayload

use of org.apache.beam.model.pipeline.v1.RunnerApi.ReadPayload in project beam by apache.

the class ReadTranslationTest method testToFromProtoBounded.

@Test
public void testToFromProtoBounded() throws Exception {
    // TODO: Split into two tests.
    assumeThat(source, instanceOf(BoundedSource.class));
    BoundedSource<?> boundedSource = (BoundedSource<?>) this.source;
    SplittableParDo.PrimitiveBoundedRead<?> boundedRead = new SplittableParDo.PrimitiveBoundedRead<>(Read.from(boundedSource));
    ReadPayload payload = ReadTranslation.toProto(boundedRead);
    assertThat(payload.getIsBounded(), equalTo(RunnerApi.IsBounded.Enum.BOUNDED));
    BoundedSource<?> deserializedSource = ReadTranslation.boundedSourceFromProto(payload);
    assertThat(deserializedSource, equalTo(source));
}
Also used : BoundedSource(org.apache.beam.sdk.io.BoundedSource) ReadPayload(org.apache.beam.model.pipeline.v1.RunnerApi.ReadPayload) Test(org.junit.Test)

Aggregations

ReadPayload (org.apache.beam.model.pipeline.v1.RunnerApi.ReadPayload)2 Test (org.junit.Test)2 BoundedSource (org.apache.beam.sdk.io.BoundedSource)1 UnboundedSource (org.apache.beam.sdk.io.UnboundedSource)1