You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Scott Carey <sc...@apache.org> on 2012/04/02 17:56:26 UTC

Re: read a compressed avro file

Reading an Avro file is the same for all compression types. The header of
the file contains what compression codec is used and the schema for the data
within it.

A basic read may look like:

DataFileReader<Object> reader = new DataFileReader<Object>(myFile, new
GenericDatumReader<Object>());
try {
  for(Object datum : reader) {
    // do something with the datum
  }
} finally {
  reader.close();
}
The documentation is here:
http://avro.apache.org/docs/1.6.3/api/java/org/apache/avro/file/DataFileRead
er.html
or
http://avro.apache.org/docs/1.6.3/api/java/org/apache/avro/file/DataFileStre
am.html

Several examples can be found in the unit tests named TestDataFile*.java:
http://svn.apache.org/viewvc/avro/tags/release-1.6.3/lang/java/avro/src/test
/java/org/apache/avro/


On 3/30/12 11:10 PM, "Weishung Chung" <we...@gmail.com> wrote:

> java 
> 
> On Sat, Mar 31, 2012 at 12:44 AM, Miki Tebeka <mi...@gmail.com> wrote:
>>> > Could you guide me to an example on how to read a compressed avro file
>>> > (snappy) ?
>> In which programming language?
> 



Re: read a compressed avro file

Posted by Weishung Chung <we...@gmail.com>.
Thank you Scott. I will try it out :)

On Mon, Apr 2, 2012 at 10:56 AM, Scott Carey <sc...@apache.org> wrote:

> Reading an Avro file is the same for all compression types. The header of
> the file contains what compression codec is used and the schema for the
> data within it.
>
> A basic read may look like:
>
> DataFileReader<Object> reader = new DataFileReader<Object>(myFile, new GenericDatumReader<Object>());
> try {
>   for(Object datum : reader) {
>     // do something with the datum
>   }
> } finally {
>   reader.close();
> }
>
> The documentation is here:
>
> http://avro.apache.org/docs/1.6.3/api/java/org/apache/avro/file/DataFileReader.html
> or
>
> http://avro.apache.org/docs/1.6.3/api/java/org/apache/avro/file/DataFileStream.html
>
> Several examples can be found in the unit tests named TestDataFile*.java:
>
> http://svn.apache.org/viewvc/avro/tags/release-1.6.3/lang/java/avro/src/test/java/org/apache/avro
> /
>
>
> On 3/30/12 11:10 PM, "Weishung Chung" <we...@gmail.com> wrote:
>
> java
>
> On Sat, Mar 31, 2012 at 12:44 AM, Miki Tebeka <mi...@gmail.com>wrote:
>
>> > Could you guide me to an example on how to read a compressed avro file
>> > (snappy) ?
>> In which programming language?
>>
>
>