T - the type of the values being transcodedpublic abstract class StandardCoder<T> extends Object implements Coder<T>
StandardCoder is a Coder that defines equality,
hashing, and printing via the class name and recursively using
getComponents().Coder.Context, Coder.NonDeterministicException| Modifier | Constructor and Description |
|---|---|
protected |
StandardCoder() |
| Modifier and Type | Method and Description |
|---|---|
com.google.cloud.dataflow.sdk.util.CloudObject |
asCloudObject()
Returns the
CloudObject that represents this Coder. |
boolean |
consistentWithEquals()
Returns true if whenever the encoded bytes of two values are equal, then the original values
are equal according to
Objects.equals() (note that this is well-defined for
null). |
boolean |
equals(Object o) |
Collection<String> |
getAllowedEncodings()
A collection of encodings supported by
Coder.decode(java.io.InputStream, com.google.cloud.dataflow.sdk.coders.Coder.Context) in addition to the value of
getEncodingId(). |
List<? extends Coder<?>> |
getComponents()
Returns the list of
Coders that are components of this
Coder. |
protected long |
getEncodedElementByteSize(T value,
Coder.Context context)
Returns the size in bytes of the encoded value using this
coder.
|
String |
getEncodingId()
A unique identifier for the binary format written by
Coder.encode(T, java.io.OutputStream, com.google.cloud.dataflow.sdk.coders.Coder.Context). |
int |
hashCode() |
boolean |
isRegisterByteSizeObserverCheap(T value,
Coder.Context context)
StandardCoder requires elements to be fully encoded and copied
into a byte stream to determine the byte size of the element, which is
considered expensive. |
void |
registerByteSizeObserver(T value,
com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver observer,
Coder.Context context)
Notifies
observer about the byte size of the encoded value using this coder. |
Object |
structuralValue(T value)
Returns an object with an
Object.equals() method that represents structural equality
on the argument. |
String |
toString() |
protected void |
verifyDeterministic(String message,
Coder<?>... coders) |
protected void |
verifyDeterministic(String message,
Iterable<Coder<?>> coders) |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitdecode, encode, getCoderArguments, verifyDeterministicpublic String getEncodingId()
Coder.encode(T, java.io.OutputStream, com.google.cloud.dataflow.sdk.coders.Coder.Context). If a subclass is
modified to write a new format, it is imperative that this method be overridden to return
a distinct value.
By default, this is an empty string so only the fully qualified name of the class is used.
getEncodingId in interface Coder<T>getAllowedEncodings()public Collection<String> getAllowedEncodings()
Coder.decode(java.io.InputStream, com.google.cloud.dataflow.sdk.coders.Coder.Context) in addition to the value of
getEncodingId().
By default, this is empty.
getAllowedEncodings in interface Coder<T>getEncodingId()public List<? extends Coder<?>> getComponents()
Coders that are components of this
Coder. Returns an empty list if this is an AtomicCoder (or
other Coder with no components).public com.google.cloud.dataflow.sdk.util.CloudObject asCloudObject()
CoderCloudObject that represents this Coder.asCloudObject in interface Coder<T>public boolean isRegisterByteSizeObserverCheap(T value, Coder.Context context)
StandardCoder requires elements to be fully encoded and copied
into a byte stream to determine the byte size of the element, which is
considered expensive.isRegisterByteSizeObserverCheap in interface Coder<T>protected long getEncodedElementByteSize(T value, Coder.Context context) throws Exception
Exceptionpublic void registerByteSizeObserver(T value, com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver observer, Coder.Context context) throws Exception
observer about the byte size of the encoded value using this coder.
Calls getEncodedElementByteSize(T, com.google.cloud.dataflow.sdk.coders.Coder.Context) and notifies observer using
ElementByteSizeObserver.update(Object).registerByteSizeObserver in interface Coder<T>Exceptionprotected void verifyDeterministic(String message, Iterable<Coder<?>> coders) throws Coder.NonDeterministicException
Coder.NonDeterministicExceptionprotected void verifyDeterministic(String message, Coder<?>... coders) throws Coder.NonDeterministicException
Coder.NonDeterministicExceptionpublic boolean consistentWithEquals()
CoderObjects.equals() (note that this is well-defined for
null). In other words, encoding is injective.
This condition is most notably false for arrays. More generally, this condition is false
whenever equals() compares object identity, rather than performing a
semantic/structural comparison.
consistentWithEquals in interface Coder<T>public Object structuralValue(T value) throws Exception
CoderObject.equals() method that represents structural equality
on the argument.
For any two values x and y of type T, if their encoded bytes are the
same, then it must be the case that structuralValue(x).equals(@code structuralValue(y).
Most notably:
null should be a proper object with
an equals() method, even if the input value is null.
See also Coder.consistentWithEquals().
structuralValue in interface Coder<T>Exception