org.apache.pig.piggybank.storage.avro
Class PigAvroDatumReader

java.lang.Object
  extended by org.apache.avro.generic.GenericDatumReader<Object>
      extended by org.apache.pig.piggybank.storage.avro.PigAvroDatumReader
All Implemented Interfaces:
org.apache.avro.io.DatumReader<Object>

public class PigAvroDatumReader
extends org.apache.avro.generic.GenericDatumReader<Object>

An avro GenericDatumReader which reads in avro data and converts them to pig data: tuples, bags, etc.


Constructor Summary
PigAvroDatumReader(org.apache.avro.Schema schema)
          Construct where the writer's and reader's schemas are the same.
PigAvroDatumReader(org.apache.avro.Schema writer, org.apache.avro.Schema reader)
          Construct given writer's and reader's schema.
 
Method Summary
protected  void addToArray(Object array, long pos, Object e)
          Called by the default implementation of GenericDatumReader.readArray(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to add a value.
protected  Object createEnum(String symbol, org.apache.avro.Schema schema)
          Called to create an enum value.
protected  Object newArray(Object old, int size, org.apache.avro.Schema schema)
          Called to create new array instances.
protected  Object newRecord(Object old, org.apache.avro.Schema schema)
          Called to create new record instances.
protected  Object peekArray(Object array)
          Called by the default implementation of GenericDatumReader.readArray(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to retrieve a value from a reused instance.
protected  Object readBytes(Object old, org.apache.avro.io.Decoder in)
          Called to read byte arrays.
protected  Object readFixed(Object old, org.apache.avro.Schema expected, org.apache.avro.io.Decoder in)
          Called to read a fixed value.
protected  Object readMap(Object old, org.apache.avro.Schema expected, org.apache.avro.io.ResolvingDecoder in)
          Called to read a map instance.
protected  Object readRecord(Object old, org.apache.avro.Schema expected, org.apache.avro.io.ResolvingDecoder in)
          Called to read a record instance.
protected  Object readString(Object old, org.apache.avro.Schema expected, org.apache.avro.io.Decoder in)
          Called to read strings.
 
Methods inherited from class org.apache.avro.generic.GenericDatumReader
addToMap, createBytes, createFixed, createFixed, createString, findStringClass, getData, getExpected, getResolver, getSchema, newInstanceFromString, newMap, read, read, readArray, readBytes, readEnum, readField, readInt, readMapKey, readString, setExpected, setSchema, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PigAvroDatumReader

public PigAvroDatumReader(org.apache.avro.Schema schema)
Construct where the writer's and reader's schemas are the same.


PigAvroDatumReader

public PigAvroDatumReader(org.apache.avro.Schema writer,
                          org.apache.avro.Schema reader)
                   throws IOException
Construct given writer's and reader's schema.

Throws:
IOException
Method Detail

readRecord

protected Object readRecord(Object old,
                            org.apache.avro.Schema expected,
                            org.apache.avro.io.ResolvingDecoder in)
                     throws IOException
Called to read a record instance. Overridden to read a pig tuple.

Overrides:
readRecord in class org.apache.avro.generic.GenericDatumReader<Object>
Throws:
IOException

readMap

protected Object readMap(Object old,
                         org.apache.avro.Schema expected,
                         org.apache.avro.io.ResolvingDecoder in)
                  throws IOException
Called to read a map instance. Overridden to read a pig map.

Overrides:
readMap in class org.apache.avro.generic.GenericDatumReader<Object>
Throws:
IOException

createEnum

protected Object createEnum(String symbol,
                            org.apache.avro.Schema schema)
Called to create an enum value. Overridden to create a pig string.

Overrides:
createEnum in class org.apache.avro.generic.GenericDatumReader<Object>

peekArray

protected Object peekArray(Object array)
Called by the default implementation of GenericDatumReader.readArray(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to retrieve a value from a reused instance.

Overrides:
peekArray in class org.apache.avro.generic.GenericDatumReader<Object>

addToArray

protected void addToArray(Object array,
                          long pos,
                          Object e)
Called by the default implementation of GenericDatumReader.readArray(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to add a value. Overridden to append to pig bag.

Overrides:
addToArray in class org.apache.avro.generic.GenericDatumReader<Object>

readFixed

protected Object readFixed(Object old,
                           org.apache.avro.Schema expected,
                           org.apache.avro.io.Decoder in)
                    throws IOException
Called to read a fixed value. Overridden to read a pig byte array.

Overrides:
readFixed in class org.apache.avro.generic.GenericDatumReader<Object>
Throws:
IOException

newRecord

protected Object newRecord(Object old,
                           org.apache.avro.Schema schema)
Called to create new record instances. Overridden to return a new tuple.

Overrides:
newRecord in class org.apache.avro.generic.GenericDatumReader<Object>

newArray

protected Object newArray(Object old,
                          int size,
                          org.apache.avro.Schema schema)
Called to create new array instances. Overridden to return a new bag.

Overrides:
newArray in class org.apache.avro.generic.GenericDatumReader<Object>

readString

protected Object readString(Object old,
                            org.apache.avro.Schema expected,
                            org.apache.avro.io.Decoder in)
                     throws IOException
Called to read strings. Overridden to return a pig string.

Overrides:
readString in class org.apache.avro.generic.GenericDatumReader<Object>
Throws:
IOException

readBytes

protected Object readBytes(Object old,
                           org.apache.avro.io.Decoder in)
                    throws IOException
Called to read byte arrays. Overridden to return a pig byte array.

Overrides:
readBytes in class org.apache.avro.generic.GenericDatumReader<Object>
Throws:
IOException


Copyright © 2007-2012 The Apache Software Foundation