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

Function CallSubqueryConsume

src/execution_plan/ops/op_call_subquery.c:301–332  ·  view source on GitHub ↗

consumes a record from the lhs, plants it in the Argument\List op(s), and consumes a record from the body until depletion. in case the subquery is returning, merges the input (lhs) record with the output record. otherwise, the input record is passed as-is upon depletion of the body, repeats the above. depletion of lhs yields depletion of this operation

Source from the content-addressed store, hash-verified

299// upon depletion of the body, repeats the above. depletion of lhs yields
300// depletion of this operation
301static Record CallSubqueryConsume
302(
303 OpBase *opBase // operation
304) {
305 OpCallSubquery *op = (OpCallSubquery *)opBase;
306
307 // if there are more records to consume from body, consume them before
308 // consuming another record from lhs
309 if(op->r) {
310 return _handoff(op);
311 }
312 ASSERT(op->r == NULL);
313
314 // consume from lhs if exists, otherwise create a dummy-record to pass to
315 // the body (rhs). the latter case will happen AT MOST once
316 if(op->lhs) {
317 op->r = OpBase_Consume(op->lhs);
318 } else if(op->first) {
319 op->r = OpBase_CreateRecord((OpBase *)op);
320 op->first = false;
321 }
322
323 // plant the record consumed at the Argument ops
324 if(op->r) {
325 _plant_records_Arguments(op);
326 } else {
327 // no records - lhs depleted
328 return NULL;
329 }
330
331 return _handoff(op);
332}
333
334// frees CallSubquery internal data structures
335static void _free_records

Callers

nothing calls this directly

Calls 4

OpBase_ConsumeFunction · 0.85
OpBase_CreateRecordFunction · 0.85
_plant_records_ArgumentsFunction · 0.85
_handoffFunction · 0.70

Tested by

no test coverage detected