\Drupal\strata\Tree BaseManifest

A complete index of what the site held at one instant, or the change since the last one.

The thing a replay starts from. Without an anchor, materializing a subject means walking every segment back to the root of history, which is fine on a site a week old and unusable on one a year old.

A manifest is a flat list of subjects, not a tree, and the reason is measured. A Merkle tree over the same index rewrites an interior node to record one changed leaf, which at any fanout costs roughly sixteen to twenty times the entry it is recording; the earlier subtree implementation wrote 3,989,289 bytes to record a 201-byte change across 50,000 subjects. A flat list of the subjects that changed since the previous manifest costs the entries themselves and nothing else, and it chains, so an anchor every four hours costs about 240 bytes per changed subject.

Two kinds. A full manifest lists every subject and ends the chain. A delta manifest lists what changed since its parent, and a NULL entry is a subject that was deleted - which has to be recorded explicitly, because a delta that simply omitted it would leave the parent's entry standing and resurrect it.

Content-addressed like everything else, so writing the same manifest twice writes one object.

Summary

Methods
Properties
Constants
__construct
address
count
deletions
frames
size
encode
decode
jsonSerialize
entries
parent
full
microtime
VERSION
PREFIX
No protected methods found
No protected properties found
No protected constants found
No private methods found
No private properties found
No private constants found

Constant

VERSION

VERSION = 1

Format marker, so a future change is a new version rather than a silent misread.

PREFIX

PREFIX = 'bases'

Key prefix manifests are stored under.

Properties

$entries

$entries : array

Type

array<string|int, mixed>

$parent

$parent : ?string

Type

string|null

$full

$full : bool

Type

bool

$microtime

$microtime : int

Type

int

Methods

__construct()

__construct(array, size: int}|null>  $entries = [], string|null  $parent = null, bool  $full = false, int  $microtime = 0) : mixed

Constructs a manifest.

Parameters

array, size: int}|null> $entries

Subject path keyed to the frames that reconstruct it and its decoded size, or NULL for a subject that was deleted.

string|null $parent

Address of the manifest this one changes, or NULL when it stands alone.

bool $full

Whether the entries are the complete index. A full manifest ends the chain.

int $microtime

Unix microseconds the manifest was written at.

Throws

\InvalidArgumentException

When the parent is not a valid digest, or a full manifest names a parent.

Returns

mixed —

address()

address() : string

This manifest's content address.

Returns

string —

A 64-character lowercase hex digest.

count()

count() : int

How many subjects this manifest names.

Returns

int —

The count, including the deletions.

deletions()

deletions() : list<string>

Subjects this manifest records as deleted.

Returns

list

Subject paths.

frames()

frames() : list<string>

Every frame address this manifest references.

What a reachability walk collects and what a verification pass reads.

Returns

list

Frame addresses, deduplicated.

size()

size() : int

Decoded bytes the subjects in this manifest occupy.

Returns

int —

Bytes.

encode()

encode() : string

The stored form.

Throws

\JsonException

When a subject is not valid UTF-8. (string) false would otherwise write an empty anchor addressed as Hash::of(''), and every commit between two anchors inherits that address.

Returns

string —

JSON.

decode()

decode(string  $payload) : \Drupal\strata\Tree\BaseManifest

A manifest from its stored form.

Parameters

string $payload

The bytes.

Throws

\RuntimeException

When the payload is not a manifest this release can read.

Returns

\Drupal\strata\Tree\BaseManifest —

The manifest.

jsonSerialize()

jsonSerialize() : array<string,mixed>

{@inheritdoc}

Returns

array

The manifest as data. Entries use short keys, because they are repeated once per subject and a full manifest for a large site has hundreds of thousands of them.