@Internal public class JdbcBatchingOutputFormat<In,JdbcIn,JdbcExec extends JdbcBatchStatementExecutor<JdbcIn>> extends AbstractJdbcOutputFormat<In>
Modifier and Type | Class and Description |
---|---|
static class |
JdbcBatchingOutputFormat.Builder
Builder for a
JdbcBatchingOutputFormat . |
static interface |
JdbcBatchingOutputFormat.RecordExtractor<F,T>
An interface to extract a value from given argument.
|
static interface |
JdbcBatchingOutputFormat.StatementExecutorFactory<T extends JdbcBatchStatementExecutor<?>>
A factory for creating
JdbcBatchStatementExecutor instance. |
connectionProvider, DEFAULT_FLUSH_INTERVAL_MILLS, DEFAULT_FLUSH_MAX_SIZE
Constructor and Description |
---|
JdbcBatchingOutputFormat(JdbcConnectionProvider connectionProvider,
JdbcExecutionOptions executionOptions,
JdbcBatchingOutputFormat.StatementExecutorFactory<JdbcExec> statementExecutorFactory,
JdbcBatchingOutputFormat.RecordExtractor<In,JdbcIn> recordExtractor) |
Modifier and Type | Method and Description |
---|---|
protected void |
addToBatch(In original,
JdbcIn extracted) |
protected void |
attemptFlush() |
static JdbcBatchingOutputFormat.Builder |
builder() |
void |
close()
Executes prepared statement and closes all resources of this instance.
|
void |
flush() |
void |
open(int taskNumber,
int numTasks)
Connects to the target database and initializes the prepared statement.
|
void |
updateExecutor(boolean reconnect) |
void |
writeRecord(In record)
Adds a record to the output.
|
configure, getConnection
getRuntimeContext, setRuntimeContext
public JdbcBatchingOutputFormat(@Nonnull JdbcConnectionProvider connectionProvider, @Nonnull JdbcExecutionOptions executionOptions, @Nonnull JdbcBatchingOutputFormat.StatementExecutorFactory<JdbcExec> statementExecutorFactory, @Nonnull JdbcBatchingOutputFormat.RecordExtractor<In,JdbcIn> recordExtractor)
public void open(int taskNumber, int numTasks) throws IOException
open
in interface OutputFormat<In>
open
in class AbstractJdbcOutputFormat<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.
record
- The records to add to the output.IOException
- Thrown, if the records could not be added to to an I/O problem.protected void addToBatch(In original, JdbcIn extracted) throws SQLException
SQLException
public void flush() throws IOException
flush
in interface Flushable
flush
in class AbstractJdbcOutputFormat<In>
IOException
protected void attemptFlush() throws SQLException
SQLException
public void close()
close
in interface OutputFormat<In>
close
in class AbstractJdbcOutputFormat<In>
public static JdbcBatchingOutputFormat.Builder builder()
public void updateExecutor(boolean reconnect) throws SQLException, ClassNotFoundException
SQLException
ClassNotFoundException
Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.