prepare to create all edges for the current Record
| 83 | |
| 84 | // prepare to create all edges for the current Record |
| 85 | static void _CreateEdges |
| 86 | ( |
| 87 | OpCreate *op, |
| 88 | Record r, |
| 89 | GraphContext *gc |
| 90 | ) { |
| 91 | uint edges_to_create_count = array_len(op->pending.edges_to_create); |
| 92 | for(uint i = 0; i < edges_to_create_count; i++) { |
| 93 | // get specified edge to create |
| 94 | EdgeCreateCtx *e = op->pending.edges_to_create + i; |
| 95 | |
| 96 | // retrieve source and dest nodes |
| 97 | GraphEntity *src_node = (GraphEntity*)Record_GetNode(r, e->src_idx); |
| 98 | GraphEntity *dest_node = (GraphEntity*)Record_GetNode(r, e->dest_idx); |
| 99 | |
| 100 | // verify edge endpoints resolved properly, fail otherwise |
| 101 | if(unlikely(!src_node || |
| 102 | !dest_node || |
| 103 | GraphEntity_IsDeleted(src_node) || |
| 104 | GraphEntity_IsDeleted(dest_node))) { |
| 105 | ErrorCtx_RaiseRuntimeException( |
| 106 | "Failed to create relationship; endpoint was not found."); |
| 107 | } |
| 108 | |
| 109 | // create the actual edge |
| 110 | Edge newEdge = {0}; |
| 111 | newEdge.relationship = e->relation; |
| 112 | Edge_SetSrcNodeID(&newEdge, ENTITY_GET_ID(src_node)); |
| 113 | Edge_SetDestNodeID(&newEdge, ENTITY_GET_ID(dest_node)); |
| 114 | Edge *edge_ref = Record_AddEdge(r, e->edge_idx, newEdge); |
| 115 | |
| 116 | // convert query-level properties |
| 117 | PropertyMap *map = op->pending.edges_to_create[i].properties; |
| 118 | AttributeSet converted_attr = NULL; |
| 119 | if(map != NULL) { |
| 120 | ConvertPropertyMap(gc, &converted_attr, r, map, false); |
| 121 | } |
| 122 | |
| 123 | // save edge for later insertion |
| 124 | array_append(op->pending.created_edges, edge_ref); |
| 125 | |
| 126 | // save attributes to insert with node |
| 127 | array_append(op->pending.edge_attributes, converted_attr); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | // Return mode, emit a populated Record. |
| 132 | static Record _handoff |
no test coverage detected