Package org.apache.beam.sdk.coders
Class RowCoderGenerator
- java.lang.Object
-
- org.apache.beam.sdk.coders.RowCoderGenerator
-
@Experimental(SCHEMAS) public abstract class RowCoderGenerator extends java.lang.Object
A utility for automatically generating aCoder
forRow
objects corresponding to a specific schema. The resulting coder is loaded into the default ClassLoader and returned.When
generate(Schema)
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 extendsCoder<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; } @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); } @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 Summary
Constructors Constructor Description RowCoderGenerator()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Coder<Row>
generate(Schema schema)
static void
overrideEncodingPositions(java.util.UUID uuid, java.util.Map<java.lang.String,java.lang.Integer> encodingPositions)
-