Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Avro, mail # user - Generic data extraction from an Avro file

Copy link to this message
Generic data extraction from an Avro file
Public Network Services 2013-02-05, 19:53

Assuming an application that only needs to quickly examine the contents of
a bunch of Avro data files (irrespective of binary or JSON encoding and
without any prior schema or object structure knowledge), an approach could
be to just extract the Avro records as text JSON records. To this effect, a
simple approach could be:

   1. Create a DataFileStream<GenericRecord>(FileInputStream,
   GenericDatumReader<GenericRecord>) from a FileInputStream to the file. (If
   the file is not an Avro data file, an IOException is caused.)
   2. Read GenericRecord records from the DataFileStream object, while its
   hasNext() method returns true.
   3. Convert each GenericRecord object read into a JSON string, via
   calling its toString() method.

For the test datasets in the Avro 1.7.3 distribution, this actually works

My question is, does anyone see any potential problems for (binary or JSON
encoded) Avro data files, given the above logic? For example, should the
GenericRecord.toString() method always produce a valid JSON string?