Class AsJsons.AsJsonsWithFailures<FailureT>
- java.lang.Object
-
- org.apache.beam.sdk.transforms.PTransform<org.apache.beam.sdk.values.PCollection<InputT>,org.apache.beam.sdk.transforms.WithFailures.Result<org.apache.beam.sdk.values.PCollection<java.lang.String>,FailureT>>
-
- org.apache.beam.sdk.extensions.jackson.AsJsons.AsJsonsWithFailures<FailureT>
-
- All Implemented Interfaces:
java.io.Serializable,org.apache.beam.sdk.transforms.display.HasDisplayData
public class AsJsons.AsJsonsWithFailures<FailureT> extends org.apache.beam.sdk.transforms.PTransform<org.apache.beam.sdk.values.PCollection<InputT>,org.apache.beam.sdk.transforms.WithFailures.Result<org.apache.beam.sdk.values.PCollection<java.lang.String>,FailureT>>APTransformthat adds exception handling toAsJsons.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AsJsons.AsJsonsWithFailures<FailureT>exceptionsVia(org.apache.beam.sdk.transforms.ProcessFunction<org.apache.beam.sdk.transforms.WithFailures.ExceptionElement<InputT>,FailureT> exceptionHandler)Returns a newAsJsons.AsJsonsWithFailurestransform that catches exceptions raised while writing JSON elements, passing the raised exception instance and the input element being processed through the givenexceptionHandlerand emitting the result to a failure collection.org.apache.beam.sdk.transforms.WithFailures.Result<org.apache.beam.sdk.values.PCollection<java.lang.String>,FailureT>expand(org.apache.beam.sdk.values.PCollection<InputT> input)-
Methods inherited from class org.apache.beam.sdk.transforms.PTransform
addAnnotation, compose, compose, getAdditionalInputs, getAnnotations, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, populateDisplayData, setDisplayData, setResourceHints, toString, validate, validate
-
-
-
-
Method Detail
-
exceptionsVia
public AsJsons.AsJsonsWithFailures<FailureT> exceptionsVia(org.apache.beam.sdk.transforms.ProcessFunction<org.apache.beam.sdk.transforms.WithFailures.ExceptionElement<InputT>,FailureT> exceptionHandler)
Returns a newAsJsons.AsJsonsWithFailurestransform that catches exceptions raised while writing JSON elements, passing the raised exception instance and the input element being processed through the givenexceptionHandlerand emitting the result to a failure collection. It is supposed to be used along withAsJsons.exceptionsInto(TypeDescriptor)and get lambda function as exception handler.See
WithFailuresdocumentation for usage patterns of the returnedWithFailures.Result.Example usage:
WithFailures.Result<PCollection<String>, KV<MyPojo, Map<String, String>>> result = pojos.apply( AsJsons.of(MyPojo.class) .exceptionsInto( TypeDescriptors.kvs( TypeDescriptor.of(MyPojo.class), TypeDescriptors.strings())) .exceptionsVia( f -> KV.of(f.element(), f.exception().getClass().getCanonicalName()))); PCollection<String> output = result.output(); // valid json elements PCollection<KV<MyPojo, Map<String, String>>> failures = result.failures();
-
-