public static < E > Schema getWriterSchema ( Class < E > type , Schema schema ) { Schema writerSchema = schema ; GenericData dataModel = getDataModelForType ( type ) ; if ( dataModel instanceof AllowNulls ) { // assume fields are non-null by default to avoid schema conflicts dataModel = ReflectData . get ( ) ; } if ( dataModel instanceof SpecificData ) { writerSchema = ( ( SpecificData ) dataModel ) . getSchema ( type ) ; } return writerSchema ; }
Get the writer schema based on the given type and dataset schema .