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

Function CreateConsume

src/execution_plan/ops/op_create.c:139–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139static Record CreateConsume
140(
141 OpBase *opBase
142) {
143 OpCreate *op = (OpCreate *)opBase;
144 Record r;
145
146 // return mode, all data was consumed
147 if(op->records) return _handoff(op);
148
149 // consume mode
150 op->records = array_new(Record, 32);
151
152 // initialize the records array with NULL, which will terminate execution
153 // upon depletion
154 array_append(op->records, NULL);
155
156 OpBase *child = NULL;
157 GraphContext *gc = QueryCtx_GetGraphCtx();
158
159 if(op->op.childCount == 0) {
160 // no child operation to call
161 r = OpBase_CreateRecord(opBase);
162 // create entities
163 _CreateNodes(op, r, gc);
164 _CreateEdges(op, r, gc);
165
166 // save record for later use
167 array_append(op->records, r);
168 } else {
169 // pull data until child is depleted
170 child = op->op.children[0];
171 while((r = OpBase_Consume(child))) {
172 // persist scalars from previous ops before storing the record
173 // as those ops will be freed before the records are handed off
174 Record_PersistScalars(r);
175
176 // create entities
177 _CreateNodes(op, r, gc);
178 _CreateEdges(op, r, gc);
179
180 // save record for later use
181 array_append(op->records, r);
182 }
183 }
184
185 // done reading, we're not going to call consume any longer
186 // there might be operations e.g. index scan that need to free
187 // index R/W lock, as such free all execution plan operation up the chain
188 if(child) {
189 OpBase_PropagateReset(child);
190 }
191
192 // create entities
193 CommitNewEntities(opBase, &op->pending);
194
195 // return record
196 return _handoff(op);

Callers

nothing calls this directly

Calls 9

QueryCtx_GetGraphCtxFunction · 0.85
OpBase_CreateRecordFunction · 0.85
_CreateNodesFunction · 0.85
_CreateEdgesFunction · 0.85
OpBase_ConsumeFunction · 0.85
Record_PersistScalarsFunction · 0.85
OpBase_PropagateResetFunction · 0.85
CommitNewEntitiesFunction · 0.85
_handoffFunction · 0.70

Tested by

no test coverage detected