commit edges
| 132 | |
| 133 | // commit edges |
| 134 | static 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. |
| 178 | void NewPendingCreationsContainer |
no test coverage detected