public class DBStorage extends StoreFunc
| Constructor and Description |
|---|
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) |
| Modifier and Type | Method and Description |
|---|---|
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 |
setStoreLocation(String location,
org.apache.hadoop.mapreduce.Job job)
Communicate to the storer the location where the data needs to be stored.
|
checkSchema, cleanupOnFailure, cleanupOnFailureImpl, cleanupOnSuccess, relToAbsPathForStoreLocation, setStoreFuncUDFContextSignature, warnpublic DBStorage(String driver, String jdbcURL, String user, String pass, String insertQuery) throws SQLException
SQLExceptionpublic DBStorage(String driver, String jdbcURL, String user, String pass, String insertQuery, String batchSize) throws RuntimeException
RuntimeExceptionpublic void putNext(Tuple tuple) throws IOException
putNext in interface StoreFuncInterfaceputNext in class StoreFunctuple - the tuple to store.IOException - if an exception occurs during the writepublic org.apache.hadoop.mapreduce.OutputFormat getOutputFormat()
throws IOException
StoreFuncgetOutputFormat in interface StoreFuncInterfacegetOutputFormat in class StoreFuncOutputFormat associated with StoreFuncIOException - if an exception occurs while constructing the
OutputFormatpublic 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 initializationpublic 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 objectIOException - if the location is not valid.Copyright © 2007-2012 The Apache Software Foundation