public class ParseJsons.ParseJsonsWithFailures<FailureT> extends PTransform<PCollection<java.lang.String>,WithFailures.Result<PCollection<OutputT>,FailureT>>
PTransform that adds exception handling to ParseJsons.name, resourceHints| Modifier and Type | Method and Description |
|---|---|
ParseJsons.ParseJsonsWithFailures<FailureT> |
exceptionsVia(ProcessFunction<WithFailures.ExceptionElement<java.lang.String>,FailureT> exceptionHandler)
Returns a new
ParseJsons.ParseJsonsWithFailures transform that catches exceptions raised while
parsing elements, passing the raised exception instance and the input element being processed
through the given exceptionHandler and emitting the result to a failure collection. |
WithFailures.Result<PCollection<OutputT>,FailureT> |
expand(PCollection<java.lang.String> input)
Override this method to specify how this
PTransform should be expanded on the given
InputT. |
compose, compose, getAdditionalInputs, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, populateDisplayData, setResourceHints, toString, validate, validatepublic ParseJsons.ParseJsonsWithFailures<FailureT> exceptionsVia(ProcessFunction<WithFailures.ExceptionElement<java.lang.String>,FailureT> exceptionHandler)
ParseJsons.ParseJsonsWithFailures transform that catches exceptions raised while
parsing elements, passing the raised exception instance and the input element being processed
through the given exceptionHandler and emitting the result to a failure collection.
It is supposed to be used along with ParseJsons.exceptionsInto(TypeDescriptor) and
get lambda function as exception handler.
See WithFailures documentation for usage patterns of the returned WithFailures.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();
public WithFailures.Result<PCollection<OutputT>,FailureT> expand(PCollection<java.lang.String> input)
PTransformPTransform should be expanded on the given
InputT.
NOTE: This method should not be called directly. Instead apply the PTransform should
be applied to the InputT using the apply method.
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).
expand in class PTransform<PCollection<java.lang.String>,WithFailures.Result<PCollection<OutputT>,FailureT>>