@Internal public class JdbcOutputFormat<In,JdbcIn,JdbcExec extends JdbcBatchStatementExecutor<JdbcIn>> extends RichOutputFormat<In> implements Flushable, InputTypeConfigurable
Modifier and Type | Class and Description |
---|---|
static class |
JdbcOutputFormat.Builder
Builder for a
JdbcOutputFormat . |
static interface |
JdbcOutputFormat.RecordExtractor<F,T>
An interface to extract a value from given argument.
|
static interface |
JdbcOutputFormat.StatementExecutorFactory<T extends JdbcBatchStatementExecutor<?>>
A factory for creating
JdbcBatchStatementExecutor instance. |
Modifier and Type | Field and Description |
---|---|
protected JdbcConnectionProvider |
connectionProvider |
Constructor and Description |
---|
JdbcOutputFormat(JdbcConnectionProvider connectionProvider,
JdbcExecutionOptions executionOptions,
JdbcOutputFormat.StatementExecutorFactory<JdbcExec> statementExecutorFactory,
JdbcOutputFormat.RecordExtractor<In,JdbcIn> recordExtractor) |
Modifier and Type | Method and Description |
---|---|
protected void |
addToBatch(In original,
JdbcIn extracted) |
protected void |
attemptFlush() |
static JdbcOutputFormat.Builder |
builder() |
void |
close()
Executes prepared statement and closes all resources of this instance.
|
void |
configure(Configuration parameters)
Configures this output format.
|
void |
flush() |
Connection |
getConnection() |
JdbcExecutionOptions |
getExecutionOptions()
Returns configured
JdbcExecutionOptions . |
void |
open(int taskNumber,
int numTasks)
Connects to the target database and initializes the prepared statement.
|
void |
setInputType(TypeInformation<?> type,
ExecutionConfig executionConfig)
Method that is called on an
OutputFormat when it is
passed to the DataSet's output method. |
void |
updateExecutor(boolean reconnect) |
void |
writeRecord(In record)
Adds a record to the output.
|
getRuntimeContext, setRuntimeContext
protected final JdbcConnectionProvider connectionProvider
public JdbcOutputFormat(@Nonnull JdbcConnectionProvider connectionProvider, @Nonnull JdbcExecutionOptions executionOptions, @Nonnull JdbcOutputFormat.StatementExecutorFactory<JdbcExec> statementExecutorFactory, @Nonnull JdbcOutputFormat.RecordExtractor<In,JdbcIn> recordExtractor)
public void setInputType(TypeInformation<?> type, ExecutionConfig executionConfig)
InputTypeConfigurable
OutputFormat
when it is
passed to the DataSet's output method. May be used to configures the output format based on
the data type.setInputType
in interface InputTypeConfigurable
type
- The data type of the input.executionConfig
- The execution config for this parallel execution.public void configure(Configuration parameters)
OutputFormat
This method is always called first on a newly instantiated output format.
configure
in interface OutputFormat<In>
parameters
- The configuration with all parameters.public void open(int taskNumber, int numTasks) throws IOException
open
in interface OutputFormat<In>
taskNumber
- The number of the parallel instance.numTasks
- The number of parallel tasks.IOException
- Thrown, if the output could not be opened due to an I/O problem.public final void writeRecord(In record) throws IOException
OutputFormat
When this method is called, the output format it guaranteed to be opened.
writeRecord
in interface OutputFormat<In>
record
- The records to add to the output.IOException
- Thrown, if the records could not be added due to an I/O problem.protected void addToBatch(In original, JdbcIn extracted) throws SQLException
SQLException
public void flush() throws IOException
flush
in interface Flushable
IOException
protected void attemptFlush() throws SQLException
SQLException
public void close()
close
in interface OutputFormat<In>
public static JdbcOutputFormat.Builder builder()
public void updateExecutor(boolean reconnect) throws SQLException, ClassNotFoundException
SQLException
ClassNotFoundException
public JdbcExecutionOptions getExecutionOptions()
JdbcExecutionOptions
.@VisibleForTesting public Connection getConnection()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.