Class ParseJsons.ParseJsonsWithFailures<FailureT>
java.lang.Object
org.apache.beam.sdk.transforms.PTransform<PCollection<String>,WithFailures.Result<PCollection<OutputT>,FailureT>>
org.apache.beam.sdk.extensions.jackson.ParseJsons.ParseJsonsWithFailures<FailureT>
- All Implemented Interfaces:
Serializable,HasDisplayData
- Enclosing class:
ParseJsons<OutputT>
public class ParseJsons.ParseJsonsWithFailures<FailureT>
extends PTransform<PCollection<String>,WithFailures.Result<PCollection<OutputT>,FailureT>>
A
PTransform that adds exception handling to ParseJsons.- See Also:
-
Field Summary
Fields inherited from class org.apache.beam.sdk.transforms.PTransform
annotations, displayData, name, resourceHints -
Method Summary
Modifier and TypeMethodDescriptionexceptionsVia(ProcessFunction<WithFailures.ExceptionElement<String>, FailureT> exceptionHandler) Returns a newParseJsons.ParseJsonsWithFailurestransform that catches exceptions raised while parsing elements, passing the raised exception instance and the input element being processed through the givenexceptionHandlerand emitting the result to a failure collection.expand(PCollection<String> input) Override this method to specify how thisPTransformshould be expanded on the givenInputT.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 Details
-
exceptionsVia
public ParseJsons<OutputT>.ParseJsonsWithFailures<FailureT> exceptionsVia(ProcessFunction<WithFailures.ExceptionElement<String>, FailureT> exceptionHandler) Returns a newParseJsons.ParseJsonsWithFailurestransform that catches exceptions raised while parsing 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 withParseJsons.exceptionsInto(TypeDescriptor)and get lambda function as exception handler.See
WithFailuresdocumentation for usage patterns of the returnedWithFailures.Result.Example usage:
WithFailures.Result<PCollection<MyPojo>, KV<String, Map<String, String>>> result = json.apply( ParseJsons.of(MyPojo.class) .exceptionsInto( TypeDescriptors.kvs(TypeDescriptors.strings(), TypeDescriptors.strings())) .exceptionsVia( f -> KV.of(f.element(), f.exception().getClass().getCanonicalName()))); PCollection<MyPojo> output = result.output(); // valid POJOs PCollection<KV<String, Map<String, String>>> failures = result.failures(); -
expand
Description copied from class:PTransformOverride this method to specify how thisPTransformshould be expanded on the givenInputT.NOTE: This method should not be called directly. Instead apply the
PTransformshould be applied to theInputTusing theapplymethod.Composite transforms, which are defined in terms of other transforms, should return the output of one of the composed transforms. Non-composite transforms, which do not apply any transforms internally, should return a new unbound output and register evaluators (via backend-specific registration methods).
- Specified by:
expandin classPTransform<PCollection<String>,WithFailures.Result<PCollection<OutputT>, FailureT>>
-