\Drupal\strata\Explore StorageExplorer

Answers what the store holds now, and what deleting something would take with it.

The three reachability classes are what makes this more than a size report. An operator looking at a commit wants to know what pruning it would free, and the honest answer is almost never the bytes that commit wrote: a frame it references may be shared with fifty other commits, may be the anchor a live delta chain decodes against, or may be a dictionary a thousand frames name. So the cost of removing a commit is computed by asking what would become unreachable, never by adding up what it wrote.

Nothing here deletes anything. The explorer is a read; Compactor::prune() is the write, and it does its own reachability walk rather than trusting a number a page rendered earlier. A store that changed between the preview and the confirmation is the normal case on a live site.

Summary

Methods
Properties
Constants
__construct
report
costOfRemoving
largestCommits
dictionaryReason
abbreviate
No public properties found
MAX_COLLECTABLE
No protected methods found
No protected properties found
No protected constants found
framesOf
byRealm
reachability
frames
commits
dictionaries
segments
database
No private constants found

Constant

MAX_COLLECTABLE

MAX_COLLECTABLE = 1000

Collectable frames one report lists.

Properties

$reachability

$reachability : \Drupal\strata\Compaction\Reachability

Type

Reachability

$commits

$commits : \Drupal\strata\Tree\CommitIndex

Type

CommitIndex

$dictionaries

$dictionaries : \Drupal\strata\Codec\Dictionary\DictionaryStore

Type

DictionaryStore

$segments

$segments : \Drupal\strata\Segment\SegmentReader

Type

SegmentReader

$database

$database : \Drupal\Core\Database\Connection

Type

Connection

Methods

__construct()

__construct(\Drupal\strata\Compaction\Reachability  $reachability, \Drupal\strata\Cas\FrameIndexInterface  $frames, \Drupal\strata\Tree\CommitIndex  $commits, \Drupal\strata\Codec\Dictionary\DictionaryStore  $dictionaries, \Drupal\strata\Segment\SegmentReader  $segments, \Drupal\Core\Database\Connection  $database) : mixed

Constructs an explorer.

Parameters

\Drupal\strata\Compaction\Reachability $reachability

Walks the three classes.

\Drupal\strata\Cas\FrameIndexInterface $frames

Supplies the store totals.

\Drupal\strata\Tree\CommitIndex $commits

Supplies the commit count and per-commit sizes.

\Drupal\strata\Codec\Dictionary\DictionaryStore $dictionaries

Supplies what dictionaries exist.

\Drupal\strata\Segment\SegmentReader $segments

Reads which frames a commit's own segment references.

\Drupal\Core\Database\Connection $database

Reads the per-realm attribution out of the journal.

Returns

mixed —

report()

report(int  $limit = \self::MAX_COLLECTABLE) : \Drupal\strata\Explore\ExplorerReport

What the store holds.

Parameters

int $limit

Collectable frames to list.

Returns

\Drupal\strata\Explore\ExplorerReport —

The report.

costOfRemoving()

costOfRemoving(string  $commit) : \Drupal\strata\Explore\RemovalCost

What removing one commit would make unreachable.

The frames that commit references are checked one at a time against every other reachability class, so a frame shared with another commit, held by a delta chain, or named by a dictionary is reported as retained rather than as freed.

Parameters

string $commit

The commit id.

Returns

\Drupal\strata\Explore\RemovalCost —

What would be freed, what would be kept and why, and whether the walk that decided it finished.

largestCommits()

largestCommits(int  $limit = 20) : list<array<string,mixed>>

The largest commits by what they wrote.

Parameters

int $limit

Most rows to return.

Returns

list> —

Commit index rows, largest first.

dictionaryReason()

dictionaryReason(string  $id) : string|null

Why one dictionary cannot be removed.

Parameters

string $id

The dictionary id.

Returns

string|null —

The reason, or NULL when nothing needs it.

abbreviate()

abbreviate(string  $hash) : string

Shortens a frame address for a table cell.

Parameters

string $hash

The address.

Returns

string —

The abbreviated form.

framesOf()

framesOf(string  $commit) : list<string>

Frames a commit's own segment references.

Only the segment's frames, not the anchor's. An anchor is shared by every commit between it and the next one, so attributing its frames to any single commit would report the same bytes as freeable several times over.

Parameters

string $commit

The commit id.

Returns

list

Frame addresses.

byRealm()

byRealm() : array<string,int>

Stored bytes attributed to each realm.

Attributed from the journal's pending operations and the commit labels, which is what is available locally: a frame is content-addressed and carries no realm, so the store itself cannot say which realm a given frame belongs to. The figures are therefore a breakdown of what has been captured rather than of what is on disk, and the explorer labels them that way.

Returns

array

Realm value keyed to bytes.