Class BooleanCoder
- java.lang.Object
-
- org.apache.beam.sdk.coders.Coder<T>
-
- org.apache.beam.sdk.coders.StructuredCoder<T>
-
- org.apache.beam.sdk.coders.AtomicCoder<java.lang.Boolean>
-
- org.apache.beam.sdk.coders.BooleanCoder
-
- All Implemented Interfaces:
java.io.Serializable
public class BooleanCoder extends AtomicCoder<java.lang.Boolean>
ACoder
forBoolean
.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.beam.sdk.coders.Coder
Coder.Context, Coder.NonDeterministicException
-
-
Constructor Summary
Constructors Constructor Description BooleanCoder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
consistentWithEquals()
java.lang.Boolean
decode(java.io.InputStream is)
Decodes a value of typeT
from the given input stream in the given context.void
encode(java.lang.Boolean value, java.io.OutputStream os)
Encodes the given value of typeT
onto the given output stream.protected long
getEncodedElementByteSize(java.lang.Boolean value)
Returns the size in bytes of the encoded value using this coder.boolean
isRegisterByteSizeObserverCheap(java.lang.Boolean value)
Returns whetherCoder.registerByteSizeObserver(T, org.apache.beam.sdk.util.common.ElementByteSizeObserver)
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 BooleanCoder
of()
Returns the singleton instance ofBooleanCoder
.-
Methods inherited from class org.apache.beam.sdk.coders.AtomicCoder
equals, getCoderArguments, getComponents, hashCode, verifyDeterministic
-
Methods inherited from class org.apache.beam.sdk.coders.StructuredCoder
toString
-
Methods inherited from class org.apache.beam.sdk.coders.Coder
decode, encode, getEncodedTypeDescriptor, registerByteSizeObserver, structuralValue, verifyDeterministic, verifyDeterministic
-
-
-
-
Method Detail
-
of
public static BooleanCoder of()
Returns the singleton instance ofBooleanCoder
.
-
encode
public void encode(java.lang.Boolean value, java.io.OutputStream os) throws java.io.IOException
Description copied from class:Coder
Encodes the given value of typeT
onto the given output stream.- Specified by:
encode
in classCoder<java.lang.Boolean>
- Throws:
java.io.IOException
- if writing to theOutputStream
fails for some reasonCoderException
- if the value could not be encoded for some reason
-
decode
public java.lang.Boolean decode(java.io.InputStream is) throws java.io.IOException
Description copied from class:Coder
Decodes a value of typeT
from the given input stream in the given context. Returns the decoded value.- Specified by:
decode
in classCoder<java.lang.Boolean>
- Throws:
java.io.IOException
- if reading from theInputStream
fails for some reasonCoderException
- if the value could not be decoded for some reason
-
consistentWithEquals
public boolean consistentWithEquals()
Description copied from class:Coder
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.By default, returns false.
- Overrides:
consistentWithEquals
in classCoder<java.lang.Boolean>
-
isRegisterByteSizeObserverCheap
public boolean isRegisterByteSizeObserverCheap(java.lang.Boolean value)
Description copied from class:Coder
Returns whetherCoder.registerByteSizeObserver(T, org.apache.beam.sdk.util.common.ElementByteSizeObserver)
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.By default, returns false. The default
Coder.registerByteSizeObserver(T, org.apache.beam.sdk.util.common.ElementByteSizeObserver)
implementation invokesCoder.getEncodedElementByteSize(T)
which requires re-encoding an element unless it is overridden. This is considered expensive.- Overrides:
isRegisterByteSizeObserverCheap
in classCoder<java.lang.Boolean>
-
getEncodedElementByteSize
protected long getEncodedElementByteSize(java.lang.Boolean value) throws java.lang.Exception
Description copied from class:Coder
Returns the size in bytes of the encoded value using this coder.- Overrides:
getEncodedElementByteSize
in classCoder<java.lang.Boolean>
- Throws:
java.lang.Exception
-
-