org.apache.pig
Class PigStreamingBase

java.lang.Object
  extended by org.apache.pig.PigStreamingBase
All Implemented Interfaces:
PigToStream, StreamToPig
Direct Known Subclasses:
PigStreaming, PigStreamingUDF

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract class PigStreamingBase
extends Object
implements PigToStream, StreamToPig

The interface is used for the custom mapping of - a Tuple to a byte array. The byte array is fed to the stdin of the streaming process. - a byte array, received from the stdout of the streaming process, to a Tuple. This interface is designed to provide a common protocol for data exchange between Pig runtime and streaming executables. Typically, a user implements this interface for a particular type of stream command and specifies the implementation class in the Pig DEFINE statement.

Since:
Pig 0.12

Constructor Summary
PigStreamingBase()
           
 
Method Summary
 Tuple deserialize(byte[] bytes)
          Deprecated. 
abstract  Tuple deserialize(byte[] bytes, int offset, int length)
          Given a byte array from a streaming executable, produce a tuple.
abstract  LoadCaster getLoadCaster()
          This will be called on the front end during planning and not on the back end during execution.
 byte[] serialize(Tuple t)
          Deprecated. 
abstract  WritableByteArray serializeToBytes(Tuple t)
          Given a tuple, produce an array of bytes to be passed to the streaming executable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PigStreamingBase

public PigStreamingBase()
Method Detail

serialize

@Deprecated
public final byte[] serialize(Tuple t)
                       throws IOException
Deprecated. 

Description copied from interface: PigToStream
Given a tuple, produce an array of bytes to be passed to the streaming executable.

Specified by:
serialize in interface PigToStream
Parameters:
t - Tuple to serialize
Returns:
Serialized form of the tuple
Throws:
IOException

serializeToBytes

public abstract WritableByteArray serializeToBytes(Tuple t)
                                            throws IOException
Given a tuple, produce an array of bytes to be passed to the streaming executable.

Parameters:
t - Tuple to serialize
Returns:
Serialized form of the tuple
Throws:
IOException

deserialize

@Deprecated
public final Tuple deserialize(byte[] bytes)
                        throws IOException
Deprecated. 

Description copied from interface: StreamToPig
Given a byte array from a streaming executable, produce a tuple.

Specified by:
deserialize in interface StreamToPig
Parameters:
bytes - to deserialize.
Returns:
Data as a Pig Tuple.
Throws:
IOException

deserialize

public abstract Tuple deserialize(byte[] bytes,
                                  int offset,
                                  int length)
                           throws IOException
Given a byte array from a streaming executable, produce a tuple.

Parameters:
bytes - bytes to deserialize.
offset - the offset in the byte array from which to deserialize.
length - the number of bytes from the offset of the byte array to deserialize.
Returns:
Data as a Pig Tuple.
Throws:
IOException

getLoadCaster

public abstract LoadCaster getLoadCaster()
                                  throws IOException
This will be called on the front end during planning and not on the back end during execution.

Specified by:
getLoadCaster in interface StreamToPig
Returns:
the LoadCaster associated with this object, or null if there is no such LoadCaster.
Throws:
IOException - if there is an exception during LoadCaster


Copyright © 2007-2012 The Apache Software Foundation