Lock the graph and commit all changes introduced by the operation.
| 194 | |
| 195 | // Lock the graph and commit all changes introduced by the operation. |
| 196 | void 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())) { |
no test coverage detected