\Drupal\strata\Tree CommitIndex

A local index over the commits in the object store.

The bucket is the record; this is a copy of the parts of it a page load needs. Rendering a timeline, finding the commit in force at a moment, or counting what a retention level covers all have to answer questions about thousands of commits at once, and answering them by walking parent links through ranged GETs would cost one request per commit.

Nothing here is authoritative. Every column is a field of a commit object that already exists under commits/, which is what makes it safe for an uninstall to drop the table and for strata:reindex to rebuild it.

Summary

Methods
Properties
Constants
__construct
record
has
get
parentsOf
newest
between
count
ids
forget
clear
No public properties found
TABLE
No protected methods found
No protected properties found
No protected constants found
No private methods found
database
No private constants found

Constant

TABLE

TABLE = 'strata_commit'

The table this index lives in.

Properties

$database

$database : \Drupal\Core\Database\Connection

Type

Connection

Methods

__construct()

__construct(\Drupal\Core\Database\Connection  $database) : mixed

Constructs an index.

Parameters

\Drupal\Core\Database\Connection $database

The database.

Returns

mixed —

record()

record(string  $id, \Drupal\strata\Tree\Commit  $commit, int  $storedBytes = 0) : void

Records a commit, or updates the row for one already present.

A commit is immutable and addressed by its content, so re-recording one writes the same values it already holds. That makes a repeated flush and a repeated reindex both idempotent.

Parameters

string $id

The commit id.

\Drupal\strata\Tree\Commit $commit

The commit.

int $storedBytes

Bytes the flush actually wrote, which the commit object itself does not know at the time it is sealed.

Returns

void —

has()

has(string  $id) : bool

Whether a commit is indexed.

Parameters

string $id

The commit id.

Returns

bool —

TRUE when a row is present.

get()

get(string  $id) : array<string,mixed>|null

The row for one commit.

Parameters

string $id

The commit id.

Returns

array|null —

The row, or NULL when the commit is not indexed.

parentsOf()

parentsOf(string  $id) : list<string>|null

What one commit builds on.

Two columns rather than the whole row, because a merge base walks thousands of commits and needs nothing else from any of them.

Parameters

string $id

The commit id.

Returns

list|null —

Parent addresses, the first parent first, or NULL when the commit is not indexed. An indexed root returns an empty list, which is what tells "no parents" apart from "not here".

newest()

newest() : array<string,mixed>|null

The newest indexed commit.

Read by the status page, which wants the head without a round trip to the bucket.

Returns

array|null —

The row, or NULL when nothing is indexed.

between()

between(int  $fromMicrotime, int  $toMicrotime, int  $limit = 100, int|null  $level = null) : list<array<string,mixed>>

Commits covering a span of time, newest first.

Parameters

int $fromMicrotime

Inclusive lower bound in unix microseconds.

int $toMicrotime

Inclusive upper bound in unix microseconds.

int $limit

Most rows to return.

int|null $level

Only commits at this compaction level, or NULL for every level.

Returns

list> —

The rows.

count()

count() : int

How many commits are indexed.

Returns

int —

The count.

ids()

ids() : list<string>

Every indexed commit id, oldest first.

Used by a verify pass and by the reindex comparison, both of which want the whole set rather than a page of it.

Returns

list

Commit ids.

forget()

forget(list  $ids) : int

Removes rows for commits that are no longer in the store.

Parameters

list $ids

Commit ids to forget.

Returns

int —

How many rows were removed.

clear()

clear() : int

Drops every row.

Returns

int —

How many rows were removed.