SpilledRows implements SchemaSampler
A source that can be read only once, made replayable: every row is written to a temporary schema-less spill file as it streams past, and the replay reads the file back. The source is advanced exactly once, ever; the spill it produced can be replayed as often as the caller likes, and lives until this object is collected.
Interfaces
Methods
- __construct() : mixed
- __destruct() : mixed
- The only place the spill is removed: it outlives every replay, so a generator source supports repeated terminal operations the way an array one does.
- path() : Path
- rows() : Generator<int, array<string|int, mixed>>
- Rows in the shape the source produced them, int keys still int - naming belongs to array_to_rows().
- samples() : iterable<int, iterable<int, RawRowValues>>
- $rowBudget is IGNORED: every row is written regardless, which is what makes a partially written spill unreachable by construction rather than merely unlikely.
- state() : SpillState
Methods
__construct()
public
__construct(iterable<string|int, array<string|int, mixed>> $source, Filesystem $filesystem, Path $spillRoot[, int<1, max> $bufferSize = 65536 ]) : mixed
Parameters
- $source : iterable<string|int, array<string|int, mixed>>
-
read exactly once, ever
- $filesystem : Filesystem
- $spillRoot : Path
-
the extractor resolves it; this class owns the layout below, the way FilesystemBuckets suffixes '/flow-php-buckets/' onto its own cacheDir
- $bufferSize : int<1, max> = 65536
-
bytes held before a write; DestinationStream::append() costs one write(2) per call, and one per row is 4x the cost of the whole fold
__destruct()
The only place the spill is removed: it outlives every replay, so a generator source supports repeated terminal operations the way an array one does.
public
__destruct() : mixed
Swallows every Throwable: an exception escaping a destructor during shutdown is a PHP fatal, and Filesystem::rm() is not exception-free.
path()
public
path() : Path
Return values
Pathrows()
Rows in the shape the source produced them, int keys still int - naming belongs to array_to_rows().
public
rows() : Generator<int, array<string|int, mixed>>
Replayable as often as the caller likes - the file is removed by __destruct, not by the replay.
A never-sampled sampler streams the source instead of a file; that arm IS one-shot, because there is no file to read back.
Tags
Return values
Generator<int, array<string|int, mixed>>samples()
$rowBudget is IGNORED: every row is written regardless, which is what makes a partially written spill unreachable by construction rather than merely unlikely.
public
samples(int $rowBudget) : iterable<int, iterable<int, RawRowValues>>
Parameters
- $rowBudget : int
Tags
Return values
iterable<int, iterable<int, RawRowValues>>state()
public
state() : SpillState