Class DatabaseFiller.Builder
java.lang.Object
io.bloviate.db.DatabaseFiller.Builder
- Enclosing class:
DatabaseFiller
Builder for constructing DatabaseFiller instances.
Follows the builder pattern to provide a clean API for creating DatabaseFiller objects with required dependencies.
- Author:
- Tim Veil
-
Constructor Summary
ConstructorsConstructorDescriptionBuilder(Connection connection, DatabaseConfiguration configuration) Creates a builder that fills sequentially on a single caller-managed connection — the default, back-compatible mode.Builder(DataSource dataSource, DatabaseConfiguration configuration) Creates a builder that fills from a pooledDataSource. -
Method Summary
-
Constructor Details
-
Builder
Creates a builder that fills sequentially on a single caller-managed connection — the default, back-compatible mode.threads(int)has no effect in this mode (a single connection cannot be shared across threads); useBuilder(DataSource, DatabaseConfiguration)for parallel fills.- Parameters:
connection- the database connection to use for filling operationsconfiguration- the configuration specifying batch sizes, record counts, and table settings
-
Builder
Creates a builder that fills from a pooledDataSource. With the default of one thread the fill is sequential (on a single borrowed connection); callthreads(int)with a value greater than one to fill independent tables concurrently, one connection per worker.- Parameters:
dataSource- the data source to borrow worker connections fromconfiguration- the configuration specifying batch sizes, record counts, and table settings
-
-
Method Details
-
threads
Sets the number of worker threads used to fill independent tables concurrently. Only effective when the builder was created with aDataSource; the default of1keeps the fill sequential.- Parameters:
threads- the worker-thread count; must be at least1- Returns:
- this builder
- Throws:
IllegalArgumentException- ifthreadsis less than1
-
build
Builds a new DatabaseFiller instance with the configured parameters.- Returns:
- a new DatabaseFiller ready to fill the database
-