Class ParseJsons<OutputT>
- java.lang.Object
-
- org.apache.beam.sdk.transforms.PTransform<org.apache.beam.sdk.values.PCollection<java.lang.String>,org.apache.beam.sdk.values.PCollection<OutputT>>
-
- org.apache.beam.sdk.extensions.jackson.ParseJsons<OutputT>
-
- All Implemented Interfaces:
java.io.Serializable,org.apache.beam.sdk.transforms.display.HasDisplayData
public class ParseJsons<OutputT> extends org.apache.beam.sdk.transforms.PTransform<org.apache.beam.sdk.values.PCollection<java.lang.String>,org.apache.beam.sdk.values.PCollection<OutputT>>PTransformfor parsing JSONStrings. ParsePCollectionofStringsin JSON format into aPCollectionof objects represented by those JSONStringsusing Jackson.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classParseJsons.ParseJsonsWithFailures<FailureT>APTransformthat adds exception handling toParseJsons.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <NewFailureT>
ParseJsons.ParseJsonsWithFailures<NewFailureT>exceptionsInto(org.apache.beam.sdk.values.TypeDescriptor<NewFailureT> failureTypeDescriptor)Returns a newParseJsons.ParseJsonsWithFailurestransform that catches exceptions raised while parsing elements, with the given type descriptor used for the failure collection but the exception handler yet to be specified usingParseJsons.ParseJsonsWithFailures.exceptionsVia(ProcessFunction).ParseJsons.ParseJsonsWithFailures<org.apache.beam.sdk.values.KV<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>>exceptionsVia()Returns a newParseJsons.ParseJsonsWithFailurestransform that catches exceptions raised while parsing elements, passing the raised exception instance and the input element being processed through the default exception handlerParseJsons.DefaultExceptionAsMapHandlerand emitting the result to a failure collection.<FailureT> ParseJsons.ParseJsonsWithFailures<FailureT>exceptionsVia(org.apache.beam.sdk.transforms.InferableFunction<org.apache.beam.sdk.transforms.WithFailures.ExceptionElement<java.lang.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.org.apache.beam.sdk.values.PCollection<OutputT>expand(org.apache.beam.sdk.values.PCollection<java.lang.String> input)static <OutputT> ParseJsons<OutputT>of(java.lang.Class<? extends OutputT> outputClass)Creates aParseJsonsPTransformthat will parse JSONStringsinto aPCollection<OutputT>using a JacksonObjectMapper.ParseJsons<OutputT>withMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)Use custom JacksonObjectMapperinstead of the default one.-
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
-
of
public static <OutputT> ParseJsons<OutputT> of(java.lang.Class<? extends OutputT> outputClass)
Creates aParseJsonsPTransformthat will parse JSONStringsinto aPCollection<OutputT>using a JacksonObjectMapper.
-
withMapper
public ParseJsons<OutputT> withMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
Use custom JacksonObjectMapperinstead of the default one.
-
exceptionsInto
public <NewFailureT> ParseJsons.ParseJsonsWithFailures<NewFailureT> exceptionsInto(org.apache.beam.sdk.values.TypeDescriptor<NewFailureT> failureTypeDescriptor)
Returns a newParseJsons.ParseJsonsWithFailurestransform that catches exceptions raised while parsing elements, with the given type descriptor used for the failure collection but the exception handler yet to be specified usingParseJsons.ParseJsonsWithFailures.exceptionsVia(ProcessFunction).See
WithFailuresdocumentation for usage patterns of the returnedWithFailures.Result.
-
exceptionsVia
public <FailureT> ParseJsons.ParseJsonsWithFailures<FailureT> exceptionsVia(org.apache.beam.sdk.transforms.InferableFunction<org.apache.beam.sdk.transforms.WithFailures.ExceptionElement<java.lang.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.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) .exceptionsVia(new WithFailures.ExceptionAsMapHandler<String>() {})); PCollection<MyPojo> output = result.output(); // valid POJOs PCollection<KV<String, Map<String, String>>> failures = result.failures();
-
exceptionsVia
public ParseJsons.ParseJsonsWithFailures<org.apache.beam.sdk.values.KV<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>> exceptionsVia()
Returns a newParseJsons.ParseJsonsWithFailurestransform that catches exceptions raised while parsing elements, passing the raised exception instance and the input element being processed through the default exception handlerParseJsons.DefaultExceptionAsMapHandlerand emitting the result to a failure collection.See
ParseJsons.DefaultExceptionAsMapHandlerfor more details about default handler behavior.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) .exceptionsVia()); PCollection<MyPojo> output = result.output(); // valid POJOs PCollection<KV<String, Map<String, String>>> failures = result.failures();
-
expand
public org.apache.beam.sdk.values.PCollection<OutputT> expand(org.apache.beam.sdk.values.PCollection<java.lang.String> input)
- Specified by:
expandin classorg.apache.beam.sdk.transforms.PTransform<org.apache.beam.sdk.values.PCollection<java.lang.String>,org.apache.beam.sdk.values.PCollection<OutputT>>
-
-