\Drupal\strata\Tree BaseReader

Reads an anchor back, and follows the chain until the index is complete.

Resolving walks from an anchor to the full one behind it, then applies the deltas forward so a newer entry wins and a recorded deletion removes the subject. Applying them the other way round would let an old value overwrite a new one, which is the kind of mistake that only shows up as a restore quietly writing last week's field.

The chain is bounded by the full-anchor policy, and a chain that reaches its limit without finding a full anchor is reported rather than walked forever.

Summary

Methods
Properties
Constants
__construct
read
exists
chain
depth
resolve
subjects
frames
flushCache
No public properties found
CHAIN_LIMIT
No protected methods found
No protected properties found
No protected constants found
No private methods found
cache
provider
No private constants found

Constant

CHAIN_LIMIT

CHAIN_LIMIT = 4096

Longest chain a resolve will follow.

A bound, not a policy. BasePolicy decides how often a full anchor is written and keeps chains far shorter than this; reaching it means the chain is broken or a full anchor was pruned, and both are worth reporting rather than looping over.

Properties

$cache

$cache : array

Anchors already read, keyed by address.

Type

array<string, BaseManifest> —

Methods

__construct()

__construct(\Drupal\strata\Storage\StorageProviderInterface  $provider) : mixed

Constructs a reader.

Parameters

\Drupal\strata\Storage\StorageProviderInterface $provider

Where anchors are stored.

Returns

mixed —

read()

read(string  $address) : \Drupal\strata\Tree\BaseManifest

Reads one anchor.

Parameters

string $address

Its content address.

Throws

\RuntimeException

When the anchor is absent or unreadable.

Returns

\Drupal\strata\Tree\BaseManifest —

The anchor.

exists()

exists(string  $address) : bool

Whether an anchor is present.

Parameters

string $address

Its content address.

Returns

bool —

TRUE when the object exists.

chain()

chain(string  $address) : list<string>

The chain from an anchor back to the full one behind it, newest first.

Parameters

string $address

Address of the newest anchor.

Throws

\RuntimeException

When an anchor in the chain is missing, or the chain does not end.

Returns

list

Addresses, ending with the full anchor.

depth()

depth(string  $address) : int

How many anchors a resolve would read.

Parameters

string $address

Address of the newest anchor.

Throws

\RuntimeException

When an anchor in the chain is missing.

Returns

int —

The chain length, which is what the restore estimate shows as the cost of an anchor.

resolve()

resolve(string  $address) : array<string,array{frames: list<string>, size: int}>

The complete index an anchor describes.

Parameters

string $address

Address of the anchor.

Throws

\RuntimeException

When an anchor in the chain is missing or unreadable.

Returns

array, size: int}> —

Subject path keyed to the frames that reconstruct it and its decoded size.

subjects()

subjects(string  $address) : list<string>

The subjects an anchor names, without their frame maps.

Parameters

string $address

Address of the anchor.

Throws

\RuntimeException

When an anchor in the chain is missing or unreadable.

Returns

list

Subject paths.

frames()

frames(string  $address) : list<string>

Every frame address the chain references.

A reachability walk needs the whole chain rather than the resolved index, because a frame named by an entry a later anchor replaced is still referenced by the anchor that named it, and an anchor is a restore target.

Parameters

string $address

Address of the newest anchor.

Throws

\RuntimeException

When an anchor in the chain is missing or unreadable.

Returns

list

Frame addresses, deduplicated.

flushCache()

flushCache() : void

Forgets what has been read.

Called by a long-running command between batches, so a resolve over a large index does not hold every anchor it touched.

Returns

void —