org.apache.pig
Interface StoreFunc

All Known Subinterfaces:
ReversibleLoadStoreFunc
All Known Implementing Classes:
BinaryStorage, BinStorage, PigDump, PigStorage

public interface StoreFunc

This interface is used to implement functions to write records from a dataset.


Method Summary
 void bindTo(OutputStream os)
          Specifies the OutputStream to write to.
 void finish()
          Do any kind of post processing because the last tuple has been stored.
 Class getStorePreparationClass()
          Specify a backend specific class to use to prepare for storing output.
 void putNext(Tuple f)
          Write a tuple the output stream to which this instance was previously bound.
 

Method Detail

bindTo

void bindTo(OutputStream os)
            throws IOException
Specifies the OutputStream to write to. This will be called before store(Tuple) is invoked.

Parameters:
os - The stream to write tuples to.
Throws:
IOException

putNext

void putNext(Tuple f)
             throws IOException
Write a tuple the output stream to which this instance was previously bound.

Parameters:
f - the tuple to store.
Throws:
IOException

finish

void finish()
            throws IOException
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.

Throws:
IOException

getStorePreparationClass

Class getStorePreparationClass()
                               throws IOException
Specify a backend specific class to use to prepare for storing output. In the Hadoop case, this can return an OutputFormat that will be used instead of PigOutputFormat. The framework will call this function and if a Class is returned that implements OutputFormat it will be used. For more details on how the OutputFormat should interact with Pig, see PigOutputFormat.getRecordWriter(org.apache.hadoop.fs.FileSystem, org.apache.hadoop.mapred.JobConf, String, org.apache.hadoop.util.Progressable)

Returns:
Backend specific class used to prepare for storing output. If the StoreFunc implementation does not have a class to prepare for storing output, it can return null and a default Pig implementation will be used to prepare for storing output.
Throws:
IOException - if the class does not implement the expected interface(s).


Copyright © ${year} The Apache Software Foundation