public class DBOutputFormat<K extends DBWritable,V> extends Object implements 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.
限定符和类型 | 类和说明 |
---|---|
protected class |
DBOutputFormat.DBRecordWriter
A RecordWriter that writes the reduce output to a SQL table
|
构造器和说明 |
---|
DBOutputFormat() |
限定符和类型 | 方法和说明 |
---|---|
void |
checkOutputSpecs(FileSystem filesystem,
JobConf job)
Check for validity of the output-specification for the job.
|
protected String |
constructQuery(String table,
String[] fieldNames)
Constructs the query used as the prepared statement to insert data.
|
RecordWriter<K,V> |
getRecordWriter(FileSystem filesystem,
JobConf job,
String name,
Progressable progress)
Get the
RecordWriter for the given job. |
static void |
setOutput(JobConf job,
String tableName,
String... fieldNames)
Initializes the reduce-part of the job with the appropriate output settings
|
protected String constructQuery(String table, String[] fieldNames)
table
- the table to insert intofieldNames
- the fields to insert into. If field names are unknown, supply an
array of nulls.public void checkOutputSpecs(FileSystem filesystem, JobConf job) throws IOException
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
在接口中 OutputFormat<K extends DBWritable,V>
job
- job configuration.IOException
- when output should not be attemptedpublic RecordWriter<K,V> getRecordWriter(FileSystem filesystem, JobConf job, String name, Progressable progress) throws IOException
RecordWriter
for the given job.getRecordWriter
在接口中 OutputFormat<K extends DBWritable,V>
job
- configuration for the job whose output is being written.name
- the unique name for this part of the output.progress
- mechanism for reporting progress while writing to file.RecordWriter
to write the output for the job.IOException
public static void setOutput(JobConf job, String tableName, String... fieldNames)
job
- The jobtableName
- The table to insert data intofieldNames
- The field names in the table. If unknown, supply the appropriate
number of nulls.Copyright © 2009 The Apache Software Foundation