commit nodes
| 54 | |
| 55 | // commit nodes |
| 56 | static void _CommitNodes |
| 57 | ( |
| 58 | PendingCreations *pending |
| 59 | ) { |
| 60 | Node *n = NULL; |
| 61 | GraphContext *gc = QueryCtx_GetGraphCtx(); |
| 62 | Graph *g = gc->g; |
| 63 | uint node_count = array_len(pending->created_nodes); |
| 64 | bool constraint_violation = false; |
| 65 | |
| 66 | // sync policy should be set to NOP, no need to sync/resize |
| 67 | ASSERT(Graph_GetMatrixPolicy(g) == SYNC_POLICY_NOP); |
| 68 | |
| 69 | for(int i = 0; i < node_count; i++) { |
| 70 | n = pending->created_nodes[i]; |
| 71 | |
| 72 | AttributeSet attr = pending->node_attributes[i]; |
| 73 | int* labels = pending->node_labels[i]; |
| 74 | uint label_count = array_len(labels); |
| 75 | |
| 76 | // introduce node into graph |
| 77 | CreateNode(gc, n, labels, label_count, attr, true); |
| 78 | |
| 79 | //---------------------------------------------------------------------- |
| 80 | // enforce constraints |
| 81 | //---------------------------------------------------------------------- |
| 82 | |
| 83 | if(constraint_violation == false) { |
| 84 | for(uint j = 0; j < label_count; j++) { |
| 85 | Schema *s = GraphContext_GetSchemaByID(gc, labels[j], SCHEMA_NODE); |
| 86 | char *err_msg = NULL; |
| 87 | if(!Schema_EnforceConstraints(s, (GraphEntity*)n, &err_msg)) { |
| 88 | // constraint violation |
| 89 | ASSERT(err_msg != NULL); |
| 90 | constraint_violation = true; |
| 91 | ErrorCtx_SetError("%s", err_msg); |
| 92 | free(err_msg); |
| 93 | break; |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | // commit edge blueprints |
| 101 | static void _CommitEdgesBlueprint |
no test coverage detected