Search in sources :

Example 1 with Materialization

use of org.apache.beam.sdk.transforms.Materialization in project beam by apache.

the class PTransformMatchersTest method createViewWithViewFnDifferentViewFn.

@Test
public void createViewWithViewFnDifferentViewFn() {
    PCollection<Integer> input = p.apply(Create.of(1));
    PCollectionView<Iterable<Integer>> view = PCollectionViews.iterableView(input, input.getWindowingStrategy(), input.getCoder());
    ViewFn<Iterable<WindowedValue<?>>, Iterable<Integer>> viewFn = new ViewFn<Iterable<WindowedValue<?>>, Iterable<Integer>>() {

        @Override
        public Materialization<Iterable<WindowedValue<?>>> getMaterialization() {
            @SuppressWarnings({ "rawtypes", "unchecked" }) Materialization<Iterable<WindowedValue<?>>> materialization = (Materialization) Materializations.iterable();
            return materialization;
        }

        @Override
        public Iterable<Integer> apply(Iterable<WindowedValue<?>> contents) {
            return Collections.emptyList();
        }
    };
    CreatePCollectionView<?, ?> createView = CreatePCollectionView.of(view);
    PTransformMatcher matcher = PTransformMatchers.createViewWithViewFn(viewFn.getClass());
    assertThat(matcher.matches(getAppliedTransform(createView)), is(false));
}
Also used : Materialization(org.apache.beam.sdk.transforms.Materialization) PTransformMatcher(org.apache.beam.sdk.runners.PTransformMatcher) ViewFn(org.apache.beam.sdk.transforms.ViewFn) WindowedValue(org.apache.beam.sdk.util.WindowedValue) Test(org.junit.Test)

Aggregations

PTransformMatcher (org.apache.beam.sdk.runners.PTransformMatcher)1 Materialization (org.apache.beam.sdk.transforms.Materialization)1 ViewFn (org.apache.beam.sdk.transforms.ViewFn)1 WindowedValue (org.apache.beam.sdk.util.WindowedValue)1 Test (org.junit.Test)1