Package org.apache.beam.sdk.coders
Coders
to specify how data is encoded to and
decoded from byte strings.
During execution of a Pipeline, elements in a PCollection
may need to be encoded into byte strings. This happens both at the beginning and end of a
pipeline when data is read from and written to persistent storage and also during execution of a
pipeline when elements are communicated between machines.
Exactly when PCollection elements are encoded during execution depends on which PipelineRunner
is being used and how that runner chooses to execute the
pipeline. As such, Beam requires that all PCollections have an appropriate Coder in case it
becomes necessary. In many cases, the Coder can be inferred from the available Java type
information and the Pipeline's CoderRegistry
. It can be
specified per PCollection via PCollection.setCoder(Coder)
or
per type using the DefaultCoder
annotation.
This package provides a number of coders for common types like Integer
,
String
, and List
, as well as coders like
invalid reference
org.apache.beam.sdk.coders.AvroCoder
-
ClassDescriptionAtomicCoder<T>A
BigDecimalCoder
encodes aBigDecimal
as an integer scale encoded withVarIntCoder
and aBigInteger
encoded usingBigIntegerCoder
.ABigEndianIntegerCoder
encodesIntegers
in 4 bytes, big-endian.ABigEndianLongCoder
encodesLongs
in 8 bytes, big-endian.ABigEndianShortCoder
encodesShorts
in 2 bytes, big-endian.ABigIntegerCoder
encodes aBigInteger
as a byte array containing the big endian two's-complement representation, encoded viaByteArrayCoder
.Coder forBitSet
.ACoder
forbyte[]
.The exception thrown when aCoderRegistry
orCoderProvider
cannot provide aCoder
that has been requested.Indicates the reason thatCoder
inference failed.Coder<T>ACoder<T>
defines how to encode and decode values of typeT
into byte streams.Deprecated.Exception thrown byCoder.verifyDeterministic()
if the encoding is not deterministic, including details of why the encoding is not deterministic.AnException
thrown if there is a problem encoding or decoding a value.ACoderProvider
providesCoder
s.Coder
creators have the ability to automatically have theircoders
registered with this SDK by creating aServiceLoader
entry and a concrete implementation of this interface.Static utility methods for creating and working withCoderProvider
s.CustomCoder<T>An abstract base class that implements all methods ofCoder
exceptCoder.encode(T, java.io.OutputStream)
andCoder.decode(java.io.InputStream)
.TheDefaultCoder
annotation specifies aCoder
class to handle encoding and decoding instances of the annotated class.ACoderProviderRegistrar
that registers aCoderProvider
which can use the@DefaultCoder
annotation to providecoder providers
that createsCoder
s.ACoderProvider
that uses the@DefaultCoder
annotation to providecoder providers
that createCoder
s.DelegateCoder<T,IntermediateT> ADelegateCoder<T, IntermediateT>
wraps aCoder
forIntermediateT
and encodes/decodes values of typeT
by converting to/fromIntermediateT
and then encoding/decoding using the underlyingCoder<IntermediateT>
.DelegateCoder.CodingFunction<InputT,OutputT> ACodingFunction<InputT, OutputT>
is a serializable function fromInputT
toOutputT
that may throw anyException
.ADoubleCoder
encodesDouble
values in 8 bytes using Java serialization.AFloatCoder
encodesFloat
values in 4 bytes using Java serialization.IterableLikeCoder<T,IterableT extends Iterable<T>> An abstract base class with functionality for assembling aCoder
for a class that implementsIterable
.AKvCoder
encodesKV
s.ACoder
which is able to take any existing coder and wrap it such that it is only invoked in theouter context
.ListCoder<T>MapCoder<K,V> ANullableCoder
encodes nullable values of typeT
using a nestedCoder<T>
that does not toleratenull
values.A sub-class of SchemaCoder that can only encodeRow
instances.SerializableCoder<T extends Serializable>ACoder
for Java classes that implementSerializable
.ACoderProviderRegistrar
which registers aCoderProvider
which can handle serializable types.SetCoder<T>ShardedKeyCoder<KeyT>SnappyCoder<T>Wraps an existing coder with Snappy compression.ACoder
that wraps aCoder<String>
and encodes/decodes values via string representations.A wrapper around a byte[] that uses structural, value-based equality rather than byte[]'s normal object identity.An abstract base class to implement aCoder
that defines equality, hashing, and printing via the class name and recursively usingStructuredCoder.getComponents()
.ACoder
that encodesInteger Integers
as the ASCII bytes of their textual, decimal, representation.TimestampPrefixingWindowCoder<T extends BoundedWindow>ATimestampPrefixingWindowCoder
wraps arbitrary user custom window coder.ZstdCoder<T>Wraps an existing coder with Zstandard compression.
Coder.Context
.