graflo.hq.endpoint_resolve¶
Resolve edge endpoints declared by a secondary identity.
An edge-only source references its endpoints by an alternate key. Before the edge can be written, that key has to be mapped back to the vertex's primary identity — which is what every backend's edge write already expects.
Doing the mapping here rather than pushing the predicate into each backend's
edge query keeps one semantic across all of them, and is the only approach that
works for backends addressing endpoints by key (PostgreSQL foreign keys,
NebulaGraph VIDs, TigerGraph PRIMARY_ID).
AmbiguousEndpointError
¶
EndpointResolutionStats
dataclass
¶
What happened while resolving one edge batch.
Unmatched and ambiguous endpoints are ordinary data conditions rather than failures, so they are counted and reported instead of raising.
Source code in graflo/hq/endpoint_resolve.py
ambiguous = 0
class-attribute
instance-attribute
¶
Rows whose key matched more than one vertex.
dropped = 0
class-attribute
instance-attribute
¶
Rows that produced no edge.
unmatched = 0
class-attribute
instance-attribute
¶
Rows whose key matched no vertex.
unresolvable = 0
class-attribute
instance-attribute
¶
Rows whose key was absent or incomplete, so no lookup was possible.
written = 0
class-attribute
instance-attribute
¶
Edge documents produced, which exceeds rows when fanning out.
resolve_edge_endpoints(db, docs, *, source_class, target_class, source_match_fields, target_match_fields, source_identity_fields, target_identity_fields, resolve_source, resolve_target, policy)
¶
Rewrite endpoint projections from secondary keys to primary identities.
Only the endpoints flagged for resolution are looked up; the other side is passed through untouched, which is what makes asymmetric selection work.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
docs
|
list[Any]
|
|
required |
resolve_source
|
bool
|
True when the source endpoint uses a secondary identity |
required |
resolve_target
|
bool
|
Same, for the target endpoint |
required |
policy
|
EndpointAmbiguityPolicy
|
What to do when a key matches several vertices |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[list[Any], EndpointResolutionStats]
|
rewritten edge documents, and what happened while resolving. |
Raises:
| Type | Description |
|---|---|
AmbiguousEndpointError
|
on multiple matches under the |
Source code in graflo/hq/endpoint_resolve.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |