MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / _CommitEdges

Function _CommitEdges

src/execution_plan/ops/shared/create_functions.c:134–175  ·  view source on GitHub ↗

commit edges

Source from the content-addressed store, hash-verified

132
133// commit edges
134static void _CommitEdges
135(
136 PendingCreations *pending
137) {
138 Edge *e = NULL;
139 GraphContext *gc = QueryCtx_GetGraphCtx();
140 Graph *g = gc->g;
141 uint edge_count = array_len(pending->created_edges);
142 bool constraint_violation = false;
143
144 // sync policy should be set to NOP, no need to sync/resize
145 ASSERT(Graph_GetMatrixPolicy(g) == SYNC_POLICY_NOP);
146
147 for(int i = 0; i < edge_count; i++) {
148 e = pending->created_edges[i];
149 NodeID src_id = Edge_GetSrcNodeID(e);
150 NodeID dest_id = Edge_GetDestNodeID(e);
151 AttributeSet attr = pending->edge_attributes[i];
152
153 Schema *s = GraphContext_GetSchema(gc, e->relationship, SCHEMA_EDGE);
154 // all schemas have been created in the edge blueprint loop or earlier
155 ASSERT(s != NULL);
156 int relation_id = Schema_GetID(s);
157
158 CreateEdge(gc, e, src_id, dest_id, relation_id, attr, true);
159
160 //----------------------------------------------------------------------
161 // enforce constraints
162 //----------------------------------------------------------------------
163
164 if(constraint_violation == false) {
165 char *err_msg = NULL;
166 if(!Schema_EnforceConstraints(s, (GraphEntity*)e, &err_msg)) {
167 // constraint violated!
168 ASSERT(err_msg != NULL);
169 constraint_violation = true;
170 ErrorCtx_SetError("%s", err_msg);
171 free(err_msg);
172 }
173 }
174 }
175}
176
177// Initialize all variables for storing pending creations.
178void NewPendingCreationsContainer

Callers 1

CommitNewEntitiesFunction · 0.85

Calls 10

QueryCtx_GetGraphCtxFunction · 0.85
array_lenFunction · 0.85
Graph_GetMatrixPolicyFunction · 0.85
Edge_GetSrcNodeIDFunction · 0.85
Edge_GetDestNodeIDFunction · 0.85
GraphContext_GetSchemaFunction · 0.85
Schema_GetIDFunction · 0.85
CreateEdgeFunction · 0.85
ErrorCtx_SetErrorFunction · 0.85

Tested by

no test coverage detected