public class StoreFuncWrapper extends java.lang.Object implements StoreFuncInterface
Modifier | Constructor and Description |
---|---|
protected |
StoreFuncWrapper() |
Modifier and Type | Method and Description |
---|---|
void |
checkSchema(ResourceSchema resourceSchema)
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.
|
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.
|
protected java.lang.String |
getMethodName(int depth)
Returns a method in the call stack at the given depth.
|
org.apache.hadoop.mapreduce.OutputFormat |
getOutputFormat()
Return the OutputFormat associated with StoreFuncInterface.
|
void |
prepareToWrite(org.apache.hadoop.mapreduce.RecordWriter recordWriter)
Initialize StoreFuncInterface to write data.
|
void |
putNext(Tuple tuple)
Write a tuple to the data store.
|
java.lang.String |
relToAbsPathForStoreLocation(java.lang.String location,
org.apache.hadoop.fs.Path path)
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.
|
protected void |
setStoreFunc(StoreFuncInterface storeFunc)
The wrapped StoreFuncInterface object must be set before method calls are made on this object.
|
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
StoreFuncInterface 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. |
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.
|
protected void setStoreFunc(StoreFuncInterface storeFunc)
storeFunc
- public java.lang.String relToAbsPathForStoreLocation(java.lang.String location, org.apache.hadoop.fs.Path path) throws java.io.IOException
StoreFuncInterface
LoadFunc.getAbsolutePath(java.lang.String, org.apache.hadoop.fs.Path)
provides a default
implementation for hdfs and hadoop local file system and it can be used
to implement this method.relToAbsPathForStoreLocation
in interface StoreFuncInterface
location
- location as provided in the "store" statement of the scriptpath
- 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 org.apache.hadoop.mapreduce.OutputFormat getOutputFormat() throws java.io.IOException
StoreFuncInterface
getOutputFormat
in interface StoreFuncInterface
OutputFormat
associated with StoreFuncInterfacejava.io.IOException
- if an exception occurs while constructing the
OutputFormatpublic void setStoreLocation(java.lang.String location, org.apache.hadoop.mapreduce.Job job) throws java.io.IOException
StoreFuncInterface
StoreFuncInterface
here is the
return value of StoreFuncInterface.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.
StoreFuncInterface.checkSchema(ResourceSchema)
will be called before any call to
StoreFuncInterface.setStoreLocation(String, Job)
.setStoreLocation
in interface StoreFuncInterface
location
- Location returned by
StoreFuncInterface.relToAbsPathForStoreLocation(String, Path)
job
- The Job
objectjava.io.IOException
- if the location is not valid.public void checkSchema(ResourceSchema resourceSchema) throws java.io.IOException
StoreFuncInterface
checkSchema
in interface StoreFuncInterface
resourceSchema
- 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 void prepareToWrite(org.apache.hadoop.mapreduce.RecordWriter recordWriter) throws java.io.IOException
StoreFuncInterface
prepareToWrite
in interface StoreFuncInterface
recordWriter
- RecordWriter to use.java.io.IOException
- if an exception occurs during initializationpublic void putNext(Tuple tuple) throws java.io.IOException
StoreFuncInterface
putNext
in interface StoreFuncInterface
tuple
- the tuple to store.java.io.IOException
- if an exception occurs during the writepublic void setStoreFuncUDFContextSignature(java.lang.String signature)
StoreFuncInterface
StoreFuncInterface
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 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.setStoreFuncUDFContextSignature
in interface StoreFuncInterface
signature
- a unique signature to identify this StoreFuncInterfacepublic void cleanupOnFailure(java.lang.String location, org.apache.hadoop.mapreduce.Job job) throws java.io.IOException
StoreFuncInterface
cleanupOnFailure
in interface StoreFuncInterface
location
- Location returned by
StoreFuncInterface.relToAbsPathForStoreLocation(String, Path)
job
- The Job
object - this should be used only to obtain
cluster properties through JobContextImpl.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
StoreFuncInterface
cleanupOnSuccess
in interface StoreFuncInterface
location
- Location returned by
StoreFuncInterface.relToAbsPathForStoreLocation(String, Path)
job
- The Job
object - this should be used only to obtain
cluster properties through JobContextImpl.getConfiguration()
and not to set/query
any runtime job information.java.io.IOException
protected java.lang.String getMethodName(int depth)
depth
- Copyright © 2007-2017 The Apache Software Foundation