org.apache.pig.builtin
Class Utf8StorageConverter

java.lang.Object
  extended by org.apache.pig.builtin.Utf8StorageConverter
All Implemented Interfaces:
LoadCaster

public class Utf8StorageConverter
extends Object
implements LoadCaster

This abstract class provides standard conversions between utf8 encoded data and pig data types. It is intended to be extended by load and store functions (such as PigStorage).


Field Summary
protected  BagFactory mBagFactory
           
protected  org.apache.commons.logging.Log mLog
           
protected  TupleFactory mTupleFactory
           
 
Constructor Summary
Utf8StorageConverter()
           
 
Method Summary
 DataBag bytesToBag(byte[] b, ResourceSchema.ResourceFieldSchema schema)
          Cast data from bytes to bag value.
 Boolean bytesToBoolean(byte[] b)
           
 String bytesToCharArray(byte[] b)
          Cast data from bytes to chararray value.
 Double bytesToDouble(byte[] b)
          Cast data from bytes to double value.
 Float bytesToFloat(byte[] b)
          Cast data from bytes to float value.
 Integer bytesToInteger(byte[] b)
          Cast data from bytes to integer value.
 Long bytesToLong(byte[] b)
          Cast data from bytes to long value.
 Map<String,Object> bytesToMap(byte[] b)
          Cast data from bytes to map value.
 Tuple bytesToTuple(byte[] b, ResourceSchema.ResourceFieldSchema fieldSchema)
          Cast data from bytes to tuple value.
 byte[] toBytes(DataBag bag)
           
 byte[] toBytes(Double d)
           
 byte[] toBytes(Float f)
           
 byte[] toBytes(Integer i)
           
 byte[] toBytes(Long l)
           
 byte[] toBytes(Map<String,Object> m)
           
 byte[] toBytes(String s)
           
 byte[] toBytes(Tuple t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mBagFactory

protected BagFactory mBagFactory

mTupleFactory

protected TupleFactory mTupleFactory

mLog

protected final org.apache.commons.logging.Log mLog
Constructor Detail

Utf8StorageConverter

public Utf8StorageConverter()
Method Detail

bytesToBag

public DataBag bytesToBag(byte[] b,
                          ResourceSchema.ResourceFieldSchema schema)
                   throws IOException
Description copied from interface: LoadCaster
Cast data from bytes to bag value.

Specified by:
bytesToBag in interface LoadCaster
Parameters:
b - byte array to be cast.
schema - field schema for the output bag
Returns:
Bag value.
Throws:
IOException - if the value cannot be cast.

bytesToCharArray

public String bytesToCharArray(byte[] b)
                        throws IOException
Description copied from interface: LoadCaster
Cast data from bytes to chararray value.

Specified by:
bytesToCharArray in interface LoadCaster
Parameters:
b - byte array to be cast.
Returns:
String value.
Throws:
IOException - if the value cannot be cast.

bytesToDouble

public Double bytesToDouble(byte[] b)
Description copied from interface: LoadCaster
Cast data from bytes to double value.

Specified by:
bytesToDouble in interface LoadCaster
Parameters:
b - byte array to be cast.
Returns:
Double value.

bytesToFloat

public Float bytesToFloat(byte[] b)
                   throws IOException
Description copied from interface: LoadCaster
Cast data from bytes to float value.

Specified by:
bytesToFloat in interface LoadCaster
Parameters:
b - byte array to be cast.
Returns:
Float value.
Throws:
IOException - if the value cannot be cast.

bytesToBoolean

public Boolean bytesToBoolean(byte[] b)
                       throws IOException
Throws:
IOException

bytesToInteger

public Integer bytesToInteger(byte[] b)
                       throws IOException
Description copied from interface: LoadCaster
Cast data from bytes to integer value.

Specified by:
bytesToInteger in interface LoadCaster
Parameters:
b - byte array to be cast.
Returns:
Double value.
Throws:
IOException - if the value cannot be cast.

bytesToLong

public Long bytesToLong(byte[] b)
                 throws IOException
Description copied from interface: LoadCaster
Cast data from bytes to long value.

Specified by:
bytesToLong in interface LoadCaster
Parameters:
b - byte array to be cast.
Returns:
Long value.
Throws:
IOException - if the value cannot be cast.

bytesToMap

public Map<String,Object> bytesToMap(byte[] b)
                              throws IOException
Description copied from interface: LoadCaster
Cast data from bytes to map value.

Specified by:
bytesToMap in interface LoadCaster
Parameters:
b - byte array to be cast.
Returns:
Map value.
Throws:
IOException - if the value cannot be cast.

bytesToTuple

public Tuple bytesToTuple(byte[] b,
                          ResourceSchema.ResourceFieldSchema fieldSchema)
                   throws IOException
Description copied from interface: LoadCaster
Cast data from bytes to tuple value.

Specified by:
bytesToTuple in interface LoadCaster
Parameters:
b - byte array to be cast.
fieldSchema - field schema for the output tuple
Returns:
Tuple value.
Throws:
IOException - if the value cannot be cast.

toBytes

public byte[] toBytes(DataBag bag)
               throws IOException
Throws:
IOException

toBytes

public byte[] toBytes(String s)
               throws IOException
Throws:
IOException

toBytes

public byte[] toBytes(Double d)
               throws IOException
Throws:
IOException

toBytes

public byte[] toBytes(Float f)
               throws IOException
Throws:
IOException

toBytes

public byte[] toBytes(Integer i)
               throws IOException
Throws:
IOException

toBytes

public byte[] toBytes(Long l)
               throws IOException
Throws:
IOException

toBytes

public byte[] toBytes(Map<String,Object> m)
               throws IOException
Throws:
IOException

toBytes

public byte[] toBytes(Tuple t)
               throws IOException
Throws:
IOException


Copyright © ${year} The Apache Software Foundation