graflo.db.cypher.sync¶
Cypher for record sync: ensure vertices, then replace what changed owners wrote.
:func:owner_statements turns an owner chunk into the statements one unit of
work runs, in order: replace the changed owners' properties (their hash left
unset), delete the edges they own, create their edges, store their hashes.
A backend runs them in one transaction, or, without one, in one batch with the
hash last, so that an owner whose batch failed half-way keeps no hash and is
rewritten by the next sync.
Attributes¶
Statement = tuple[str, dict[str, Any]]
module-attribute
¶
Classes¶
Functions:¶
changed_owners(chunk, stored)
¶
Indexes of the owners whose hash differs from the stored one (stored: by index).
Source code in graflo/db/cypher/sync.py
delete_owned_query(edge, owner_keys)
¶
Delete the edge relationships of the owners in $rows.
A row is the owner's key map, or for an edge owned by a property, the owner's identity value.
Source code in graflo/db/cypher/sync.py
ensure_nodes_query(label, match_keys)
¶
Create each row's node unless its key exists; an existing node is left as is.
Source code in graflo/db/cypher/sync.py
hash_rows(chunk)
¶
The rows :func:stored_hashes_query takes for every owner of chunk.
Source code in graflo/db/cypher/sync.py
owner_statements(chunk, changed)
¶
The statements that rewrite the changed owners of chunk, hash last.
Source code in graflo/db/cypher/sync.py
replace_nodes_query(label, match_keys)
¶
Replace every property of each row's node, creating it when absent.
Source code in graflo/db/cypher/sync.py
set_hash_query(label, match_keys, hash_field)
¶
Store each row's hash h on its node.
Source code in graflo/db/cypher/sync.py
stored_hashes_query(label, match_keys, hash_field)
¶
The stored hash of each row's node, by the row's i; absent nodes return nothing.