typedef struct BloomState
{
FmgrInfo hashFn[INDEX_MAX_KEYS];
- BloomOptions *opts; /* stored in rd_amcache and defined at
- * creation time */
+ BloomOptions opts; /* copy of options on index's metapage */
int32 nColumns;
/*
- * sizeOfBloomTuple is index's specific, and it depends on reloptions, so
+ * sizeOfBloomTuple is index-specific, and it depends on reloptions, so
* precompute it
*/
Size sizeOfBloomTuple;
/* New search: have to calculate search signature */
ScanKey skey = scan->keyData;
- so->sign = palloc0(sizeof(SignType) * so->state.opts->bloomLength);
+ so->sign = palloc0(sizeof(SignType) * so->state.opts.bloomLength);
for (i = 0; i < scan->numberOfKeys; i++)
{
bool res = true;
/* Check index signature with scan signature */
- for (i = 0; i < so->state.opts->bloomLength; i++)
+ for (i = 0; i < so->state.opts.bloomLength; i++)
{
if ((itup->sign[i] & so->sign[i]) != so->sign[i])
{
index->rd_amcache = (void *) opts;
}
- state->opts = (BloomOptions *) index->rd_amcache;
+ memcpy(&state->opts, index->rd_amcache, sizeof(state->opts));
state->sizeOfBloomTuple = BLOOMTUPLEHDRSZ +
- sizeof(SignType) * state->opts->bloomLength;
+ sizeof(SignType) * state->opts.bloomLength;
}
/*
hashVal = DatumGetInt32(FunctionCall1(&state->hashFn[attno], value));
mySrand(hashVal ^ myRand());
- for (j = 0; j < state->opts->bitSize[attno]; j++)
+ for (j = 0; j < state->opts.bitSize[attno]; j++)
{
/* prevent mutiple evaluation */
- nBit = myRand() % (state->opts->bloomLength * BITSIGNTYPE);
+ nBit = myRand() % (state->opts.bloomLength * BITSIGNTYPE);
SETBIT(sign, nBit);
}
}