35 #define SH_PREFIX tuplehash
36 #define SH_ELEMENT_TYPE TupleHashEntryData
37 #define SH_KEY_TYPE MinimalTuple
38 #define SH_KEY firstTuple
39 #define SH_HASH_KEY(tb, key) TupleHashTableHash_internal(tb, key)
40 #define SH_EQUAL(tb, a, b) TupleHashTableMatch(tb, a, b) == 0
41 #define SH_SCOPE extern
43 #define SH_GET_HASH(tb, a) a->hash
61 const Oid *eqOperators,
62 const Oid *collations,
75 for (
i = 0;
i < numCols;
i++)
80 numCols, keyColIdx, eqFunctions, collations,
98 const Oid *eqOperators,
107 for (
i = 0;
i < numCols;
i++)
109 Oid eq_opr = eqOperators[
i];
111 Oid left_hash_function;
112 Oid right_hash_function;
116 &left_hash_function, &right_hash_function))
117 elog(
ERROR,
"could not find hash function for hash operator %u",
120 Assert(left_hash_function == right_hash_function);
121 (*eqFuncOids)[
i] = eq_function;
122 fmgr_info(right_hash_function, &(*hashFunctions)[
i]);
158 const Oid *eqfuncoids,
161 long nbuckets,
Size additionalsize,
165 bool use_variable_hash_iv)
177 if (nbuckets > hash_mem_limit)
178 nbuckets = hash_mem_limit;
204 if (use_variable_hash_iv)
209 hashtable->
hashtab = tuplehash_create(metacxt, nbuckets, hashtable);
226 allow_jit = metacxt != tablecxt;
233 keyColIdx, eqfuncoids, collations,
234 allow_jit ? parent : NULL);
259 const Oid *eqfuncoids,
262 long nbuckets,
Size additionalsize,
265 bool use_variable_hash_iv)
273 nbuckets, additionalsize,
277 use_variable_hash_iv);
288 tuplehash_reset(hashtable->
hashtab);
328 Assert(entry == NULL || entry->
hash == local_hash);
412 entry = tuplehash_lookup(hashtable->
hashtab,
key);
431 int numCols = hashtable->
numCols;
457 for (
i = 0;
i < numCols;
i++)
508 entry = tuplehash_insert_hash(hashtable->
hashtab,
key,
hash, &found);
558 econtext->ecxt_innertuple = slot2;
559 econtext->ecxt_outertuple = slot1;
#define Assert(condition)
ExprState * ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc, const TupleTableSlotOps *lops, const TupleTableSlotOps *rops, int numCols, const AttrNumber *keyColIdx, const Oid *eqfunctions, const Oid *collations, PlanState *parent)
void execTuplesHashPrepare(int numCols, const Oid *eqOperators, Oid **eqFuncOids, FmgrInfo **hashFunctions)
TupleHashTable BuildTupleHashTable(PlanState *parent, TupleDesc inputDesc, int numCols, AttrNumber *keyColIdx, const Oid *eqfuncoids, FmgrInfo *hashfunctions, Oid *collations, long nbuckets, Size additionalsize, MemoryContext tablecxt, MemoryContext tempcxt, bool use_variable_hash_iv)
TupleHashEntry LookupTupleHashEntryHash(TupleHashTable hashtable, TupleTableSlot *slot, bool *isnew, uint32 hash)
TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot, bool *isnew, uint32 *hash)
static uint32 TupleHashTableHash_internal(struct tuplehash_hash *tb, const MinimalTuple tuple)
uint32 TupleHashTableHash(TupleHashTable hashtable, TupleTableSlot *slot)
static int TupleHashTableMatch(struct tuplehash_hash *tb, const MinimalTuple tuple1, const MinimalTuple tuple2)
TupleHashEntry FindTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot, ExprState *eqcomp, FmgrInfo *hashfunctions)
TupleHashTable BuildTupleHashTableExt(PlanState *parent, TupleDesc inputDesc, int numCols, AttrNumber *keyColIdx, const Oid *eqfuncoids, FmgrInfo *hashfunctions, Oid *collations, long nbuckets, Size additionalsize, MemoryContext metacxt, MemoryContext tablecxt, MemoryContext tempcxt, bool use_variable_hash_iv)
void ResetTupleHashTable(TupleHashTable hashtable)
ExprState * execTuplesMatchPrepare(TupleDesc desc, int numCols, const AttrNumber *keyColIdx, const Oid *eqOperators, const Oid *collations, PlanState *parent)
static TupleHashEntry LookupTupleHashEntry_internal(TupleHashTable hashtable, TupleTableSlot *slot, bool *isnew, uint32 hash)
TupleTableSlot * ExecStoreMinimalTuple(MinimalTuple mtup, TupleTableSlot *slot, bool shouldFree)
const TupleTableSlotOps TTSOpsMinimalTuple
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
ExprContext * CreateStandaloneExprContext(void)
struct TupleHashTableData * TupleHashTable
struct TupleHashEntryData TupleHashEntryData
static bool ExecQualAndReset(ExprState *state, ExprContext *econtext)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Datum FunctionCall1Coll(FmgrInfo *flinfo, Oid collation, Datum arg1)
static uint32 murmurhash32(uint32 data)
if(TABLE==NULL||TABLE_index==NULL)
RegProcedure get_opcode(Oid opno)
bool get_op_hash_functions(Oid opno, RegProcedure *lhs_procno, RegProcedure *rhs_procno)
size_t get_hash_memory_limit(void)
static uint32 pg_rotate_left32(uint32 word, int n)
static uint32 DatumGetUInt32(Datum X)
MemoryContextSwitchTo(old_ctx)
static unsigned hash(unsigned *uv, int n)
FmgrInfo * tab_hash_funcs
TupleTableSlot * tableslot
ExprContext * exprcontext
TupleTableSlot * inputslot
TupleDesc CreateTupleDescCopy(TupleDesc tupdesc)
static MinimalTuple ExecCopySlotMinimalTuple(TupleTableSlot *slot)
static Datum slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull)