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

java.lang.Object
  extended by org.apache.avro.generic.GenericDatumWriter<Object>
      extended by org.apache.pig.piggybank.storage.avro.PigAvroDatumWriter
All Implemented Interfaces:
org.apache.avro.io.DatumWriter<Object>

public class PigAvroDatumWriter
extends org.apache.avro.generic.GenericDatumWriter<Object>

An avro GenericDatumWriter to write pig data as Avro data.


Constructor Summary
PigAvroDatumWriter(org.apache.avro.Schema schema)
          construct with output schema
 
Method Summary
protected  Iterator<? extends Object> getArrayElements(Object array)
          Called by the implementation of GenericDatumWriter.writeArray(org.apache.avro.Schema, java.lang.Object, org.apache.avro.io.Encoder) to enumerate array elements.
protected  long getArraySize(Object array)
          Called by the implementation of GenericDatumWriter.writeArray(org.apache.avro.Schema, java.lang.Object, org.apache.avro.io.Encoder) to get the size of an array.
protected  Object getField(Object record, String name, int pos)
          Called by the implementation of writeRecord(org.apache.avro.Schema, java.lang.Object, org.apache.avro.io.Encoder) to retrieve a record field value.
protected  boolean instanceOf(org.apache.avro.Schema schema, Object datum)
          Recursively check whether "datum" is an instance of "schema" and called by resolveUnionSchema(Schema,Object), unwrappedInstanceOf(Schema,Object).
protected  NullPointerException npe(NullPointerException e, String s)
          As of Avro 1.5.1 this method is now in the superclass so it's no longer needed here, but leaving here for backward compatibility with Avro 1.4.1.
protected  int resolveUnionSchema(org.apache.avro.Schema union, Object datum)
          Called to resolve union.
protected  void write(org.apache.avro.Schema schema, Object datum, org.apache.avro.io.Encoder out)
           
protected  void writeBoolean(Object datum, org.apache.avro.io.Encoder out)
          Write boolean.
protected  void writeBytes(Object datum, org.apache.avro.io.Encoder out)
          Called to write a bytes.
protected  void writeDouble(Object datum, org.apache.avro.io.Encoder out)
          Write double.
protected  void writeFixed(org.apache.avro.Schema schema, Object datum, org.apache.avro.io.Encoder out)
          Called to write a fixed value.
protected  void writeFloat(Object datum, org.apache.avro.io.Encoder out)
          Write float.
protected  void writeLong(Object datum, org.apache.avro.io.Encoder out)
          Write long.
protected  void writeRecord(org.apache.avro.Schema schema, Object datum, org.apache.avro.io.Encoder out)
          Overriding to fetch the field value from the Tuple.
protected  void writeUnion(org.apache.avro.Schema schema, Object datum, org.apache.avro.io.Encoder out)
          Called to write union.
 
Methods inherited from class org.apache.avro.generic.GenericDatumWriter
getData, getMapEntries, getMapSize, resolveUnion, setSchema, write, writeArray, writeEnum, writeField, writeMap, writeString, writeString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PigAvroDatumWriter

public PigAvroDatumWriter(org.apache.avro.Schema schema)
construct with output schema

Method Detail

write

protected void write(org.apache.avro.Schema schema,
                     Object datum,
                     org.apache.avro.io.Encoder out)
              throws IOException
Overrides:
write in class org.apache.avro.generic.GenericDatumWriter<Object>
Throws:
IOException

writeUnion

protected void writeUnion(org.apache.avro.Schema schema,
                          Object datum,
                          org.apache.avro.io.Encoder out)
                   throws IOException
Called to write union.

Throws:
IOException

resolveUnionSchema

protected int resolveUnionSchema(org.apache.avro.Schema union,
                                 Object datum)
                          throws IOException
Called to resolve union.

Throws:
IOException

instanceOf

protected boolean instanceOf(org.apache.avro.Schema schema,
                             Object datum)
                      throws IOException
Recursively check whether "datum" is an instance of "schema" and called by resolveUnionSchema(Schema,Object), unwrappedInstanceOf(Schema,Object).

Throws:
IOException

writeDouble

protected void writeDouble(Object datum,
                           org.apache.avro.io.Encoder out)
                    throws IOException
Write double. Users can cast long, float and integer to double.

Throws:
IOException

writeFloat

protected void writeFloat(Object datum,
                          org.apache.avro.io.Encoder out)
                   throws IOException
Write float. Users can cast long and integer into float.

Throws:
IOException

writeLong

protected void writeLong(Object datum,
                         org.apache.avro.io.Encoder out)
                  throws IOException
Write long. Users can cast integer into long.

Throws:
IOException

writeBoolean

protected void writeBoolean(Object datum,
                            org.apache.avro.io.Encoder out)
                     throws IOException
Write boolean. Users can cast an integer into boolean.

Throws:
IOException

npe

protected NullPointerException npe(NullPointerException e,
                                   String s)
As of Avro 1.5.1 this method is now in the superclass so it's no longer needed here, but leaving here for backward compatibility with Avro 1.4.1.

Overrides:
npe in class org.apache.avro.generic.GenericDatumWriter<Object>

writeBytes

protected void writeBytes(Object datum,
                          org.apache.avro.io.Encoder out)
                   throws IOException
Called to write a bytes.

Overrides:
writeBytes in class org.apache.avro.generic.GenericDatumWriter<Object>
Throws:
IOException

writeFixed

protected void writeFixed(org.apache.avro.Schema schema,
                          Object datum,
                          org.apache.avro.io.Encoder out)
                   throws IOException
Called to write a fixed value.

Overrides:
writeFixed in class org.apache.avro.generic.GenericDatumWriter<Object>
Throws:
IOException

writeRecord

protected void writeRecord(org.apache.avro.Schema schema,
                           Object datum,
                           org.apache.avro.io.Encoder out)
                    throws IOException
Overriding to fetch the field value from the Tuple.

Overrides:
writeRecord in class org.apache.avro.generic.GenericDatumWriter<Object>
Throws:
IOException

getField

protected Object getField(Object record,
                          String name,
                          int pos)
Called by the implementation of writeRecord(org.apache.avro.Schema, java.lang.Object, org.apache.avro.io.Encoder) to retrieve a record field value.


getArraySize

protected long getArraySize(Object array)
Called by the implementation of GenericDatumWriter.writeArray(org.apache.avro.Schema, java.lang.Object, org.apache.avro.io.Encoder) to get the size of an array.

Overrides:
getArraySize in class org.apache.avro.generic.GenericDatumWriter<Object>

getArrayElements

protected Iterator<? extends Object> getArrayElements(Object array)
Called by the implementation of GenericDatumWriter.writeArray(org.apache.avro.Schema, java.lang.Object, org.apache.avro.io.Encoder) to enumerate array elements.

Overrides:
getArrayElements in class org.apache.avro.generic.GenericDatumWriter<Object>


Copyright © 2007-2012 The Apache Software Foundation