MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / ApplyConsume

Function ApplyConsume

src/execution_plan/ops/op_apply.c:50–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50static Record ApplyConsume(OpBase *opBase) {
51 Apply *op = (Apply *)opBase;
52
53 while(true) {
54 if(op->r == NULL) {
55 // retrieve a Record from the bound branch
56 op->r = OpBase_Consume(op->bound_branch);
57 if(op->r == NULL) {
58 return NULL; // Bound branch and this op are depleted.
59 }
60
61 // collect record for future freeing
62 array_append(op->records, op->r);
63
64 // Successfully pulled a new Record, propagate to the top of the RHS branch.
65 if(op->op_arg) {
66 Argument_AddRecord(op->op_arg, OpBase_CloneRecord(op->r));
67 }
68 }
69
70 // pull a Record from the RHS branch
71 Record rhs_record = OpBase_Consume(op->rhs_branch);
72
73 if(rhs_record == NULL) {
74 // RHS branch depleted for the current bound Record
75 // free it and loop back to retrieve a new one
76 op->r = NULL;
77 // reset the RHS branch
78 OpBase_PropagateReset(op->rhs_branch);
79 continue;
80 }
81
82 // clone the bound Record and merge the RHS Record into it
83 Record r = OpBase_CloneRecord(op->r);
84 Record_Merge(r, rhs_record);
85 // delete the RHS record, as it has been merged into r
86 OpBase_DeleteRecord(rhs_record);
87
88 return r;
89 }
90
91 return NULL;
92}
93
94static OpResult ApplyReset(OpBase *opBase) {
95 Apply *op = (Apply *)opBase;

Callers

nothing calls this directly

Calls 6

OpBase_ConsumeFunction · 0.85
Argument_AddRecordFunction · 0.85
OpBase_CloneRecordFunction · 0.85
OpBase_PropagateResetFunction · 0.85
Record_MergeFunction · 0.85
OpBase_DeleteRecordFunction · 0.85

Tested by

no test coverage detected