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 the encoded bytes of two objects are
equal only when they are also equal according to
Object.equals(). |
boolean |
equals(Object o) |
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.
|
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 ElementByteSizeObserver 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 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
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()
CoderObject.equals().
(and also implements a compatible Object.hasCode())
This most notably false for arrays. It will generally
be false when Object.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.
(and also implements a compatible Object.hashCode()).
For any two objects of type T, if their encoded bytes
are the same, then their structural values are equal
according to Object.equals().
Most notably, the structural value for an array coder should perform a structural comparison of the contents of the arrays, rather than the default behavior of comparing according to object identity.
See also Coder.consistentWithEquals().
structuralValue in interface Coder<T>Exception