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

Function BlockSampler_Init

src/backend/utils/misc/sampling.c:38–55  ·  view source on GitHub ↗

* BlockSampler_Init -- prepare for random sampling of blocknumbers * * BlockSampler provides algorithm for block level sampling of a relation * as discussed on pgsql-hackers 2004-04-02 (subject "Large DB") * It selects a random sample of samplesize blocks out of * the nblocks blocks in the table. If the table has less than * samplesize blocks, all blocks are selected. * * Since we know the

Source from the content-addressed store, hash-verified

36 * Returns the number of blocks that BlockSampler_Next will return.
37 */
38BlockNumber
39BlockSampler_Init(BlockSampler bs, BlockNumber nblocks, int samplesize,
40 long randseed)
41{
42 bs->N = nblocks; /* measured table size */
43
44 /*
45 * If we decide to reduce samplesize for tables that have less or not much
46 * more than samplesize blocks, here is the place to do it.
47 */
48 bs->n = samplesize;
49 bs->t = 0; /* blocks scanned so far */
50 bs->m = 0; /* blocks selected so far */
51
52 sampler_random_init_state(randseed, bs->randstate);
53
54 return Min(bs->n, bs->N);
55}
56
57bool
58BlockSampler_HasMore(BlockSampler bs)

Callers 1

acquire_sample_rowsFunction · 0.85

Calls 1

Tested by

no test coverage detected