| 18 | static void ProjectFree(OpBase *opBase); |
| 19 | |
| 20 | OpBase *NewProjectOp(const ExecutionPlan *plan, AR_ExpNode **exps) { |
| 21 | OpProject *op = rm_malloc(sizeof(OpProject)); |
| 22 | op->exps = exps; |
| 23 | op->singleResponse = false; |
| 24 | op->exp_count = array_len(exps); |
| 25 | op->record_offsets = array_new(uint, op->exp_count); |
| 26 | op->r = NULL; |
| 27 | op->projection = NULL; |
| 28 | |
| 29 | // Set our Op operations |
| 30 | OpBase_Init((OpBase *)op, OPType_PROJECT, "Project", NULL, ProjectConsume, |
| 31 | ProjectReset, NULL, ProjectClone, ProjectFree, false, plan); |
| 32 | |
| 33 | for(uint i = 0; i < op->exp_count; i ++) { |
| 34 | // The projected record will associate values with their resolved name |
| 35 | // to ensure that space is allocated for each entry. |
| 36 | int record_idx = OpBase_Modifies((OpBase *)op, op->exps[i]->resolved_name); |
| 37 | array_append(op->record_offsets, record_idx); |
| 38 | } |
| 39 | |
| 40 | return (OpBase *)op; |
| 41 | } |
| 42 | |
| 43 | static Record ProjectConsume(OpBase *opBase) { |
| 44 | OpProject *op = (OpProject *)opBase; |
no test coverage detected