jrgemignani commented on code in PR #2592:
URL: https://github.com/apache/age/pull/2592#discussion_r4250957972
##########
src/backend/utils/adt/age_global_graph.c:
##########
@@ -1980,6 +2365,233 @@ GRAPH_global_context *find_GRAPH_global_context(Oid
graph_oid)
return NULL;
}
+/*
+ * Find a graph context for materializing a VLE path. The path may come from a
+ * traversal whose context has since been retired, so retired contexts that a
+ * query still pins are considered too. The first context that holds every
+ * vertex and edge of the path is returned, or NULL if there is none.
+ */
+GRAPH_global_context *find_GRAPH_global_context_for_path(Oid graph_oid,
+ const graphid *ids,
+ int64 count)
+{
+ GRAPH_global_context *ggctx = NULL;
+
+ for (ggctx = global_graph_contexts; ggctx != NULL; ggctx = ggctx->next)
+ {
+ bool complete = true;
+ int64 i;
+
+ if (ggctx->graph_oid != graph_oid)
+ {
+ continue;
+ }
+
+ for (i = 0; i < count; i++)
+ {
+ /*
+ * get_edge_entry() asserts that the edge exists; a context may
+ * lack it here, so look the edge up directly.
+ */
+ if ((i % 2 == 0 && get_vertex_entry(ggctx, ids[i]) == NULL) ||
+ (i % 2 == 1 &&
+ agehash_lookup(ggctx->edge_table, &ids[i]) == NULL))
+ {
+ complete = false;
+ break;
+ }
+ }
Review Comment:
Thanks. The alternating vertex/edge positions are the existing
VLE_path_container format, not a new assumption introduced by this helper.
Producers create 2 * edge_count + 1 interleaved entries, and the existing
path
materializers already consume that format by parity. This helper also
verifies
each even position through the vertex table and each odd position through the
edge table. A future format change would require versioning the container tag
and updating all readers, as the existing format documentation states.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]