org.apache.pig.impl.util
Class StorageUtil

java.lang.Object
  extended by org.apache.pig.impl.util.StorageUtil

public final class StorageUtil
extends Object

This util class provides methods that are shared by storage class PigStorage and streaming class PigStreaming


Field Summary
static StreamingDelimiters DEFAULT_DELIMITERS
           
 
Constructor Summary
StorageUtil()
           
 
Method Summary
static Tuple bytesToTuple(byte[] buf, int offset, int length, byte fieldDel)
          Transform bytes from a byte array up to the specified length to a Tuple
static byte parseFieldDel(String delimiter)
          Transform a String into a byte representing the field delimiter.
static void putField(OutputStream out, Object field)
           
static void putField(OutputStream out, Object field, boolean includeTypeInformation)
           
static void putField(OutputStream out, Object field, StreamingDelimiters delims, boolean includeTypeInformation)
          Serialize an object to an OutputStream in the field-delimited form.
static Tuple textToTuple(org.apache.hadoop.io.Text val, byte fieldDel)
          Transform a line of Text to a Tuple
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DELIMITERS

public static final StreamingDelimiters DEFAULT_DELIMITERS
Constructor Detail

StorageUtil

public StorageUtil()
Method Detail

parseFieldDel

public static byte parseFieldDel(String delimiter)
Transform a String into a byte representing the field delimiter.

Parameters:
delimiter - a string that may be in single-quoted form
Returns:
the field delimiter in byte form

putField

public static void putField(OutputStream out,
                            Object field)
                     throws IOException
Throws:
IOException

putField

public static void putField(OutputStream out,
                            Object field,
                            boolean includeTypeInformation)
                     throws IOException
Throws:
IOException

putField

public static void putField(OutputStream out,
                            Object field,
                            StreamingDelimiters delims,
                            boolean includeTypeInformation)
                     throws IOException
Serialize an object to an OutputStream in the field-delimited form.

Parameters:
out - an OutputStream object
field - an object to be serialized
Throws:
IOException - if serialization fails.

textToTuple

public static Tuple textToTuple(org.apache.hadoop.io.Text val,
                                byte fieldDel)
Transform a line of Text to a Tuple

Parameters:
val - a line of text
fieldDel - the field delimiter
Returns:
tuple constructed from the text

bytesToTuple

public static Tuple bytesToTuple(byte[] buf,
                                 int offset,
                                 int length,
                                 byte fieldDel)
Transform bytes from a byte array up to the specified length to a Tuple

Parameters:
buf - the byte array
length - number of bytes to consume from the byte array
fieldDel - the field delimiter
Returns:
tuple constructed from the bytes


Copyright © 2007-2012 The Apache Software Foundation