Skip to main content

Module triplets

Module triplets 

Source
Expand description

Triplets (index: type from to) stored in doublets, with an associative API over any NamedTypeLinks (issue #151).

The encoding keeps the convention of the type hierarchy of issue #148, the type of a link is its source, and adds two marker points, Pair (P) and Nothing (N, which stands for the empty part 0):

tripletdoublets
(i: T 0 0), node(i: T i)
(i: T f t)wrapper w = (P f), pair p = (w t), outer (i: T p)
the same, againthe outer (T p) is taken, so a duplicate pair d = (p i) and (i: T d)

A zero f or t is written as N. Wrappers and pairs are shared by every triplet with the same parts, so they are collected as soon as nothing uses them any more. A triplet’s address is the address of its outer doublet, which an update rewrites in place: the address stays and the old pair is collected. A delete removes, like a doublet delete here, every triplet that uses the deleted one as its type, from or to.

Every doublet is classified by its sources alone:

  • P and N are the markers;
  • (w: P x) is a wrapper;
  • (p: w x) whose source is a wrapper is a pair;
  • (d: p i) whose source is a pair is a duplicate pair;
  • (i: T y) is a triplet when y is i, a pair, or a duplicate pair (p i) that points back at it;
  • anything else, the Extends wiring of a TypesDecorator say, is a doublet of somebody else and is not a triplet.

Triplets is the interface, with every read and write as a default method over NamedTypeLinks, and TripletsOverDoublets is the decorator that implements it over any other layer. The C# counterpart is Foundation.Data.Doublets.Cli.TripletsOverDoublets<TLinkAddress>. docs/TRIPLETS.md compares this encoding with the alternatives and lists the cost of every operation.

Structs§

Triplet
A triplet (index: type from to); from and to are 0 when empty.
TripletChange
One change a query made: a creation has no before, a deletion no after, and a read reports the same triplet on both sides.
TripletMarkers
The two marker points of the encoding.
TripletQuery
A restriction of Triplets::each_triplet: None matches any value, Some(0) an empty from or to.
TripletsOverDoublets
A decorator that stores triplets (index: type from to) in the doublets of the layer it wraps; see the module documentation.

Enums§

DoubletRole
What a doublet is in the encoding.

Constants§

NOTHING_MARKER_NAME
The name of the marker point that stands for the empty part 0.
PAIR_MARKER_NAME
The name of the marker point of wrappers.

Traits§

Triplets
The reads and writes of triplets stored in doublets.

Functions§

import_triplets_lino
Writes the triplets of text and returns their indices, one per line.
match_triplets_query
The values of $variable under which every pattern of restriction matches a triplet, each once, in the order found: a read-only substitution query, as the GraphQL layer asks them (issue #153).
process_triplets_query
Runs a substitution query and returns the changes it made, in order: creations and updates as the substitution lists them, then deletions.
triplets_to_lino
Every triplet as a line (index: type from to), in the order of the addresses.