T - type of JAXB annotated objects that will be serialized.public class JAXBCoder<T> extends AtomicCoder<T>
Class of the JAXB annotated object.Coder.Context, Coder.NonDeterministicException| Modifier and Type | Method and Description |
|---|---|
org.apache.beam.sdk.util.CloudObject |
asCloudObject()
Returns the
CloudObject that represents this Coder. |
T |
decode(InputStream inStream,
Coder.Context context)
Decodes a value of type
T from the given input stream in
the given context. |
void |
encode(T value,
OutputStream outStream,
Coder.Context context)
Encodes the given value of type
T onto the given output stream
in the given context. |
String |
getEncodingId()
An identifier for the binary format written by
Coder.encode(T, java.io.OutputStream, org.apache.beam.sdk.coders.Coder.Context). |
Class<T> |
getJAXBClass() |
static <T> JAXBCoder<T> |
of(Class<T> jaxbClass)
Create a coder for a given type of JAXB annotated objects.
|
static <T> JAXBCoder<T> |
of(String jaxbClassName)
Constructor for JSON deserialization only.
|
getCoderArguments, getInstanceComponentsverifyDeterministicconsistentWithEquals, equals, getAllowedEncodings, getComponents, getEncodedElementByteSize, hashCode, isRegisterByteSizeObserverCheap, registerByteSizeObserver, structuralValue, toString, verifyDeterministic, verifyDeterministicpublic static <T> JAXBCoder<T> of(Class<T> jaxbClass)
jaxbClass - the Class of the JAXB annotated objects.public void encode(T value, OutputStream outStream, Coder.Context context) throws CoderException, IOException
CoderT onto the given output stream
in the given context.CoderException - if the value could not be encoded for some reasonIOException - if writing to the OutputStream fails
for some reasonpublic T decode(InputStream inStream, Coder.Context context) throws CoderException, IOException
CoderT from the given input stream in
the given context. Returns the decoded value.CoderException - if the value could not be decoded for some reasonIOException - if reading from the InputStream fails
for some reasonpublic String getEncodingId()
CoderCoder.encode(T, java.io.OutputStream, org.apache.beam.sdk.coders.Coder.Context).
This value, along with the fully qualified class name, forms an identifier for the binary format of this coder. Whenever this value changes, the new encoding is considered incompatible with the prior format: It is presumed that the prior version of the coder will be unable to correctly read the new format and the new version of the coder will be unable to correctly read the old format.
If the format is changed in a backwards-compatible way (the Coder can still accept data from
the prior format), such as by adding optional fields to a Protocol Buffer or Avro definition,
and you want Dataflow to understand that the new coder is compatible with the prior coder,
this value must remain unchanged. It is then the responsibility of Coder.decode(java.io.InputStream, org.apache.beam.sdk.coders.Coder.Context) to correctly
read data from the prior format.
getEncodingId in interface Coder<T>getEncodingId in class StandardCoder<T>public static <T> JAXBCoder<T> of(String jaxbClassName)
public org.apache.beam.sdk.util.CloudObject asCloudObject()
CoderCloudObject that represents this Coder.asCloudObject in interface Coder<T>asCloudObject in class StandardCoder<T>