gfphoenix78 commented on code in PR #1384:
URL: https://github.com/apache/cloudberry/pull/1384#discussion_r2425103603
##########
contrib/pax_storage/src/cpp/comm/bitmap.h:
##########
@@ -134,12 +134,31 @@ struct BitmapRaw final {
static_assert(BM_WORD_BITS == (1 << BM_WORD_SHIFTS));
return (index >> BM_WORD_SHIFTS) < size;
}
- inline bool Empty() const {
+
+
+ inline bool Empty(uint32 end_index) const {
if (!bitmap) return true;
- for (size_t i = 0; i < size; i++)
- if (bitmap[i]) return false;
+
+ uint32 end_word = BM_INDEX_WORD_OFF(end_index);
+ uint32 end_bit_offset = BM_INDEX_BIT_OFF(end_index);
+
+ for (uint32 i = 0; i < end_word && i < size; i++) {
+ if (bitmap[i] != 0) return false;
+ }
+
+ // Check partial word at end
+ if (end_word < size && end_bit_offset > 0) {
+ T mask = (T(1) << end_bit_offset) - 1;
+ if (bitmap[end_word] & mask) return false;
+ }
Review Comment:
If the function is in the hot path, we may need more optimization, like
compare 64bits one time, SIMD.
--
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]