|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.pig.StoreFunc
org.apache.pig.piggybank.storage.DBStorage
public class DBStorage
| Field Summary | |
|---|---|
protected ResourceSchema |
schema
|
| Constructor Summary | |
|---|---|
DBStorage(String driver,
String jdbcURL,
String insertQuery)
|
|
DBStorage(String driver,
String jdbcURL,
String user,
String pass,
String insertQuery)
|
|
DBStorage(String driver,
String jdbcURL,
String user,
String pass,
String insertQuery,
String batchSize)
|
|
| Method Summary | |
|---|---|
void |
checkSchema(ResourceSchema s)
Set the schema for data to be stored. |
org.apache.hadoop.mapreduce.OutputFormat |
getOutputFormat()
Return the OutputFormat associated with StoreFunc. |
void |
prepareToWrite(org.apache.hadoop.mapreduce.RecordWriter writer)
Initialise the database connection and prepared statement here. |
void |
putNext(Tuple tuple)
Write the tuple to Database directly here. |
void |
setStoreFuncUDFContextSignature(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. |
void |
setStoreLocation(String location,
org.apache.hadoop.mapreduce.Job job)
Communicate to the storer the location where the data needs to be stored. |
protected int |
sqlDataTypeFromPigDataType(byte pigDataType)
|
| Methods inherited from class org.apache.pig.StoreFunc |
|---|
cleanupOnFailure, cleanupOnFailureImpl, cleanupOnSuccess, relToAbsPathForStoreLocation, warn |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ResourceSchema schema
| Constructor Detail |
|---|
public DBStorage(String driver,
String jdbcURL,
String insertQuery)
public DBStorage(String driver,
String jdbcURL,
String user,
String pass,
String insertQuery)
throws SQLException
SQLException
public DBStorage(String driver,
String jdbcURL,
String user,
String pass,
String insertQuery,
String batchSize)
throws RuntimeException
RuntimeException| Method Detail |
|---|
public void putNext(Tuple tuple)
throws IOException
putNext in interface StoreFuncInterfaceputNext in class StoreFunctuple - the tuple to store.
IOException - if an exception occurs during the writeprotected int sqlDataTypeFromPigDataType(byte pigDataType)
public org.apache.hadoop.mapreduce.OutputFormat getOutputFormat()
throws IOException
StoreFunc
getOutputFormat in interface StoreFuncInterfacegetOutputFormat in class StoreFuncOutputFormat associated with StoreFunc
IOException - if an exception occurs while constructing the
OutputFormat
public void prepareToWrite(org.apache.hadoop.mapreduce.RecordWriter writer)
throws IOException
prepareToWrite in interface StoreFuncInterfaceprepareToWrite in class StoreFuncwriter - RecordWriter to use.
IOException - if an exception occurs during initialization
public void setStoreLocation(String location,
org.apache.hadoop.mapreduce.Job job)
throws IOException
StoreFuncStoreFunc here is the
return value of StoreFunc.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.
StoreFunc.checkSchema(ResourceSchema) will be called before any call to
StoreFunc.setStoreLocation(String, Job).
setStoreLocation in interface StoreFuncInterfacesetStoreLocation in class StoreFunclocation - Location returned by
StoreFunc.relToAbsPathForStoreLocation(String, Path)job - The Job object
IOException - if the location is not valid.public void setStoreFuncUDFContextSignature(String signature)
StoreFuncStoreFunc 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 StoreFuncInterfacesetStoreFuncUDFContextSignature in class StoreFuncsignature - a unique signature to identify this StoreFunc
public void checkSchema(ResourceSchema s)
throws IOException
StoreFunc
checkSchema in interface StoreFuncInterfacecheckSchema in class StoreFuncs - to be checked
IOException - if this schema is not acceptable. It should include
a detailed error message indicating what is wrong with the schema.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||