Search in sources :

Example 1 with OnTimerMethod

use of org.apache.beam.sdk.transforms.reflect.DoFnSignature.OnTimerMethod in project beam by apache.

the class ParDo method validateWindowType.

/**
   * Perform common validations of the {@link DoFn} against the input {@link PCollection}, for
   * example ensuring that the window type expected by the {@link DoFn} matches the window type of
   * the {@link PCollection}.
   */
private static <InputT, OutputT> void validateWindowType(PCollection<? extends InputT> input, DoFn<InputT, OutputT> fn) {
    DoFnSignature signature = DoFnSignatures.getSignature((Class) fn.getClass());
    TypeDescriptor<? extends BoundedWindow> actualWindowT = input.getWindowingStrategy().getWindowFn().getWindowTypeDescriptor();
    validateWindowTypeForMethod(actualWindowT, signature.processElement());
    for (OnTimerMethod method : signature.onTimerMethods().values()) {
        validateWindowTypeForMethod(actualWindowT, method);
    }
}
Also used : DoFnSignature(org.apache.beam.sdk.transforms.reflect.DoFnSignature) OnTimerMethod(org.apache.beam.sdk.transforms.reflect.DoFnSignature.OnTimerMethod)

Aggregations

DoFnSignature (org.apache.beam.sdk.transforms.reflect.DoFnSignature)1 OnTimerMethod (org.apache.beam.sdk.transforms.reflect.DoFnSignature.OnTimerMethod)1