public class DBOutputFormat<K extends DBWritable,V> extends OutputFormat<K,V>
DBOutputFormat
accepts <key,value> pairs, where
key has a type extending DBWritable. Returned RecordWriter
writes only the key to the database with a batch SQL query.
Modifier and Type | Class and Description |
---|---|
class |
DBOutputFormat.DBRecordWriter
A RecordWriter that writes the reduce output to a SQL table
|
Constructor and Description |
---|
DBOutputFormat() |
Modifier and Type | Method and Description |
---|---|
void |
checkOutputSpecs(JobContext context)
Check for validity of the output-specification for the job.
|
java.lang.String |
constructQuery(java.lang.String table,
java.lang.String[] fieldNames)
Constructs the query used as the prepared statement to insert data.
|
OutputCommitter |
getOutputCommitter(TaskAttemptContext context)
Get the output committer for this output format.
|
RecordWriter<K,V> |
getRecordWriter(TaskAttemptContext context)
Get the
RecordWriter for the given task. |
static void |
setOutput(Job job,
java.lang.String tableName,
int fieldCount)
Initializes the reduce-part of the job
with the appropriate output settings
|
static void |
setOutput(Job job,
java.lang.String tableName,
java.lang.String... fieldNames)
Initializes the reduce-part of the job with
the appropriate output settings
|
public void checkOutputSpecs(JobContext context) throws java.io.IOException, java.lang.InterruptedException
OutputFormat
This is to validate the output specification for the job when it is a job is submitted. Typically checks that it does not already exist, throwing an exception when it already exists, so that output is not overwritten.
checkOutputSpecs
in class OutputFormat<K extends DBWritable,V>
context
- information about the jobjava.io.IOException
- when output should not be attemptedjava.lang.InterruptedException
public OutputCommitter getOutputCommitter(TaskAttemptContext context) throws java.io.IOException, java.lang.InterruptedException
OutputFormat
getOutputCommitter
in class OutputFormat<K extends DBWritable,V>
context
- the task contextjava.io.IOException
java.lang.InterruptedException
public java.lang.String constructQuery(java.lang.String table, java.lang.String[] fieldNames)
table
- the table to insert intofieldNames
- the fields to insert into. If field names are unknown, supply an
array of nulls.public RecordWriter<K,V> getRecordWriter(TaskAttemptContext context) throws java.io.IOException
RecordWriter
for the given task.getRecordWriter
in class OutputFormat<K extends DBWritable,V>
context
- the information about the current task.RecordWriter
to write the output for the job.java.io.IOException
public static void setOutput(Job job, java.lang.String tableName, java.lang.String... fieldNames) throws java.io.IOException
job
- The jobtableName
- The table to insert data intofieldNames
- The field names in the table.java.io.IOException
public static void setOutput(Job job, java.lang.String tableName, int fieldCount) throws java.io.IOException
job
- The jobtableName
- The table to insert data intofieldCount
- the number of fields in the table.java.io.IOException
Copyright © 2009 The Apache Software Foundation