@Experimental public abstract class InferredRowCoder<T> extends CustomCoder<T>
Schema and then Row instances
based on the element type.
Relies on delegate elementCoder to encode original elements.
Coder.Context, Coder.NonDeterministicException| Constructor and Description |
|---|
InferredRowCoder() |
| Modifier and Type | Method and Description |
|---|---|
Row |
createRow(T element) |
T |
decode(java.io.InputStream inStream)
Decodes a value of type
T from the given input stream in
the given context. |
void |
encode(T value,
java.io.OutputStream outStream)
Encodes the given value of type
T onto the given output stream. |
static <W> InferredRowCoder<W> |
of(java.lang.Class<W> elementType,
Coder<W> elementCoder)
|
static <W extends java.io.Serializable> |
ofSerializable(java.lang.Class<W> elementType)
Creates a
InferredRowCoder delegating to the SerializableCoder
for encoding the PCollection elements. |
RowCoder |
rowCoder() |
Schema |
schema() |
void |
verifyDeterministic()
Throw
Coder.NonDeterministicException if the coding is not deterministic. |
InferredRowCoder<T> |
withSchemaFactory(SchemaFactory schemaFactory)
Returns a
InferredRowCoder with row type factory overridden by schemaFactory. |
getCoderArgumentsconsistentWithEquals, decode, encode, getEncodedElementByteSize, getEncodedTypeDescriptor, isRegisterByteSizeObserverCheap, registerByteSizeObserver, structuralValue, verifyDeterministic, verifyDeterministicpublic static <W extends java.io.Serializable> InferredRowCoder<W> ofSerializable(java.lang.Class<W> elementType)
InferredRowCoder delegating to the SerializableCoder
for encoding the PCollection elements.public static <W> InferredRowCoder<W> of(java.lang.Class<W> elementType, Coder<W> elementCoder)
public InferredRowCoder<T> withSchemaFactory(SchemaFactory schemaFactory)
InferredRowCoder with row type factory overridden by schemaFactory.public Schema schema()
public RowCoder rowCoder()
public void encode(T value, java.io.OutputStream outStream) throws java.io.IOException
CoderT onto the given output stream.encode in class Coder<T>java.io.IOException - if writing to the OutputStream fails
for some reasonCoderException - if the value could not be encoded for some reasonpublic T decode(java.io.InputStream inStream) throws java.io.IOException
CoderT from the given input stream in
the given context. Returns the decoded value.decode in class Coder<T>java.io.IOException - if reading from the InputStream fails
for some reasonCoderException - if the value could not be decoded for some reasonpublic void verifyDeterministic()
throws Coder.NonDeterministicException
CustomCoderCoder.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 class CustomCoder<T>Coder.NonDeterministicException - if this coder is not deterministic.