zhangyue-hashdata commented on code in PR #724:
URL: https://github.com/apache/cloudberry/pull/724#discussion_r1856482708
##########
src/backend/executor/nodeHash.c:
##########
@@ -4126,3 +4151,138 @@ get_hash_mem(void)
return (int) mem_limit;
}
+
+/*
+ * Convert AttrFilter to ScanKeyData and send these runtime filters to the
+ * target node(seqscan).
+ */
+void
+PushdownRuntimeFilter(HashState *node)
+{
+ ListCell *lc;
+ List *scankeys;
+ ScanKey sk;
+ AttrFilter *attr_filter;
+
+ foreach (lc, node->filters)
+ {
+ scankeys = NIL;
+
+ attr_filter = lfirst(lc);
+ if (!IsA(attr_filter->target, SeqScanState) ||
attr_filter->empty)
+ continue;
+
+ /* bloom filter */
+ sk = (ScanKey)palloc0(sizeof(ScanKeyData));
+ sk->sk_flags = SK_BLOOM_FILTER;
+ sk->sk_attno = attr_filter->lattno;
+ sk->sk_subtype = INT8OID;
+ sk->sk_argument = PointerGetDatum(attr_filter->blm_filter);
+ scankeys = lappend(scankeys, sk);
+
+ /* range filter */
+ sk = (ScanKey)palloc0(sizeof(ScanKeyData));
+ sk->sk_flags = 0;
+ sk->sk_attno = attr_filter->lattno;
+ sk->sk_strategy = BTGreaterEqualStrategyNumber;
+ sk->sk_subtype = INT8OID;
+ sk->sk_argument = attr_filter->min;
+ scankeys = lappend(scankeys, sk);
+
+ sk = (ScanKey)palloc0(sizeof(ScanKeyData));
+ sk->sk_flags = 0;
+ sk->sk_attno = attr_filter->lattno;
+ sk->sk_strategy = BTLessEqualStrategyNumber;
+ sk->sk_subtype = INT8OID;
+ sk->sk_argument = attr_filter->max;
+ scankeys = lappend(scankeys, sk);
+
+ /* append new runtime filters to target node */
+ SeqScanState *sss = castNode(SeqScanState, attr_filter->target);
+ sss->filters = list_concat(sss->filters, scankeys);
Review Comment:
1. Combining Bloom filters will result in a higher False Positive Rate (FPR)
compared to using each of the individual Bloom filters separately, so it is not
recommended;
2. There is the same problem to combine range filters like combining Bloom
filters;
3. ~~There is only one Bloom filter and one range filter on the same
attribute in many cases;~~
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]