Class RowCoderGenerator


  • @Experimental(SCHEMAS)
    public abstract class RowCoderGenerator
    extends java.lang.Object
    A utility for automatically generating a Coder for Row 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);
       }
     }
     
    • 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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RowCoderGenerator

        public RowCoderGenerator()
    • Method Detail

      • overrideEncodingPositions

        public static void overrideEncodingPositions​(java.util.UUID uuid,
                                                     java.util.Map<java.lang.String,​java.lang.Integer> encodingPositions)