* Returns true if the element may be in the bloom filter. */
| 410 | * Returns true if the element may be in the bloom filter. |
| 411 | */ |
| 412 | bool |
| 413 | PassByBloomFilter(PlanState *ps, List *filters, TupleTableSlot *slot) |
| 414 | { |
| 415 | ScanKey sk; |
| 416 | Datum val; |
| 417 | bool isnull; |
| 418 | ListCell *lc; |
| 419 | bloom_filter *blm_filter; |
| 420 | |
| 421 | /* |
| 422 | * Mark that the pushdown runtime filter is actually taking effect. |
| 423 | */ |
| 424 | if (ps->instrument && !ps->instrument->prf_work && list_length(filters)) |
| 425 | ps->instrument->prf_work = true; |
| 426 | |
| 427 | foreach (lc, filters) |
| 428 | { |
| 429 | sk = lfirst(lc); |
| 430 | if (sk->sk_flags != SK_BLOOM_FILTER) |
| 431 | continue; |
| 432 | |
| 433 | val = slot_getattr(slot, sk->sk_attno, &isnull); |
| 434 | if (isnull) |
| 435 | continue; |
| 436 | |
| 437 | blm_filter = (bloom_filter *)DatumGetPointer(sk->sk_argument); |
| 438 | if (bloom_lacks_element(blm_filter, (unsigned char *)&val, sizeof(Datum))) |
| 439 | { |
| 440 | InstrCountFilteredPRF(ps, 1); |
| 441 | return false; |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | return true; |
| 446 | } |
| 447 | |
| 448 | /* |
| 449 | * Convert the list of ScanKey to the array, and append an emtpy ScanKey as |
no test coverage detected