KeyGrouping
Read onlyYes
FinalYes
Collects rows sharing a key into one batch, so a downstream operator sees each key exactly once and contiguously.
Methods
- __construct() : mixed
- group() : Generator<string|int, Rows>
- indices() : array<string, array<int, int>>
- Each key's rows, by the key, in row order. One pass per row: with no hash per row it beats gathering by value (one array_keys() pass per distinct key) from 4 distinct keys on, 0.03 s against 0.11 s at 24 on 1 M rows. A key never reads as an integer array key: every one starts with a NUL byte, or is empty.
Methods
__construct()
public
__construct(KeyEncoder $keys, Backend $backend) : mixed
Parameters
- $keys : KeyEncoder
- $backend : Backend
group()
public
group(Generator<string|int, Rows> $rows) : Generator<string|int, Rows>
Parameters
- $rows : Generator<string|int, Rows>
Return values
Generator<string|int, Rows>indices()
Each key's rows, by the key, in row order. One pass per row: with no hash per row it beats gathering by value (one array_keys() pass per distinct key) from 4 distinct keys on, 0.03 s against 0.11 s at 24 on 1 M rows. A key never reads as an integer array key: every one starts with a NUL byte, or is empty.
public
static indices(array<int, string> $keys) : array<string, array<int, int>>
Parameters
- $keys : array<int, string>
-
one key per row