Google Cloud Dataflow SDK for Java, version 1.9.1
Class DurationCoder
- java.lang.Object
-
- com.google.cloud.dataflow.sdk.coders.StandardCoder<T>
-
- com.google.cloud.dataflow.sdk.coders.DeterministicStandardCoder<T>
-
- com.google.cloud.dataflow.sdk.coders.AtomicCoder<ReadableDuration>
-
- com.google.cloud.dataflow.sdk.coders.DurationCoder
-
- All Implemented Interfaces:
- Coder<ReadableDuration>, Serializable
public class DurationCoder extends AtomicCoder<ReadableDuration>
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.cloud.dataflow.sdk.coders.Coder
Coder.Context, Coder.NonDeterministicException
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description boolean
consistentWithEquals()
ReadableDuration
decode(InputStream inStream, Coder.Context context)
Decodes a value of typeT
from the given input stream in the given context.void
encode(ReadableDuration value, OutputStream outStream, Coder.Context context)
Encodes the given value of typeT
onto the given output stream in the given context.boolean
isRegisterByteSizeObserverCheap(ReadableDuration value, Coder.Context context)
Returns whetherCoder.registerByteSizeObserver(T, com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver, com.google.cloud.dataflow.sdk.coders.Coder.Context)
cheap enough to call for every element, that is, if thisCoder
can calculate the byte size of the element to be coded in roughly constant time (or lazily).static DurationCoder
of()
void
registerByteSizeObserver(ReadableDuration value, com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver observer, Coder.Context context)
Notifies theElementByteSizeObserver
about the byte size of the encoded value using thisCoder
.-
Methods inherited from class com.google.cloud.dataflow.sdk.coders.AtomicCoder
getCoderArguments, getInstanceComponents
-
Methods inherited from class com.google.cloud.dataflow.sdk.coders.DeterministicStandardCoder
verifyDeterministic
-
Methods inherited from class com.google.cloud.dataflow.sdk.coders.StandardCoder
asCloudObject, equals, getAllowedEncodings, getComponents, getEncodedElementByteSize, getEncodingId, hashCode, structuralValue, toString, verifyDeterministic, verifyDeterministic
-
-
-
-
Method Detail
-
of
public static DurationCoder of()
-
encode
public void encode(ReadableDuration value, OutputStream outStream, Coder.Context context) throws CoderException, IOException
Description copied from interface:Coder
Encodes the given value of typeT
onto the given output stream in the given context.- Throws:
CoderException
- if the value could not be encoded for some reasonIOException
- if writing to theOutputStream
fails for some reason
-
decode
public ReadableDuration decode(InputStream inStream, Coder.Context context) throws CoderException, IOException
Description copied from interface:Coder
Decodes a value of typeT
from the given input stream in the given context. Returns the decoded value.- Throws:
CoderException
- if the value could not be decoded for some reasonIOException
- if reading from theInputStream
fails for some reason
-
consistentWithEquals
public boolean consistentWithEquals()
Returnstrue
if thisCoder
is injective with respect toObject.equals(java.lang.Object)
.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 fornull
.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.- Specified by:
consistentWithEquals
in interfaceCoder<ReadableDuration>
- Overrides:
consistentWithEquals
in classStandardCoder<ReadableDuration>
- Returns:
true
. This coder is injective.
-
isRegisterByteSizeObserverCheap
public boolean isRegisterByteSizeObserverCheap(ReadableDuration value, Coder.Context context)
Returns whetherCoder.registerByteSizeObserver(T, com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver, com.google.cloud.dataflow.sdk.coders.Coder.Context)
cheap enough to call for every element, that is, if thisCoder
can calculate the byte size of the element to be coded in roughly constant time (or lazily).Not intended to be called by user code, but instead by
PipelineRunner
implementations.- Specified by:
isRegisterByteSizeObserverCheap
in interfaceCoder<ReadableDuration>
- Overrides:
isRegisterByteSizeObserverCheap
in classStandardCoder<ReadableDuration>
- Returns:
true
, because it is cheap to ascertain the byte size of a long.
-
registerByteSizeObserver
public void registerByteSizeObserver(ReadableDuration value, com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver observer, Coder.Context context) throws Exception
Description copied from class:StandardCoder
Notifies theElementByteSizeObserver
about the byte size of the encoded value using thisCoder
.Not intended to be called by user code, but instead by
PipelineRunner
implementations.For
StandardCoder
subclasses, this notifiesobserver
about the byte size of the encoded value using this coder as returned byStandardCoder.getEncodedElementByteSize(T, com.google.cloud.dataflow.sdk.coders.Coder.Context)
.- Specified by:
registerByteSizeObserver
in interfaceCoder<ReadableDuration>
- Overrides:
registerByteSizeObserver
in classStandardCoder<ReadableDuration>
- Throws:
Exception
-
-