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):
| triplet | doublets |
|---|---|
(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, again | the 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:
PandNare 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 whenyisi, a pair, or a duplicate pair(p i)that points back at it;- anything else, the
Extendswiring of aTypesDecoratorsay, 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);fromandtoare0when empty. - Triplet
Change - One change a query made: a creation has no
before, a deletion noafter, and a read reports the same triplet on both sides. - Triplet
Markers - The two marker points of the encoding.
- Triplet
Query - A restriction of
Triplets::each_triplet:Nonematches any value,Some(0)an emptyfromorto. - Triplets
Over Doublets - A decorator that stores triplets
(index: type from to)in the doublets of the layer it wraps; see the module documentation.
Enums§
- Doublet
Role - 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
textand returns their indices, one per line. - match_
triplets_ query - The values of
$variableunder which every pattern ofrestrictionmatches 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.