graflo.db.arango.keys¶
ArangoDB document keys, computed on the client from identity values.
A vertex's _key is the value of a single-field identity when ArangoDB
accepts it as a key (a string of key characters, or an integer, at most 254
characters), and otherwise the SHA-256 hex digest of the typed identity tuple
(:func:~graflo.util.typed_values.typed_key), so 1 and "1" in a composite
identity are two keys. An edge's _key is the digest of its endpoints'
_id, its relation and the values of its identity fields. Because every key
is a function of identity values, edges reference their endpoints without
looking them up, and a resent document lands on the same key.
Attributes¶
KEY = '_key'
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
Functions:¶
digest(text)
¶
edge_documents(rows, source_class, target_class, match_keys_source, match_keys_target, relation_name, identity_fields, *, strict, fuse)
¶
Edge documents with _key, _from, _to and relation set.
A row is (source_doc, target_doc[, props]). With fuse, rows of one
edge become one document, later properties winning: one query does not
see what it wrote itself, so it would otherwise write the edge twice.
Raises:
| Type | Description |
|---|---|
ValueError
|
With strict, a row whose endpoint values cannot key it; otherwise the row is dropped. |
Source code in graflo/db/arango/keys.py
edge_key(from_id, to_id, relation, identity)
¶
The _key of an edge: a digest of its endpoints, relation and identity values.
An identity value is typed as a vertex identity value is; a null or non-scalar one keys by its encoded form, as the bulk fold keys it.
Source code in graflo/db/arango/keys.py
endpoint_key(doc, match_keys)
¶
The _key of the vertex doc names by its match_keys values.
Source code in graflo/db/arango/keys.py
vertex_documents(docs, match_keys, *, strict)
¶
docs with _key set from their match_keys values (new dicts).
A _key already in a document is replaced unless it is itself a match
key, so a vertex's key never depends on where the document came from.
Raises:
| Type | Description |
|---|---|
ValueError
|
With strict, a document whose values cannot key it;
otherwise such a document keeps no |
Source code in graflo/db/arango/keys.py
vertex_key(values)
¶
The _key of a vertex whose identity holds values, in identity order.
None when no value is set, or one cannot key a document (NaN, not a
scalar); a composite identity lacking some values keys as
:func:~graflo.util.typed_values.typed_key keys it.