public abstract class RowCoderGenerator
extends java.lang.Object
Coder
for Row
objects corresponding to a
specific schema. The resulting coder is loaded into the default ClassLoader and returned.
When generate(Schema, UUID)
is called, a new subclass of Coder<Row> is generated for the specified schema. This class is generated using low-level
bytecode generation, and hardcodes encodings for all fields of the Schema. Empirically, this is
30-40% faster than a coder that introspects the schema.
The generated class corresponds to the following Java class:
class SchemaRowCoder extends Coder<Row> {
// Generated array containing a coder for each field in the Schema.
private static final Coder[] FIELD_CODERS;
// Generated method to return the schema this class corresponds to. Used during code
// generation.
private static getSchema() {
return schema;
}
{@literal @}Override public void encode(T value, OutputStream outStream) {
// Delegate to a method that evaluates each coder in the static array.
encodeDelegate(FIELD_CODERS, value, outStream);
}
{@literal @}Overide public abstract T decode(InputStream inStream) {
// Delegate to a method that evaluates each coder in the static array.
return decodeDelegate(FIELD_CODERS, inStream);
}
}
Constructor and Description |
---|
RowCoderGenerator() |
Modifier and Type | Method and Description |
---|---|
static Coder<Row> |
generate(Schema schema,
java.util.UUID coderId) |