org.apache.pig.impl.streaming
Class InputHandler

java.lang.Object
  extended by org.apache.pig.impl.streaming.InputHandler
Direct Known Subclasses:
DefaultInputHandler, FileInputHandler

public abstract class InputHandler
extends Object

InputHandler is responsible for handling the input to the Pig-Streaming external command. The managed executable could be fed input in a InputHandler.InputType.SYNCHRONOUS manner via its stdin or in an InputHandler.InputType.ASYNCHRONOUS manner via an external file which is subsequently read by the executable.


Nested Class Summary
static class InputHandler.InputType
           
 
Field Summary
protected  boolean alreadyClosed
           
protected  PigToStream serializer
           
 
Constructor Summary
InputHandler()
           
 
Method Summary
 void bindTo(OutputStream os)
          Bind the InputHandler to the OutputStream from which it reads input and sends it to the managed process.
 void close(Process process)
          Close the InputHandler since there is no more input to be sent to the managed process.
abstract  InputHandler.InputType getInputType()
          Get the handled InputType
 void putNext(Tuple t)
          Send the given input Tuple to the managed executable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serializer

protected PigToStream serializer

alreadyClosed

protected boolean alreadyClosed
Constructor Detail

InputHandler

public InputHandler()
Method Detail

getInputType

public abstract InputHandler.InputType getInputType()
Get the handled InputType

Returns:
the handled InputType

putNext

public void putNext(Tuple t)
             throws IOException
Send the given input Tuple to the managed executable.

Parameters:
t - input Tuple
Throws:
IOException

close

public void close(Process process)
           throws IOException
Close the InputHandler since there is no more input to be sent to the managed process.

Parameters:
process - the managed process - this could be null in some cases like when input is through files. In that case, the process would not have been exec'ed yet - if this method if overridden it is the responsibility of the implementer to check that the process is usable. The managed process object is supplied by the ExecutableManager to this call so that this method can check if the process is alive if it needs to know.
Throws:
IOException

bindTo

public void bindTo(OutputStream os)
            throws IOException
Bind the InputHandler to the OutputStream from which it reads input and sends it to the managed process.

Parameters:
os - OutputStream from which to read input data for the managed process
Throws:
IOException


Copyright © ${year} The Apache Software Foundation