TABLE
TABLE = 'strata_subject'
The table subjects are indexed in.
Where every subject was last stored, kept locally so a flush reads nothing.
Two things need this and neither can afford a fetch.
An anchor names the subjects that changed since the anchor before it. Working that set out from the store would mean reading every segment written since - 960 objects at the shipped intervals - on every anchor.
Delta coding needs the address of a subject's previous version, because a rewritten value compresses against its own predecessor 63.70x better than against anything else. Resolving that from the anchor chain would cost reads on the flush path, which is the one place that cannot afford them.
So this is a complete local index rather than a per-interval accumulator, and it is never cleared by writing an anchor. An earlier version truncated it at each anchor, which left the first rewrite after every anchor with no parent to code against - the delta gain silently applied to some writes and not others. Rows are selected by when they last changed instead.
Local and derivable, which is why it lives in a table rather than in the bucket. Every row is recoverable from the anchors, so an uninstall dropping it loses nothing: the next anchor is written full, which is correct if more expensive, and delta coding resumes as subjects are written again.
record(array, size: int}|null> $subjects, int $microtime) : int
Records where each subject a window touched is now stored.
| array |
$subjects | Subject path keyed to its frame map, or NULL for a subject the window deleted. |
| int | $microtime | Unix microseconds the window was sealed at. |
How many subjects were recorded.
changedSince(int $since) : array<string,array{frames: list<string>, size: int}|null>
Subjects that changed after a given moment.
What the next anchor records. Bounded by time rather than by emptying the table, so a subject appears in exactly the one anchor that follows its change and stays available to delta code against afterwards.
| int | $since | Unix microseconds, exclusive. Zero returns everything. |
Subject path keyed to its frame map, or NULL for a deletion.
changedAt(string $subject) : int|null
When one subject was last written.
What a restore compares against its target to find out whether it would discard somebody's later edit.
| string | $subject | Subject path. |
Unix microseconds, or NULL when the index has never seen the subject.