Skip to content

Instantly share code, notes, and snippets.

@tom-code
Created October 27, 2017 16:33
Show Gist options
  • Save tom-code/1582c1294e54b060da1b20fbcb52045e to your computer and use it in GitHub Desktop.
Save tom-code/1582c1294e54b060da1b20fbcb52045e to your computer and use it in GitHub Desktop.
decode avro data (java/generic)
//avro-tools.jar needed
Schema schema = new Schema.Parser().parse(new File("/data/work/avro/message.avro"));
DatumReader<GenericRecord> dr = new GenericDatumReader<GenericRecord>(schema);
InputStream in = new FileInputStream(new File("/data/work/avro/record_pack/record_1_202571858.bin"));
BinaryDecoder decoder= DecoderFactory.get().binaryDecoder(in, null);
GenericRecord out = dr.read(null, decoder);
System.out.println(out);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment