Class GroupedPrefixGenerator<T>
- Type Parameters:
T- the Java type produced by the wrapped generator
- All Implemented Interfaces:
DataGenerator<T>, IndexedDataGenerator
prefixSize rows of each consecutive group of
groupSize rows, emitting null for the remainder. For the n-th row (0-based) the
position within its group is n % groupSize; positions below prefixSize delegate
to a wrapped generator, the rest yield SQL NULL.
This is the streaming, O(1)-memory building block for a "sparse prefix column" — a value that
exists only for a leading subset of each group. For example TPC-C's o_carrier_id, which is
set for the delivered orders (the lower o_ids of each district) and NULL for the most
recent, undelivered ones. It is schema-agnostic.
The wrapped generator is consulted only for prefix rows, so a stateless delegate is recommended. The values do not depend on the injected random source beyond whatever the delegate uses.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class AbstractDataGenerator
random, randomUtils -
Method Summary
Modifier and TypeMethodDescriptiongenerate()Generates a random value of type T.Retrieves a value from a ResultSet column.voidseek(long rowIndex) Positions this generator so the nextDataGenerator.generate()returns the value for the given absolute (0-based) row index.voidset(Connection connection, PreparedStatement statement, int parameterIndex, T value) Sets a specific value on a PreparedStatement parameter.Methods inherited from class AbstractDataGenerator
generateAndSet, generateAsString, reseed
-
Method Details
-
generate
Description copied from interface:DataGeneratorGenerates a random value of type T.- Specified by:
generatein interfaceDataGenerator<T>- Returns:
- a generated value, may be null if the generator supports nullable columns
-
seek
public void seek(long rowIndex) Positions this generator so the nextDataGenerator.generate()returns the value for the given absolute (0-based) row index.Setting the counter to
rowIndexrestores the null/non-null pattern exactly (it is a pure function of the absolute position). The wrapped delegate is consulted only on prefix rows, so it is advanced to the matching delegate-call index: a positional delegate is itselfsought(byte-identical), while a plain random delegate is reseeded deterministically for the partition (its non-key values may differ from a sequential fill).- Specified by:
seekin interfaceIndexedDataGenerator- Parameters:
rowIndex- the absolute, 0-based row index to seek to; must be>= 0
-
set
public void set(Connection connection, PreparedStatement statement, int parameterIndex, T value) throws SQLException Description copied from interface:DataGeneratorSets a specific value on a PreparedStatement parameter.- Specified by:
setin interfaceDataGenerator<T>- Overrides:
setin classAbstractDataGenerator<T>- Parameters:
connection- the database connectionstatement- the prepared statement to set the parameter onparameterIndex- the 1-based parameter indexvalue- the value to set- Throws:
SQLException- if the database operation fails
-
get
Description copied from interface:DataGeneratorRetrieves a value from a ResultSet column.- Specified by:
getin interfaceDataGenerator<T>- Parameters:
resultSet- the result set to read fromcolumnIndex- the 1-based column index- Returns:
- the value from the result set, properly cast to type T
- Throws:
SQLException- if the database operation fails
-