| 68 | } |
| 69 | |
| 70 | OpBase *NewMergeCreateOp(const ExecutionPlan *plan, NodeCreateCtx *nodes, EdgeCreateCtx *edges) { |
| 71 | OpMergeCreate *op = rm_calloc(1, sizeof(OpMergeCreate)); |
| 72 | op->unique_entities = raxNew(); // Create a map to unique pending creations. |
| 73 | op->hash_state = XXH64_createState(); // Create a hash state. |
| 74 | |
| 75 | NewPendingCreationsContainer(&op->pending, nodes, edges); // Prepare all creation variables. |
| 76 | op->handoff_mode = false; |
| 77 | op->records = array_new(Record, 32); |
| 78 | |
| 79 | // insert one NULL value to terminate execution of the op |
| 80 | array_append(op->records, NULL); |
| 81 | |
| 82 | // Set our Op operations |
| 83 | OpBase_Init((OpBase *)op, OPType_MERGE_CREATE, "MergeCreate", MergeCreateInit, MergeCreateConsume, |
| 84 | NULL, NULL, MergeCreateClone, MergeCreateFree, true, plan); |
| 85 | |
| 86 | uint node_blueprint_count = array_len(nodes); |
| 87 | uint edge_blueprint_count = array_len(edges); |
| 88 | |
| 89 | // Construct the array of IDs this operation modifies |
| 90 | for(uint i = 0; i < node_blueprint_count; i ++) { |
| 91 | NodeCreateCtx *n = nodes + i; |
| 92 | n->node_idx = OpBase_Modifies((OpBase *)op, n->alias); |
| 93 | } |
| 94 | for(uint i = 0; i < edge_blueprint_count; i ++) { |
| 95 | EdgeCreateCtx *e = edges + i; |
| 96 | e->edge_idx = OpBase_Modifies((OpBase *)op, e->alias); |
| 97 | bool aware; |
| 98 | UNUSED(aware); |
| 99 | aware = OpBase_Aware((OpBase *)op, e->src, &e->src_idx); |
| 100 | ASSERT(aware == true); |
| 101 | aware = OpBase_Aware((OpBase *)op, e->dest, &e->dest_idx); |
| 102 | ASSERT(aware == true); |
| 103 | } |
| 104 | |
| 105 | return (OpBase *)op; |
| 106 | } |
| 107 | |
| 108 | static OpResult MergeCreateInit(OpBase* opBase) { |
| 109 | OpMergeCreate *op = (OpMergeCreate *)opBase; |
no test coverage detected