public void serializeToDisk ( final File file ) throws IOException { final DatumWriter datumWriter = new GenericDatumWriter < GenericRecord > ( ) ; final DataFileWriter fileWriter = new DataFileWriter < GenericRecord > ( datumWriter ) ; final AvroParquetReader < GenericRecord > reader = createAvroReader ( ) ; fileWriter . create ( createAvroSchema ( ) , file ) ; GenericRecord record = reader . read ( ) ; while ( record != null ) { fileWriter . append ( record ) ; record = reader . read ( ) ; } try { reader . close ( ) ; } catch ( IOException ex ) { LOG . log ( Level . SEVERE , ex . getMessage ( ) ) ; throw ex ; } try { fileWriter . close ( ) ; } catch ( IOException ex ) { LOG . log ( Level . SEVERE , ex . getMessage ( ) ) ; throw ex ; } }
Serialize Avro data to a local file .