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

Function CommitNewEntities

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

Lock the graph and commit all changes introduced by the operation.

Source from the content-addressed store, hash-verified

194
195// Lock the graph and commit all changes introduced by the operation.
196void CommitNewEntities
197(
198 OpBase *op,
199 PendingCreations *pending
200) {
201 Graph *g = QueryCtx_GetGraph();
202 uint node_count = array_len(pending->created_nodes);
203 uint edge_count = array_len(pending->created_edges);
204
205 // lock everything
206 QueryCtx_LockForCommit();
207
208 //--------------------------------------------------------------------------
209 // commit nodes
210 //--------------------------------------------------------------------------
211
212 if(node_count > 0) {
213 Graph_AllocateNodes(g, node_count);
214
215 // set graph matrix sync policy to resize
216 // no need to perform sync
217 Graph_SetMatrixPolicy(g, SYNC_POLICY_RESIZE);
218 _CommitNodesBlueprint(pending);
219
220 // set graph matrix sync policy to NOP
221 // no need to perform sync/resize
222 Graph_SetMatrixPolicy(g, SYNC_POLICY_NOP);
223 _CommitNodes(pending);
224
225 // clear pending attributes array
226 array_clear(pending->node_attributes);
227
228 if(unlikely(ErrorCtx_EncounteredError())) {
229 goto cleanup;
230 }
231 }
232
233 //--------------------------------------------------------------------------
234 // commit edges
235 //--------------------------------------------------------------------------
236
237 if(edge_count > 0) {
238 Graph_AllocateEdges(g, edge_count);
239
240 // set graph matrix sync policy to resize
241 // no need to perform sync
242 Graph_SetMatrixPolicy(g, SYNC_POLICY_RESIZE);
243 _CommitEdgesBlueprint(pending->edges_to_create);
244
245 // set graph matrix sync policy to NOP
246 // no need to perform sync/resize
247 Graph_SetMatrixPolicy(g, SYNC_POLICY_NOP);
248 _CommitEdges(pending);
249
250 // clear pending attributes array
251 array_clear(pending->edge_attributes);
252
253 if(unlikely(ErrorCtx_EncounteredError())) {

Callers 2

CreateConsumeFunction · 0.85
MergeCreate_CommitFunction · 0.85

Calls 11

QueryCtx_GetGraphFunction · 0.85
array_lenFunction · 0.85
QueryCtx_LockForCommitFunction · 0.85
Graph_AllocateNodesFunction · 0.85
Graph_SetMatrixPolicyFunction · 0.85
_CommitNodesBlueprintFunction · 0.85
_CommitNodesFunction · 0.85
Graph_AllocateEdgesFunction · 0.85
_CommitEdgesBlueprintFunction · 0.85
_CommitEdgesFunction · 0.85

Tested by

no test coverage detected