MCPcopy Create free account
hub / github.com/apache/cloudberry / UpdateMotionLayerNode

Function UpdateMotionLayerNode

src/backend/cdb/motion/cdbmotion.c:246–304  ·  view source on GitHub ↗

* Initialize a single motion node. This is called by the executor when a * motion node in the plan tree is being initialized. * * This function is called from: ExecInitMotion() */

Source from the content-addressed store, hash-verified

244 * This function is called from: ExecInitMotion()
245 */
246void
247UpdateMotionLayerNode(MotionLayerState *mlStates, int16 motNodeID, bool preserveOrder, TupleDesc tupDesc)
248{
249 MemoryContext oldCtxt;
250 MotionNodeEntry *pEntry;
251
252 if (motNodeID < 1 || motNodeID > mlStates->mneCount)
253 elog(ERROR, "invalid motion node ID %d", motNodeID);
254
255 AssertArg(tupDesc != NULL);
256
257 /*
258 * Switch to the Motion Layer's memory-context, so that the motion node
259 * can be reset later.
260 */
261 oldCtxt = MemoryContextSwitchTo(mlStates->motion_layer_mctx);
262
263 pEntry = &mlStates->mnEntries[motNodeID - 1];
264
265 Assert(pEntry->valid);
266
267 pEntry->motion_node_id = motNodeID;
268
269 /* Finish up initialization of the motion node entry. */
270 pEntry->preserve_order = preserveOrder;
271 pEntry->tuple_desc = CreateTupleDescCopy(tupDesc);
272 InitSerTupInfo(pEntry->tuple_desc, &pEntry->ser_tup_info);
273
274 if (!preserveOrder)
275 {
276 /* Create a tuple-store for the motion node's incoming tuples. */
277 pEntry->ready_tuples = htfifo_create();
278 }
279 else
280 pEntry->ready_tuples = NULL;
281
282
283 pEntry->num_stream_ends_recvd = 0;
284
285 /* Initialize statistics counters. */
286 pEntry->stat_total_chunks_sent = 0;
287 pEntry->stat_total_bytes_sent = 0;
288 pEntry->stat_tuple_bytes_sent = 0;
289 pEntry->stat_total_sends = 0;
290 pEntry->stat_total_recvs = 0;
291 pEntry->stat_tuples_available = 0;
292 pEntry->stat_tuples_available_hwm = 0;
293 pEntry->stat_total_chunks_recvd = 0;
294 pEntry->stat_total_bytes_recvd = 0;
295 pEntry->stat_tuple_bytes_recvd = 0;
296
297 pEntry->cleanedUp = false;
298 pEntry->stopped = false;
299 pEntry->moreNetWork = true;
300
301
302 /* All done! Go back to caller memory-context. */
303 MemoryContextSwitchTo(oldCtxt);

Callers 1

ExecInitMotionFunction · 0.85

Calls 4

MemoryContextSwitchToFunction · 0.85
CreateTupleDescCopyFunction · 0.85
InitSerTupInfoFunction · 0.85
htfifo_createFunction · 0.85

Tested by

no test coverage detected