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

Function MemoizeHash_equal

src/backend/executor/nodeMemoize.c:215–259  ·  view source on GitHub ↗

* MemoizeHash_equal * Equality function for confirming hash value matches during a hash * table lookup. 'key2' is never used. Instead the MemoizeState's * probeslot is always populated with details of what's being looked up. */

Source from the content-addressed store, hash-verified

213 * probeslot is always populated with details of what's being looked up.
214 */
215static bool
216MemoizeHash_equal(struct memoize_hash *tb, const MemoizeKey *key1,
217 const MemoizeKey *key2)
218{
219 MemoizeState *mstate = (MemoizeState *) tb->private_data;
220 ExprContext *econtext = mstate->ss.ps.ps_ExprContext;
221 TupleTableSlot *tslot = mstate->tableslot;
222 TupleTableSlot *pslot = mstate->probeslot;
223
224 /* probeslot should have already been prepared by prepare_probe_slot() */
225 ExecStoreMinimalTuple(key1->params, tslot, false);
226
227 if (mstate->binary_mode)
228 {
229 int numkeys = mstate->nkeys;
230
231 slot_getallattrs(tslot);
232 slot_getallattrs(pslot);
233
234 for (int i = 0; i < numkeys; i++)
235 {
236 FormData_pg_attribute *attr;
237
238 if (tslot->tts_isnull[i] != pslot->tts_isnull[i])
239 return false;
240
241 /* both NULL? they're equal */
242 if (tslot->tts_isnull[i])
243 continue;
244
245 /* perform binary comparison on the two datums */
246 attr = &tslot->tts_tupleDescriptor->attrs[i];
247 if (!datum_image_eq(tslot->tts_values[i], pslot->tts_values[i],
248 attr->attbyval, attr->attlen))
249 return false;
250 }
251 return true;
252 }
253 else
254 {
255 econtext->ecxt_innertuple = tslot;
256 econtext->ecxt_outertuple = pslot;
257 return ExecQualAndReset(mstate->cache_eq_expr, econtext);
258 }
259}
260
261/*
262 * Initialize the hash table to empty.

Callers

nothing calls this directly

Calls 4

ExecStoreMinimalTupleFunction · 0.85
slot_getallattrsFunction · 0.85
datum_image_eqFunction · 0.85
ExecQualAndResetFunction · 0.85

Tested by

no test coverage detected