@InterfaceAudience.Public @InterfaceStability.Stable public abstract class StoreFunc extends java.lang.Object implements StoreFuncInterface
Constructor and Description |
---|
StoreFunc() |
Modifier and Type | Method and Description |
---|---|
void |
checkSchema(ResourceSchema s)
Set the schema for data to be stored.
|
void |
cleanupOnFailure(java.lang.String location,
org.apache.hadoop.mapreduce.Job job)
This method will be called by Pig if the job which contains this store
fails.
|
static void |
cleanupOnFailureImpl(java.lang.String location,
org.apache.hadoop.mapreduce.Job job)
Default implementation for
cleanupOnFailure(String, Job)
and cleanupOnSuccess(String, Job) . |
void |
cleanupOnSuccess(java.lang.String location,
org.apache.hadoop.mapreduce.Job job)
This method will be called by Pig if the job which contains this store
is successful, and some cleanup of intermediate resources is required.
|
abstract org.apache.hadoop.mapreduce.OutputFormat |
getOutputFormat()
Return the OutputFormat associated with StoreFunc.
|
abstract void |
prepareToWrite(org.apache.hadoop.mapreduce.RecordWriter writer)
Initialize StoreFunc to write data.
|
abstract void |
putNext(Tuple t)
Write a tuple to the data store.
|
java.lang.String |
relToAbsPathForStoreLocation(java.lang.String location,
org.apache.hadoop.fs.Path curDir)
This method is called by the Pig runtime in the front end to convert the
output location to an absolute path if the location is relative.
|
void |
setStoreFuncUDFContextSignature(java.lang.String signature)
This method will be called by Pig both in the front end and back end to
pass a unique signature to the
StoreFunc which it can use to store
information in the UDFContext which it needs to store between
various method invocations in the front end and back end. |
abstract void |
setStoreLocation(java.lang.String location,
org.apache.hadoop.mapreduce.Job job)
Communicate to the storer the location where the data needs to be stored.
|
void |
warn(java.lang.String msg,
java.lang.Enum warningEnum)
Issue a warning.
|
public java.lang.String relToAbsPathForStoreLocation(java.lang.String location, org.apache.hadoop.fs.Path curDir) throws java.io.IOException
relToAbsPathForStoreLocation
in interface StoreFuncInterface
location
- location as provided in the "store" statement of the scriptcurDir
- the current working direction based on any "cd" statements
in the script before the "store" statement. If there are no "cd" statements
in the script, this would be the home directory -
/user/
java.io.IOException
- if the conversion is not possiblepublic abstract org.apache.hadoop.mapreduce.OutputFormat getOutputFormat() throws java.io.IOException
getOutputFormat
in interface StoreFuncInterface
OutputFormat
associated with StoreFuncjava.io.IOException
- if an exception occurs while constructing the
OutputFormatpublic abstract void setStoreLocation(java.lang.String location, org.apache.hadoop.mapreduce.Job job) throws java.io.IOException
StoreFunc
here is the
return value of relToAbsPathForStoreLocation(String, Path)
This method will be called in the frontend and backend multiple times. Implementations
should bear in mind that this method is called multiple times and should
ensure there are no inconsistent side effects due to the multiple calls.
checkSchema(ResourceSchema)
will be called before any call to
setStoreLocation(String, Job)
.setStoreLocation
in interface StoreFuncInterface
location
- Location returned by
relToAbsPathForStoreLocation(String, Path)
job
- The Job
objectjava.io.IOException
- if the location is not valid.public void checkSchema(ResourceSchema s) throws java.io.IOException
checkSchema
in interface StoreFuncInterface
s
- to be checkedjava.io.IOException
- if this schema is not acceptable. It should include
a detailed error message indicating what is wrong with the schema.public abstract void prepareToWrite(org.apache.hadoop.mapreduce.RecordWriter writer) throws java.io.IOException
prepareToWrite
in interface StoreFuncInterface
writer
- RecordWriter to use.java.io.IOException
- if an exception occurs during initializationpublic abstract void putNext(Tuple t) throws java.io.IOException
putNext
in interface StoreFuncInterface
t
- the tuple to store.java.io.IOException
- if an exception occurs during the writepublic void setStoreFuncUDFContextSignature(java.lang.String signature)
StoreFunc
which it can use to store
information in the UDFContext
which it needs to store between
various method invocations in the front end and back end. This method
will be called before other methods in StoreFunc
. This is necessary
because in a Pig Latin script with multiple stores, the different
instances of store functions need to be able to find their (and only their)
data in the UDFContext object. The default implementation is a no-op.setStoreFuncUDFContextSignature
in interface StoreFuncInterface
signature
- a unique signature to identify this StoreFuncpublic void cleanupOnFailure(java.lang.String location, org.apache.hadoop.mapreduce.Job job) throws java.io.IOException
FileSystem
location.cleanupOnFailure
in interface StoreFuncInterface
location
- Location returned by
relToAbsPathForStoreLocation(String, Path)
job
- The Job
object - this should be used only to obtain
cluster properties through JobContext.getConfiguration()
and not to set/query
any runtime job information.java.io.IOException
public void cleanupOnSuccess(java.lang.String location, org.apache.hadoop.mapreduce.Job job) throws java.io.IOException
cleanupOnSuccess
in interface StoreFuncInterface
location
- Location returned by
relToAbsPathForStoreLocation(String, Path)
job
- The Job
object - this should be used only to obtain
cluster properties through JobContext.getConfiguration()
and not to set/query
any runtime job information.java.io.IOException
public static void cleanupOnFailureImpl(java.lang.String location, org.apache.hadoop.mapreduce.Job job) throws java.io.IOException
cleanupOnFailure(String, Job)
and cleanupOnSuccess(String, Job)
. This removes a file
from HDFS.location
- file name (or URI) of file to removejob
- Hadoop job, used to access the appropriate file system.java.io.IOException
public final void warn(java.lang.String msg, java.lang.Enum warningEnum)
msg
- String message of the warningwarningEnum
- type of warningCopyright © 2007-2012 The Apache Software Foundation