@Documented @Retention(value=RUNTIME) @Target(value=TYPE) public @interface DefaultCoder
DefaultCoder annotation
specifies a default Coder class to handle encoding and decoding
instances of the annotated class.
The specified Coder must implement a function with the following
signature:
public static Coder<T> of(Class<T> clazz) {...}
For example, to configure the use of Java serialization as the default
for a class, annotate the class to use
SerializableCoder as follows:the
@DefaultCoder(SerializableCoder.class)
public class MyCustomDataType {
// ...
}
Similarly, to configure the use of
AvroCoder as the default:
@DefaultCoder(AvroCoder.class)
public class MyCustomDataType {
public MyCustomDataType() {} // Avro requires an empty constructor.
// ...
}
Coders specified explicitly via
PCollection.setCoder
take precedence, followed by Coders registered at runtime via
CoderRegistry.registerCoder(java.lang.Class<?>, java.lang.Class<?>).