T - the type of elements handled by this coderpublic class SerializableCoder<T extends java.io.Serializable> extends AtomicCoder<T>
Serializable objects.
To use, specify the coder type on a PCollection.
PCollection<MyRecord> records =
foo.apply(...).setCoder(SerializableCoder.of(MyRecord.class));
SerializableCoder does not guarantee a deterministic encoding, as Java Serialization may produce different binary encodings for two equivalent objects.
Coder.Context, Coder.NonDeterministicException| Modifier | Constructor and Description |
|---|---|
protected |
SerializableCoder(java.lang.Class<T> type) |
| Modifier and Type | Method and Description |
|---|---|
com.google.cloud.dataflow.sdk.util.CloudObject |
asCloudObject()
Returns the
CloudObject that represents this Coder. |
T |
decode(java.io.InputStream inStream,
Coder.Context context)
Decodes a value of type
T from the given input stream in
the given context. |
void |
encode(T value,
java.io.OutputStream outStream,
Coder.Context context)
Encodes the given value of type
T onto the given output stream
in the given context. |
boolean |
equals(java.lang.Object other) |
java.lang.Class<T> |
getRecordType() |
boolean |
isDeterministic()
Deprecated.
|
static <T extends java.io.Serializable> |
of(java.lang.Class<T> type)
Returns a
SerializableCoder instance for the provided element type. |
static SerializableCoder<?> |
of(java.lang.String classType) |
void |
verifyDeterministic()
Throw
Coder.NonDeterministicException if the coding is not deterministic. |
getCoderArguments, getInstanceComponentsgetComponents, getEncodedElementByteSize, hashCode, isRegisterByteSizeObserverCheap, registerByteSizeObserver, toString, verifyDeterministic, verifyDeterministicprotected SerializableCoder(java.lang.Class<T> type)
public static <T extends java.io.Serializable> SerializableCoder<T> of(java.lang.Class<T> type)
SerializableCoder instance for the provided element type.T - the element typepublic static SerializableCoder<?> of(java.lang.String classType) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundExceptionpublic java.lang.Class<T> getRecordType()
public void encode(T value, java.io.OutputStream outStream, Coder.Context context) throws java.io.IOException, CoderException
CoderT onto the given output stream
in the given context.java.io.IOException - if writing to the OutputStream fails
for some reasonCoderException - if the value could not be encoded for some reasonpublic T decode(java.io.InputStream inStream, Coder.Context context) throws java.io.IOException, CoderException
CoderT from the given input stream in
the given context. Returns the decoded value.java.io.IOException - if reading from the InputStream fails
for some reasonCoderException - if the value could not be decoded for some reasonpublic com.google.cloud.dataflow.sdk.util.CloudObject asCloudObject()
CoderCloudObject that represents this Coder.asCloudObject in interface Coder<T extends java.io.Serializable>asCloudObject in class StandardCoder<T extends java.io.Serializable>@Deprecated public boolean isDeterministic()
Coder In order for a Coder to be considered deterministic,
the following must be true:
Object.equals()
or Comparable.compareTo(), if supported), have the same
encoding.
Coder always produces a canonical encoding, which is the
same for an instance of an object even if produced on different
computers at different times.
public void verifyDeterministic()
throws Coder.NonDeterministicException
CoderCoder.NonDeterministicException if the coding is not deterministic.
In order for a Coder to be considered deterministic,
the following must be true:
Object.equals()
or Comparable.compareTo(), if supported), have the same
encoding.
Coder always produces a canonical encoding, which is the
same for an instance of an object even if produced on different
computers at different times.
verifyDeterministic in interface Coder<T extends java.io.Serializable>verifyDeterministic in class StandardCoder<T extends java.io.Serializable>Coder.NonDeterministicException - if this coder is not deterministic.public boolean equals(java.lang.Object other)
equals in class StandardCoder<T extends java.io.Serializable>