Class GroupedPermutationGenerator
- All Implemented Interfaces:
DataGenerator<Integer>, IndexedDataGenerator
[start, start + groupSize) within
each consecutive run of groupSize rows, advancing to a fresh permutation for the next
group. Over the n-th row (0-based) it returns start + permute(n % groupSize) using a
permutation keyed by n / groupSize, so each group is an independent shuffle.
This is the streaming, O(1)-memory building block for "shuffled 1:1 assignment within a
group" — for example TPC-C's o_c_id, where each district's orders reference its customer
ids 1..C in a random order (each customer gets exactly one order). It is schema-agnostic:
any column that should be a per-group permutation of a contiguous id range can use it.
The permutation is produced by a small keyed Feistel network with cycle-walking, which is a
bijection on [0, groupSize) without materialising a shuffle array — so memory is constant
regardless of group size or row count, and the result is fully reproducible. The values do not
depend on the injected random source; the per-group key is derived from a fixed seed and
the group index, and counter state advances on every generate().
Supports group sizes up to 2^30.
-
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, Integer 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<Integer>- 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.The value is a pure function of the row index (the permutation is keyed by
rowIndex / groupSizeand applied torowIndex % groupSize), so seeking is O(1): the counter is set torowIndex.- 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, Integer value) throws SQLException Description copied from interface:DataGeneratorSets a specific value on a PreparedStatement parameter.- Specified by:
setin interfaceDataGenerator<Integer>- Overrides:
setin classAbstractDataGenerator<Integer>- 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<Integer>- 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
-