Class SkewedTimestampGenerator

java.lang.Object
io.bloviate.gen.AbstractDataGenerator<Timestamp>
io.bloviate.gen.SkewedTimestampGenerator
All Implemented Interfaces:
DataGenerator<Timestamp>

public class SkewedTimestampGenerator extends AbstractDataGenerator<Timestamp>
Generates Timestamp values in the window [start, end] skewed toward end — i.e. recent timestamps are more likely than old ones. Real event/audit columns (created_at, last_login, order_date) are rarely uniform across history; they bunch toward the present.

A uniform draw u is reshaped to u^(1/skew): skew == 1 is uniform, and larger skew pulls more mass toward end. Bounds default to a deterministic five-year window anchored at AbstractBuilder.DEFAULT_REFERENCE, so output stays reproducible (it is never anchored to wall-clock now()); set explicit bounds for a different window.

Since:
2.11.0
  • Method Details

    • generate

      public Timestamp generate()
      Description copied from interface: DataGenerator
      Generates a random value of type T.
      Returns:
      a generated value, may be null if the generator supports nullable columns
    • set

      public void set(Connection connection, PreparedStatement statement, int parameterIndex, Timestamp value) throws SQLException
      Description copied from interface: DataGenerator
      Sets a specific value on a PreparedStatement parameter.
      Specified by:
      set in interface DataGenerator<Timestamp>
      Overrides:
      set in class AbstractDataGenerator<Timestamp>
      Parameters:
      connection - the database connection
      statement - the prepared statement to set the parameter on
      parameterIndex - the 1-based parameter index
      value - the value to set
      Throws:
      SQLException - if the database operation fails
    • get

      public Timestamp get(ResultSet resultSet, int columnIndex) throws SQLException
      Description copied from interface: DataGenerator
      Retrieves a value from a ResultSet column.
      Parameters:
      resultSet - the result set to read from
      columnIndex - the 1-based column index
      Returns:
      the value from the result set, properly cast to type T
      Throws:
      SQLException - if the database operation fails