SEGMENT_LIMIT
SEGMENT_LIMIT = 200
Segments read to collect samples.
A bound on the pass rather than a policy: the newest segments describe what the site is writing now, and reading further back trains against a shape the site has moved on from.
Trains each realm's dictionary from what that realm has actually been writing.
Samples come from the operations already in the store rather than from a fixture, because a dictionary is only worth anything if it looks like the next frame. A site whose nodes all carry the same twelve fields gets a dictionary full of those field names; a site with one node type gets a different one, and neither is guessable in advance.
Runs on cron and by hand, never on a flush. Building a candidate compresses the samples twice and the winner is scored against a held-out slice, so a pass costs seconds - fine on a schedule, impossible inside a web request.
A realm gets a new version only when one measures better than what it has. Retraining for the sake of it would add a version, strand nothing, and cost every new frame the same ratio, so the gain is measured against the realm's current dictionary before anything is written.
$trainer : \Drupal\strata\Codec\Dictionary\DictionaryTrainer
$store : \Drupal\strata\Codec\Dictionary\DictionaryStore
$objects : \Drupal\strata\Cas\ObjectStore
$segments : \Drupal\strata\Segment\SegmentReader
$commits : \Drupal\strata\Tree\CommitLog
$refs : \Drupal\strata\Tree\RefStore
__construct(\Drupal\strata\Codec\Dictionary\DictionaryTrainer $trainer, \Drupal\strata\Codec\Dictionary\DictionaryStore $store, \Drupal\strata\Cas\ObjectStore $objects, \Drupal\strata\Segment\SegmentReader $segments, \Drupal\strata\Tree\CommitLog $commits, \Drupal\strata\Tree\RefStore $refs, \Psr\Log\LoggerInterface $logger) : mixed
Constructs a pass.
| \Drupal\strata\Codec\Dictionary\DictionaryTrainer | $trainer | Builds and scores the candidates. |
| \Drupal\strata\Codec\Dictionary\DictionaryStore | $store | Where a winning dictionary is stored. |
| \Drupal\strata\Cas\ObjectStore | $objects | Fetches the payload frames samples are taken from. |
| \Drupal\strata\Segment\SegmentReader | $segments | Reads the segment manifests that name them. |
| \Drupal\strata\Tree\CommitLog | $commits | Walks history to find the segments. |
| \Drupal\strata\Tree\RefStore | $refs | Resolves the ref to walk from. |
| \Psr\Log\LoggerInterface | $logger | Records what a pass did. |
run(string $ref = \Drupal\strata\Tree\RefStore::MAIN) : array<string,array{stored: bool, reason: string, ratio: float, source: string}>
Trains every realm that has enough recent data.
| string | $ref | Ref to collect samples from. |
Realm value keyed to what happened, so a command can print a line per realm rather than one number for the run.
trainRealm(string $realm, list$samples) : array{stored: bool, reason: string, ratio: float, source: string}
Trains one realm.
| string | $realm | Realm value. |
| list |
$samples | Payloads from that realm. |
What happened.