* 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(
| 2219 | * than to lose the ability to divide batches. |
| 2220 | */ |
| 2221 | void |
| 2222 | ExecHashGetBucketAndBatch(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 |
no test coverage detected