Record Class BulkLoadStrategy

java.lang.Object
java.lang.Record
io.bloviate.db.BulkLoadStrategy
Record Components:
mode - the ordering mode
revalidate - whether DatabaseSupport.enableConstraints(Connection, Database, BulkLoadHandle) should re-validate existing rows when re-enabling enforcement (only meaningful for vendor mechanisms that can do so; the session-based PostgreSQL/MySQL mechanisms cannot and ignore it)

public record BulkLoadStrategy(BulkLoadStrategy.Mode mode, boolean revalidate) extends Record
How DatabaseFiller orders table fills relative to foreign-key dependencies.

By default (ordered()) the fill engine respects the foreign-key dependency graph: a child table is never filled before its parent. On the parallel path this means filling one topological level at a time with a barrier between levels, which serializes deep, narrow dependency chains (e.g. TPC-C's warehouse → district → customer → open_order → order_line).

unorderedBulk() trades that ordering for speed on chained schemas. Bloviate's generated data is referentially consistent by construction — a foreign-key column's generator is seeded from the referenced primary-key column's seed, so child and parent produce identical key values regardless of insert order (see DatabaseUtils.columnSeed(Column, long)). That makes it safe to disable foreign-key enforcement for the duration of the fill, insert all tables concurrently with no topological barrier, then re-enable enforcement. For the same seed, the resulting row content is identical to an ordered fill across every deterministic column — physical (on-disk) row order may differ, and columns whose generator is non-deterministic (e.g. wall-clock temporal values, or a custom plugin that reads external state) are reproducible only to the extent that generator is.

Bulk mode only takes effect on the parallel path (a DataSource with DatabaseFiller.Builder.threads(int) > 1) and only when the active DatabaseSupport reports DatabaseSupport.supportsBulkLoad(). Otherwise the engine logs a warning and uses the ordered path. PostgreSQL and MySQL support it; CockroachDB does not and falls back.

Since:
2.17.0
See Also:
  • Constructor Details

  • Method Details

    • ordered

      public static BulkLoadStrategy ordered()
      The back-compatible default: fill in foreign-key dependency order, never disabling constraints.
      Returns:
      an BulkLoadStrategy.Mode.ORDERED strategy
    • unorderedBulk

      public static BulkLoadStrategy unorderedBulk()
      Disable foreign-key enforcement, fill every table concurrently with no topological barrier, then re-enable enforcement without re-validating (safe because the data is consistent by construction).
      Returns:
      an BulkLoadStrategy.Mode.UNORDERED_BULK strategy
    • isUnordered

      public boolean isUnordered()
      Whether this strategy is BulkLoadStrategy.Mode.UNORDERED_BULK.
      Returns:
      true for unordered bulk loading
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • mode

      public BulkLoadStrategy.Mode mode()
      Returns the value of the mode record component.
      Returns:
      the value of the mode record component
    • revalidate

      public boolean revalidate()
      Returns the value of the revalidate record component.
      Returns:
      the value of the revalidate record component