SpilledRows implements Sniffer
Makes a read-once source replayable; the source is advanced exactly once.
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.
- bytes() : int<0, max>
- close() : void
- Releases what the sniffs left open.
- names() : array<int, string>
- parts() : array<int, self>
- Live one-unit sniffers that together cover $unit (unit 0 of each; the parent-resolved header and candidate set): a source that can be cut hands out one per byte window of about $targetBytes, every other one hands out [itself over $unit]. A part runs in a worker when it is Describable with a non-null describe(); the parts' samples merged in order are the unit's sample.
- 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().
- sniff() : Sample
- The spill writes every row regardless of $rowBudget, which is what makes a partially written spill unreachable by construction rather than merely unlikely.
- state() : SpillState
- units() : int<0, max>
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 FilesystemRowsStorage suffixes '/flow-php-rows/' 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.
bytes()
public
bytes(int $unit) : int<0, max>
Parameters
- $unit : int
Return values
int<0, max> —on-disk bytes of the unit; 0 when unknown or in memory
close()
Releases what the sniffs left open.
public
close() : void
names()
public
names() : array<int, string>
Return values
array<int, string> —columns known before any row - a header; [] for a headerless source
parts()
Live one-unit sniffers that together cover $unit (unit 0 of each; the parent-resolved header and candidate set): a source that can be cut hands out one per byte window of about $targetBytes, every other one hands out [itself over $unit]. A part runs in a worker when it is Describable with a non-null describe(); the parts' samples merged in order are the unit's sample.
public
parts(int $unit, int $targetBytes) : array<int, self>
Parameters
- $unit : int
- $targetBytes : int
Return values
array<int, self>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>>sniff()
The spill writes every row regardless of $rowBudget, which is what makes a partially written spill unreachable by construction rather than merely unlikely.
public
sniff(int $unit, int|null $rowBudget) : Sample
Parameters
- $unit : int
- $rowBudget : int|null
-
rows to observe from this unit, 0 for none, null for every row
Tags
Return values
Samplestate()
public
state() : SpillState
Return values
SpillStateunits()
public
units() : int<0, max>