\Drupal\strata\Segment SegmentManifest

The ordered record of what one flush captured.

A segment is the unit a flush writes and a replay reads. It holds the operations in sequence order, the frame map that reconstructs each operation's payload, and the counters the UI reports.

The format carries a version. A segment written by one release must stay readable by every later one, because the whole point of the store is that a restore reaches back further than the code does; a reader that meets a version it does not understand says so rather than guessing at the layout.

Summary

Methods
Properties
Constants
__construct
count
isEmpty
duration
collapsed
payloadFor
frames
byRealm
summary
jsonSerialize
fromArray
level
firstSequence
lastSequence
firstMicrotime
lastMicrotime
operations
payloads
collapsedFrom
rawBytes
version
VERSION
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 version written into every manifest.

Properties

$level

$level : int

Type

int

$firstSequence

$firstSequence : int

Type

int

$lastSequence

$lastSequence : int

Type

int

$firstMicrotime

$firstMicrotime : int

Type

int

$lastMicrotime

$lastMicrotime : int

Type

int

$operations

$operations : array

Type

array<string|int, mixed>

$payloads

$payloads : array

Type

array<string|int, mixed>

$collapsedFrom

$collapsedFrom : int

Type

int

$rawBytes

$rawBytes : int

Type

int

$version

$version : int

Type

int

Methods

__construct()

__construct(int  $level, int  $firstSequence, int  $lastSequence, int  $firstMicrotime, int  $lastMicrotime, list<\Drupal\strata\Journal\JournalOp>  $operations, array>  $payloads = [], int  $collapsedFrom = 0, int  $rawBytes = 0, int  $version = \self::VERSION) : mixed

Constructs a manifest.

Parameters

int $level

Compaction level; 0 for a freshly flushed segment, higher after a rollup.

int $firstSequence

Journal sequence of the earliest operation.

int $lastSequence

Journal sequence of the latest operation.

int $firstMicrotime

Unix microseconds of the earliest operation.

int $lastMicrotime

Unix microseconds of the latest operation.

list<\Drupal\strata\Journal\JournalOp> $operations

The operations, in sequence order.

array> $payloads

Operation key keyed to the frame map that reconstructs its payload. An operation with no payload, such as a delete, has no entry.

int $collapsedFrom

How many operations were captured before collapsing produced this set.

int $rawBytes

Decoded payload bytes the operations describe.

int $version

Manifest format version.

Throws

\InvalidArgumentException

When the sequence or time range is inverted, a count is negative, or a payload map names an operation the manifest does not carry.

Returns

mixed —

count()

count() : int

How many operations the segment carries.

Returns

int —

The operation count.

isEmpty()

isEmpty() : bool

Whether the segment carries nothing.

Returns

bool —

TRUE when there are no operations.

duration()

duration() : float

How long the segment covers, in seconds.

Returns

float —

Seconds between the earliest and latest operation.

collapsed()

collapsed() : int

What collapsing removed.

Returns

int —

Operations dropped, never below zero.

payloadFor()

payloadFor(\Drupal\strata\Journal\JournalOp  $operation) : list<string>

The frame map for one operation.

Parameters

\Drupal\strata\Journal\JournalOp $operation

The operation.

Returns

list

Frame content addresses, or an empty list when the operation carries no payload.

frames()

frames() : list<string>

Every distinct frame the segment references.

A prune counts references through this, so a frame named by two operations is counted twice rather than once.

Returns

list

Frame content addresses, in first-reference order, with duplicates removed.

byRealm()

byRealm() : array<string,list<\Drupal\strata\Journal\JournalOp>>

Operations grouped by realm.

Returns

array> —

Realm value keyed to its operations, in sequence order.

summary()

summary() : string

A one-line summary for a commit label.

Returns

string —

Something such as "12 entity, 3 config".

jsonSerialize()

jsonSerialize() : array<string,mixed>

{@inheritdoc}

Returns

array

The manifest as a plain array.

fromArray()

fromArray(array  $data) : self

Rebuilds a manifest from its serialized form.

Parameters

array $data

The array produced by SegmentManifest::jsonSerialize().

Throws

\InvalidArgumentException

When the version is newer than this release understands, or the manifest is incoherent.

Returns

self —

The manifest.