IF Commons GitHub

physical/memory-merge/mod

Written to: 3 requirements: 3 proved, 0 partly, 0 failing, 0 with no test recorded. 0009-anyfs-merge-physical FR-008, 0009-anyfs-merge-physical FR-009, 0009-anyfs-merge-physical FR-010

The store in memory that merges: a replica whose files are the view of a set of immutable version rows, so that it keeps every capability of the store in memory and one more, merge. A write is a new row that replaces the heads of its path, a delete is a tombstone, the winner among the heads is the file and the other heads are its siblings. Its revision is sha256: and the digest of the bytes, as everywhere. It is the reference every backend that merges is held to, and the model whose laws a SQL dump of such a database relies on.

import { memoryMergeStore } from "./mod.ts";
const a = memoryMergeStore({ name: "a" });
a.store.id; // "merge-memory:a"

Source: commons/anyfs/src/physical/memory-merge/mod.ts

1 of 6 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

MERGE_STORE_CAPABILITIESconstno test imports it
const MERGE_STORE_CAPABILITIES: readonly ["read", "write", "list", "stat", "delete", "cas", "batch", "rename", "history", "merge"]

The capabilities of the store in memory that merges.

MergeStoretypeno test imports it
type MergeStore = Store<(typeof MERGE_STORE_CAPABILITIES)[number]>;

The type of the store in memory that merges.

MemoryMergeOptionstypeno test imports it
type MemoryMergeOptions = {
  readonly name?: string;
  readonly replica?: ReplicaId;
  readonly clock?: () => number;
  readonly trust?: Trust;
  readonly maxDrift?: number;
  readonly limits?: Limits;
};

What the store is made with: its name, its replica identity, the clock in milliseconds, whom it takes changes from, how far ahead it takes an id and its limits.

Siblingtypeno test imports it
type Sibling = { readonly id: string; readonly kind: "put" | "tombstone"; readonly rev: Revision | undefined; readonly replica: ReplicaId };

A sibling: a head of a path that is not the winner.

MergeReplicatypeno test imports it
type MergeReplica = { readonly store: MergeStore; readonly replica: ReplicaId; /** The state as it is now: rows an… (712 characters)
type MergeReplica = {
  readonly store: MergeStore;
  readonly replica: ReplicaId;
  /** The state as it is now: rows and blobs. */
  state(): MergeState;
  /** The heads of a path that are not the winner. */
  siblings(path: Path): readonly Sibling[];
  /** The rows and blobs as one text, and the files as one text. */
  stateText(): string;
  viewText(): string;
  /** What is wrong with the rows held, whatever way they came. */
  verify(): Promise<readonly MergeFinding[]>;
  /** How many deltas the replica holds back. */
  pending(): number;
  /** Rows put in as a SQL import puts them: with no check of ours. */
  importRows(versions: readonly Version[], blobs: ReadonlyMap<string, Uint8Array>): void;
};

A replica: the store, and what a test or a program reads of it that the store's interface does not give.

memoryMergeStorefunction
function memoryMergeStore(options?: MemoryMergeOptions): MergeReplica

A store in memory that merges.

Imported by 11 tests of the run (11 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.