Class DatabaseFiller.Builder

java.lang.Object
io.bloviate.db.DatabaseFiller.Builder
Enclosing class:
DatabaseFiller

public static class DatabaseFiller.Builder extends Object
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 Details

    • Builder

      public Builder(Connection connection, DatabaseConfiguration configuration)
      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); use Builder(DataSource, DatabaseConfiguration) for parallel fills.
      Parameters:
      connection - the database connection to use for filling operations
      configuration - the configuration specifying batch sizes, record counts, and table settings
    • Builder

      public Builder(DataSource dataSource, DatabaseConfiguration configuration)
      Creates a builder that fills from a pooled DataSource. With the default of one thread the fill is sequential (on a single borrowed connection); call threads(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 from
      configuration - the configuration specifying batch sizes, record counts, and table settings
  • Method Details

    • threads

      public DatabaseFiller.Builder threads(int threads)
      Sets the number of worker threads used to fill independent tables concurrently. Only effective when the builder was created with a DataSource; the default of 1 keeps the fill sequential.
      Parameters:
      threads - the worker-thread count; must be at least 1
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if threads is less than 1
    • build

      public DatabaseFiller build()
      Builds a new DatabaseFiller instance with the configured parameters.
      Returns:
      a new DatabaseFiller ready to fill the database