gfphoenix78 commented on code in PR #724:
URL: https://github.com/apache/cloudberry/pull/724#discussion_r1855838595


##########
src/backend/executor/nodeSeqscan.c:
##########
@@ -365,3 +398,60 @@ ExecSeqScanInitializeWorker(SeqScanState *node,
        }
        node->ss.ss_currentScanDesc = scandesc;
 }
+
+/*
+ * Returns true if the element may be in the bloom filter.
+ */
+static bool
+PassByBloomFilter(SeqScanState *node, TupleTableSlot *slot)
+{
+       ScanKey sk;
+       Datum   val;
+       bool    isnull;
+       ListCell *lc;
+       bloom_filter *blm_filter;
+
+       foreach (lc, node->filters)
+       {
+               sk = lfirst(lc);
+               if (sk->sk_flags != SK_BLOOM_FILTER)
+                       continue;
+
+               val = slot_getattr(slot, sk->sk_attno, &isnull);
+               if (isnull)
+                       continue;
+
+               blm_filter = (bloom_filter *)DatumGetPointer(sk->sk_argument);
+               if (bloom_lacks_element(blm_filter, (unsigned char *)&val, 
sizeof(Datum)))
+                       return false;
+       }
+
+       return true;
+}
+
+/*
+ * Convert the list of ScanKey to the array, and append an emtpy ScanKey as
+ * the end flag of the array.
+ */
+static ScanKey
+ScanKeyListToArray(List *keys, int *num)
+{
+       ScanKey sk;
+
+       if (list_length(keys) == 0)
+               return NULL;
+
+       Assert(num);
+       *num = list_length(keys);
+
+       sk = (ScanKey)palloc(sizeof(ScanKeyData) * (*num + 1));
+       for (int i = 0; i < *num; ++i)
+               memcpy(&sk[i], list_nth(keys, i), sizeof(ScanKeyData));
+
+       /*
+        * SK_EMPYT means the end of the array of the ScanKey
+        */
+       sk[*num].sk_flags = SK_EMPYT;

Review Comment:
   How to check the boundary of the `ScanKey` array in rescan? In normal 
rescan, the number of `ScanKey`s is the same as begin_scan. If the number of 
`ScanKey`s is larger in rescan than that in begin_scan, the boundary value 
might be invalid and dangerous to access.



-- 
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]

Reply via email to