org.apache.pig.builtin
Class BinStorage

java.lang.Object
  extended by org.apache.pig.builtin.BinStorage
All Implemented Interfaces:
LoadFunc, ReversibleLoadStoreFunc, StoreFunc
Direct Known Subclasses:
RandomSampleLoader

public class BinStorage
extends Object
implements ReversibleLoadStoreFunc


Field Summary
protected  long end
           
protected  BufferedPositionedInputStream in
           
 
Constructor Summary
BinStorage()
          Simple binary nested reader format
 
Method Summary
 void bindTo(OutputStream os)
          Specifies the OutputStream to write to.
 void bindTo(String fileName, BufferedPositionedInputStream in, long offset, long end)
          Specifies a portion of an InputStream to read tuples.
 boolean equals(Object obj)
           
 void finish()
          Do any kind of post processing because the last tuple has been stored.
 Tuple getNext()
          Retrieves the next tuple to be processed.
 void putNext(Tuple t)
          Write a tuple the output stream to which this instance was previously bound.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

protected BufferedPositionedInputStream in

end

protected long end
Constructor Detail

BinStorage

public BinStorage()
Simple binary nested reader format

Method Detail

getNext

public Tuple getNext()
              throws IOException
Description copied from interface: LoadFunc
Retrieves the next tuple to be processed.

Specified by:
getNext in interface LoadFunc
Returns:
the next tuple to be processed or null if there are no more tuples to be processed.
Throws:
IOException

bindTo

public void bindTo(String fileName,
                   BufferedPositionedInputStream in,
                   long offset,
                   long end)
            throws IOException
Description copied from interface: LoadFunc
Specifies a portion of an InputStream to read tuples. Because the starting and ending offsets may not be on record boundaries it is up to the implementor to deal with figuring out the actual starting and ending offsets in such a way that an arbitrarily sliced up file will be processed in its entirety.

A common way of handling slices in the middle of records is to start at the given offset and, if the offset is not zero, skip to the end of the first record (which may be a partial record) before reading tuples. Reading continues until a tuple has been read that ends at an offset past the ending offset.

The load function should not do any buffering on the input stream. Buffering will cause the offsets returned by is.getPos() to be unreliable.

Specified by:
bindTo in interface LoadFunc
Parameters:
fileName - the name of the file to be read
in - the stream representing the file to be processed, and which can also provide its position.
offset - the offset to start reading tuples.
end - the ending offset for reading.
Throws:
IOException

bindTo

public void bindTo(OutputStream os)
            throws IOException
Description copied from interface: StoreFunc
Specifies the OutputStream to write to. This will be called before store(Tuple) is invoked.

Specified by:
bindTo in interface StoreFunc
Parameters:
os - The stream to write tuples to.
Throws:
IOException

finish

public void finish()
            throws IOException
Description copied from interface: StoreFunc
Do any kind of post processing because the last tuple has been stored. DO NOT CLOSE THE STREAM in this method. The stream will be closed later outside of this function.

Specified by:
finish in interface StoreFunc
Throws:
IOException

putNext

public void putNext(Tuple t)
             throws IOException
Description copied from interface: StoreFunc
Write a tuple the output stream to which this instance was previously bound.

Specified by:
putNext in interface StoreFunc
Parameters:
t - the tuple to store.
Throws:
IOException

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © ${year} The Apache Software Foundation