graflo.db.resolve¶
Helpers for resolving vertices by an arbitrary field-set.
Edge-only sources reference their endpoints by a secondary identity — a field
set that identifies the vertex but is not its upsert key. Locating those
endpoints means mapping secondary key -> primary key immediately before the
edge write, which every backend can do through :meth:Connection.resolve_vertices.
This module holds the backend-agnostic pieces of that lookup: extracting key
tuples from documents, building the OR-of-AND filter that selects a chunk
of keys, and bucketing returned documents back by key.
bucket_by_key(docs, match_keys)
¶
Group docs by their match_keys tuple, preserving multiplicity.
Source code in graflo/db/resolve.py
build_match_filter(match_keys, keys)
¶
Build a filter selecting any vertex whose match_keys equal one of keys.
Uses the list form consumed by :class:~graflo.filter.onto.FilterExpression
so it renders on every backend flavor (AQL, Cypher, nGQL, GSQL, SQL):
["OR", [["AND", [["==", value, field], ...]], ...]].
A single key with a single field collapses to a bare leaf, and a single key
collapses to a bare AND — smaller predicates for the common unary case.
Source code in graflo/db/resolve.py
chunked(items, size)
¶
Yield items in lists of at most size.
Source code in graflo/db/resolve.py
distinct_keys(docs, match_keys)
¶
Deduplicated key tuples of docs, preserving first-occurrence order.
Source code in graflo/db/resolve.py
index_matches_by_doc(key_docs, match_keys, buckets)
¶
Map each input document's position to the vertices it matched.
Positions with an unresolvable key, or with no match, are absent from the
result — callers distinguish the two by recomputing :func:key_tuple.
Source code in graflo/db/resolve.py
key_tuple(doc, match_keys)
¶
Extract the key tuple of doc for match_keys.
Returns None when any field is absent or None — a partial key must
never be partially matched, so such documents are unresolvable by design.