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

Function tablesample_getnext

src/backend/executor/nodeSamplescan.c:334–378  ·  view source on GitHub ↗

* Get next tuple from TABLESAMPLE method. */

Source from the content-addressed store, hash-verified

332 * Get next tuple from TABLESAMPLE method.
333 */
334static TupleTableSlot *
335tablesample_getnext(SampleScanState *scanstate)
336{
337 TableScanDesc scan = scanstate->ss.ss_currentScanDesc;
338 TupleTableSlot *slot = scanstate->ss.ss_ScanTupleSlot;
339
340 ExecClearTuple(slot);
341
342 if (scanstate->done)
343 return NULL;
344
345 for (;;)
346 {
347 if (!scanstate->haveblock)
348 {
349 if (!table_scan_sample_next_block(scan, scanstate))
350 {
351 scanstate->haveblock = false;
352 scanstate->done = true;
353
354 /* exhausted relation */
355 return NULL;
356 }
357
358 scanstate->haveblock = true;
359 }
360
361 if (!table_scan_sample_next_tuple(scan, scanstate, slot))
362 {
363 /*
364 * If we get here, it means we've exhausted the items on this page
365 * and it's time to move to the next.
366 */
367 scanstate->haveblock = false;
368 continue;
369 }
370
371 /* Found visible tuple, return it. */
372 break;
373 }
374
375 scanstate->donetuples++;
376
377 return slot;
378}

Callers 1

SampleNextFunction · 0.85

Calls 3

ExecClearTupleFunction · 0.85

Tested by

no test coverage detected