Class ChildCardinality
[minChildren, maxChildren].
This models variable parent-child cardinality — a child table whose
per-parent row count differs from row to row (e.g. TPC-C orders with a random number
of order lines, or TPC-H orders with a random number of line items). It is the shared
source of truth that lets a parent table and its child table agree on counts even though
they are filled independently: a "number of children" column on the parent (see
ChildCountGenerator) returns count(k) for the k-th parent,
and the child's key generators (see ChildKeyComponentGenerator) emit exactly that
many rows for parent k. Because count(long) is a pure function of the parent index
(a splitmix64 hash, no random state), every consumer computes identical values.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionChildCardinality(int minChildren, int maxChildren, long seed) Creates a cardinality over the inclusive range[minChildren, maxChildren]. -
Method Summary
Modifier and TypeMethodDescriptionintcount(long parentIndex) Returns the deterministic child count for the parent at the given global index.intReturns the maximum children per parent (inclusive).intReturns the minimum children per parent (inclusive).longtotal(long parentCount) Returns the total number of child rows across the firstparentCountparents, i.e.
-
Constructor Details
-
ChildCardinality
public ChildCardinality(int minChildren, int maxChildren, long seed) Creates a cardinality over the inclusive range[minChildren, maxChildren].- Parameters:
minChildren- minimum children per parent (inclusive),>= 0maxChildren- maximum children per parent (inclusive),>= minChildrenseed- salt mixed into the hash, so different datasets can vary independently
-
-
Method Details
-
count
public int count(long parentIndex) Returns the deterministic child count for the parent at the given global index.- Parameters:
parentIndex- the 0-based, row-major parent index- Returns:
- a value in
[minChildren, maxChildren]
-
total
public long total(long parentCount) Returns the total number of child rows across the firstparentCountparents, i.e.sum(count(k))forkin[0, parentCount).When the count is fixed (
minChildren == maxChildren) this is closed-form and O(1). Otherwise it is a single O(parentCount) pass with no intermediate storage, so memory stays constant even for very large datasets.- Parameters:
parentCount- the number of parents- Returns:
- the total child-row count
-
minChildren
public int minChildren()Returns the minimum children per parent (inclusive).- Returns:
- the minimum child count
-
maxChildren
public int maxChildren()Returns the maximum children per parent (inclusive).- Returns:
- the maximum child count
-