Search in sources :

Example 1 with SideInputParameter

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

the class ParDo method validateSideInputTypes.

private static void validateSideInputTypes(Map<String, PCollectionView<?>> sideInputs, DoFn<?, ?> fn) {
    DoFnSignature signature = DoFnSignatures.getSignature(fn.getClass());
    DoFnSignature.ProcessElementMethod processElementMethod = signature.processElement();
    for (SideInputParameter sideInput : processElementMethod.getSideInputParameters()) {
        PCollectionView<?> view = sideInputs.get(sideInput.sideInputId());
        checkArgument(view != null, "the ProcessElement method expects a side input identified with the tag %s, but no such side input was" + " supplied. Use withSideInput(String, PCollectionView) to supply this side input.", sideInput.sideInputId());
        TypeDescriptor<?> viewType = view.getViewFn().getTypeDescriptor();
        // Currently check that the types exactly match, even if the types are convertible.
        checkArgument(viewType.equals(sideInput.elementT()), "Side Input with tag %s and type %s cannot be bound to ProcessElement parameter with type %s", sideInput.sideInputId(), viewType, sideInput.elementT());
    }
}
Also used : SideInputParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.SideInputParameter) DoFnSignature(org.apache.beam.sdk.transforms.reflect.DoFnSignature)

Aggregations

DoFnSignature (org.apache.beam.sdk.transforms.reflect.DoFnSignature)1 SideInputParameter (org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.SideInputParameter)1