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

Function ExecHashGetBucketAndBatch

src/backend/executor/nodeHash.c:2221–2241  ·  view source on GitHub ↗

* ExecHashGetBucketAndBatch * Determine the bucket number and batch number for a hash value * * Note: on-the-fly increases of nbatch must not change the bucket number * for a given hash code (since we don't move tuples to different hash * chains), and must only cause the batch number to remain the same or * increase. Our algorithm is * bucketno = hashvalue MOD nbuckets * batchno = ROR(

Source from the content-addressed store, hash-verified

2219 * than to lose the ability to divide batches.
2220 */
2221void
2222ExecHashGetBucketAndBatch(HashJoinTable hashtable,
2223 uint32 hashvalue,
2224 int *bucketno,
2225 int *batchno)
2226{
2227 uint32 nbuckets = (uint32) hashtable->nbuckets;
2228 uint32 nbatch = (uint32) hashtable->nbatch;
2229
2230 if (nbatch > 1)
2231 {
2232 *bucketno = hashvalue & (nbuckets - 1);
2233 *batchno = pg_rotate_right32(hashvalue,
2234 hashtable->log2_nbuckets) & (nbatch - 1);
2235 }
2236 else
2237 {
2238 *bucketno = hashvalue & (nbuckets - 1);
2239 *batchno = 0;
2240 }
2241}
2242
2243/*
2244 * ExecScanHashBucket

Calls 1

pg_rotate_right32Function · 0.85

Tested by

no test coverage detected