Package org.apache.beam.sdk.io.jdbc
Class JdbcIO.WriteVoid<T>
- java.lang.Object
-
- org.apache.beam.sdk.transforms.PTransform<org.apache.beam.sdk.values.PCollection<T>,org.apache.beam.sdk.values.PCollection<java.lang.Void>>
-
- org.apache.beam.sdk.io.jdbc.JdbcIO.WriteVoid<T>
-
- All Implemented Interfaces:
java.io.Serializable,org.apache.beam.sdk.transforms.display.HasDisplayData
- Enclosing class:
- JdbcIO
public abstract static class JdbcIO.WriteVoid<T> extends org.apache.beam.sdk.transforms.PTransform<org.apache.beam.sdk.values.PCollection<T>,org.apache.beam.sdk.values.PCollection<java.lang.Void>>APTransformto write to a JDBC datasource. Executes statements in a batch, and returns a trivial result.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description WriteVoid()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.beam.sdk.values.PCollection<java.lang.Void>expand(org.apache.beam.sdk.values.PCollection<T> input)JdbcIO.WriteVoid<T>withAutoSharding()If true, enables using a dynamically determined number of shards to write.JdbcIO.WriteVoid<T>withBatchSize(long batchSize)Provide a maximum size in number of SQL statement for the batch.JdbcIO.WriteVoid<T>withDataSourceConfiguration(JdbcIO.DataSourceConfiguration config)JdbcIO.WriteVoid<T>withDataSourceProviderFn(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Void,javax.sql.DataSource> dataSourceProviderFn)JdbcIO.WriteVoid<T>withMaxBatchBufferingDuration(long maxBatchBufferingDuration)Provide maximum buffering time to batch elements before committing SQL statement.JdbcIO.WriteVoid<T>withPreparedStatementSetter(JdbcIO.PreparedStatementSetter<T> setter)JdbcIO.WriteVoid<T>withRetryConfiguration(JdbcIO.RetryConfiguration retryConfiguration)When a SQL exception occurs,JdbcIO.Writeuses thisJdbcIO.RetryConfigurationto exponentially back off and retry the statements based on theJdbcIO.RetryConfigurationmentioned.JdbcIO.WriteVoid<T>withRetryStrategy(JdbcIO.RetryStrategy retryStrategy)When a SQL exception occurs,JdbcIO.Writeuses thisJdbcIO.RetryStrategyto determine if it will retry the statements.JdbcIO.WriteVoid<T>withStatement(java.lang.String statement)JdbcIO.WriteVoid<T>withStatement(org.apache.beam.sdk.options.ValueProvider<java.lang.String> statement)JdbcIO.WriteVoid<T>withTable(java.lang.String table)-
Methods inherited from class org.apache.beam.sdk.transforms.PTransform
addAnnotation, compose, compose, getAdditionalInputs, getAnnotations, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, populateDisplayData, setDisplayData, setResourceHints, toString, validate, validate
-
-
-
-
Method Detail
-
withAutoSharding
public JdbcIO.WriteVoid<T> withAutoSharding()
If true, enables using a dynamically determined number of shards to write.
-
withDataSourceConfiguration
public JdbcIO.WriteVoid<T> withDataSourceConfiguration(JdbcIO.DataSourceConfiguration config)
-
withDataSourceProviderFn
public JdbcIO.WriteVoid<T> withDataSourceProviderFn(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Void,javax.sql.DataSource> dataSourceProviderFn)
-
withStatement
public JdbcIO.WriteVoid<T> withStatement(java.lang.String statement)
-
withStatement
public JdbcIO.WriteVoid<T> withStatement(org.apache.beam.sdk.options.ValueProvider<java.lang.String> statement)
-
withPreparedStatementSetter
public JdbcIO.WriteVoid<T> withPreparedStatementSetter(JdbcIO.PreparedStatementSetter<T> setter)
-
withBatchSize
public JdbcIO.WriteVoid<T> withBatchSize(long batchSize)
Provide a maximum size in number of SQL statement for the batch. Default is 1000. The pipeline will either commit a batch when this maximum is reached or its maximum buffering time has been reached. SeewithMaxBatchBufferingDuration(long)- Parameters:
batchSize- maximum batch size in number of statements
-
withMaxBatchBufferingDuration
public JdbcIO.WriteVoid<T> withMaxBatchBufferingDuration(long maxBatchBufferingDuration)
Provide maximum buffering time to batch elements before committing SQL statement. Default is 200 The pipeline will either commit a batch when this maximum buffering time has been reached or the maximum amount of elements has been collected. SeewithBatchSize(long)- Parameters:
maxBatchBufferingDuration- maximum time in milliseconds before batch is committed
-
withRetryStrategy
public JdbcIO.WriteVoid<T> withRetryStrategy(JdbcIO.RetryStrategy retryStrategy)
When a SQL exception occurs,JdbcIO.Writeuses thisJdbcIO.RetryStrategyto determine if it will retry the statements. IfJdbcIO.RetryStrategy.apply(SQLException)returnstrue, thenJdbcIO.Writeretries the statements.
-
withRetryConfiguration
public JdbcIO.WriteVoid<T> withRetryConfiguration(JdbcIO.RetryConfiguration retryConfiguration)
When a SQL exception occurs,JdbcIO.Writeuses thisJdbcIO.RetryConfigurationto exponentially back off and retry the statements based on theJdbcIO.RetryConfigurationmentioned.Usage of RetryConfiguration -
maxDuration and initialDuration are Nullablepipeline.apply(JdbcIO.<T>write()) .withDataSourceConfiguration(...) .withRetryStrategy(...) .withRetryConfiguration(JdbcIO.RetryConfiguration. create(5, Duration.standardSeconds(5), Duration.standardSeconds(1))pipeline.apply(JdbcIO.<T>write()) .withDataSourceConfiguration(...) .withRetryStrategy(...) .withRetryConfiguration(JdbcIO.RetryConfiguration. create(5, null, null)
-
withTable
public JdbcIO.WriteVoid<T> withTable(java.lang.String table)
-
-