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

Function PushdownRuntimeFilter

src/backend/executor/nodeHash.c:4151–4211  ·  view source on GitHub ↗

* Convert AttrFilter to ScanKeyData and send these runtime filters to the * target node(seqscan). */

Source from the content-addressed store, hash-verified

4149 * target node(seqscan).
4150 */
4151void
4152PushdownRuntimeFilter(HashState *node)
4153{
4154 ListCell *lc;
4155 List *scankeys;
4156 ScanKey sk;
4157 AttrFilter *attr_filter;
4158
4159 foreach (lc, node->filters)
4160 {
4161 scankeys = NIL;
4162
4163 attr_filter = lfirst(lc);
4164 if (attr_filter->empty ||
4165 (!IsA(attr_filter->target, SeqScanState) &&
4166 !IsA(attr_filter->target, DynamicSeqScanState)))
4167 continue;
4168
4169 /* bloom filter */
4170 sk = (ScanKey)palloc0(sizeof(ScanKeyData));
4171 sk->sk_flags = SK_BLOOM_FILTER;
4172 sk->sk_attno = attr_filter->lattno;
4173 sk->sk_subtype = INT8OID;
4174 sk->sk_argument = PointerGetDatum(attr_filter->blm_filter);
4175 scankeys = lappend(scankeys, sk);
4176
4177 /* range filter */
4178 sk = (ScanKey)palloc0(sizeof(ScanKeyData));
4179 sk->sk_flags = 0;
4180 sk->sk_attno = attr_filter->lattno;
4181 sk->sk_strategy = BTGreaterEqualStrategyNumber;
4182 sk->sk_subtype = INT8OID;
4183 sk->sk_argument = attr_filter->min;
4184 scankeys = lappend(scankeys, sk);
4185
4186 sk = (ScanKey)palloc0(sizeof(ScanKeyData));
4187 sk->sk_flags = 0;
4188 sk->sk_attno = attr_filter->lattno;
4189 sk->sk_strategy = BTLessEqualStrategyNumber;
4190 sk->sk_subtype = INT8OID;
4191 sk->sk_argument = attr_filter->max;
4192 scankeys = lappend(scankeys, sk);
4193
4194 /* append new runtime filters to target node */
4195 if (IsA(attr_filter->target, SeqScanState))
4196 {
4197 SeqScanState *sss = castNode(SeqScanState, attr_filter->target);
4198 sss->filters = list_concat(sss->filters, scankeys);
4199 }
4200 else if (IsA(attr_filter->target, DynamicSeqScanState))
4201 {
4202 DynamicSeqScanState *dsss = castNode(DynamicSeqScanState, attr_filter->target);
4203 dsss->filters = list_concat(dsss->filters, scankeys);
4204 }
4205 else
4206 {
4207 /* never reach here */
4208 pg_unreachable();

Callers 1

MultiExecPrivateHashFunction · 0.85

Calls 4

lappendFunction · 0.85
list_concatFunction · 0.85
foreachFunction · 0.50
palloc0Function · 0.50

Tested by

no test coverage detected