T - the type of the values being transcodedpublic abstract class StandardCoder<T> extends java.lang.Object implements Coder<T>
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(java.lang.Object o) |
java.util.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.
|
java.lang.Object |
structuralValue(T value)
Returns an object with an
Object.equals() method
that represents structural equality on the argument. |
java.lang.String |
toString() |
void |
verifyDeterministic()
Throw
Coder.NonDeterministicException if the coding is not deterministic. |
protected void |
verifyDeterministic(java.lang.String message,
Coder<?>... coders) |
protected void |
verifyDeterministic(java.lang.String message,
java.lang.Iterable<Coder<?>> coders) |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitdecode, encode, getCoderArguments, isDeterministicpublic java.util.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 boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic 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)
isRegisterByteSizeObserverCheap in interface Coder<T>protected long getEncodedElementByteSize(T value, Coder.Context context) throws java.lang.Exception
java.lang.Exceptionpublic void registerByteSizeObserver(T value, com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver observer, Coder.Context context) throws java.lang.Exception
registerByteSizeObserver in interface Coder<T>java.lang.Exceptionpublic 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>Coder.NonDeterministicException - if this coder is not deterministic.protected void verifyDeterministic(java.lang.String message,
java.lang.Iterable<Coder<?>> coders)
throws Coder.NonDeterministicException
Coder.NonDeterministicExceptionprotected void verifyDeterministic(java.lang.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 java.lang.Object structuralValue(T value) throws java.lang.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>java.lang.Exception