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

Function ExecHashGetSkewBucket

src/backend/executor/nodeHash.c:3077–3113  ·  view source on GitHub ↗

* ExecHashGetSkewBucket * * Returns the index of the skew bucket for this hashvalue, * or INVALID_SKEW_BUCKET_NO if the hashvalue is not * associated with any active skew bucket. */

Source from the content-addressed store, hash-verified

3075 * associated with any active skew bucket.
3076 */
3077int
3078ExecHashGetSkewBucket(HashJoinTable hashtable, uint32 hashvalue)
3079{
3080 int bucket;
3081
3082 /*
3083 * Always return INVALID_SKEW_BUCKET_NO if not doing skew optimization (in
3084 * particular, this happens after the initial batch is done).
3085 */
3086 if (!hashtable->skewEnabled)
3087 return INVALID_SKEW_BUCKET_NO;
3088
3089 /*
3090 * Since skewBucketLen is a power of 2, we can do a modulo by ANDing.
3091 */
3092 bucket = hashvalue & (hashtable->skewBucketLen - 1);
3093
3094 /*
3095 * While we have not hit a hole in the hashtable and have not hit the
3096 * desired bucket, we have collided with some other hash value, so try the
3097 * next bucket location.
3098 */
3099 while (hashtable->skewBucket[bucket] != NULL &&
3100 hashtable->skewBucket[bucket]->hashvalue != hashvalue)
3101 bucket = (bucket + 1) & (hashtable->skewBucketLen - 1);
3102
3103 /*
3104 * Found the desired bucket?
3105 */
3106 if (hashtable->skewBucket[bucket] != NULL)
3107 return bucket;
3108
3109 /*
3110 * There must not be any hashtable entry for this hash value.
3111 */
3112 return INVALID_SKEW_BUCKET_NO;
3113}
3114
3115/*
3116 * ExecHashSkewTableInsert

Callers 2

MultiExecPrivateHashFunction · 0.85
ExecHashJoinImplFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected