bkmgit commented on a change in pull request #11882:
URL: https://github.com/apache/arrow/pull/11882#discussion_r767672873
##########
File path: cpp/src/arrow/util/bit_block_counter.h
##########
@@ -586,5 +961,144 @@ static void VisitTwoBitBlocksVoid(const
std::shared_ptr<Buffer>& left_bitmap_buf
}
}
+template <typename VisitNotNull, typename VisitNull>
+static void VisitThreeBitBlocksVoid(
+ const std::shared_ptr<Buffer>& left_bitmap_buf, int64_t left_offset,
+ const std::shared_ptr<Buffer>& mid_bitmap_buf, int64_t mid_offset,
+ const std::shared_ptr<Buffer>& right_bitmap_buf, int64_t right_offset,
int64_t length,
+ VisitNotNull&& visit_not_null, VisitNull&& visit_null) {
+ if (((left_bitmap_buf == NULLPTR) && (mid_bitmap_buf == NULLPTR)) ||
+ ((mid_bitmap_buf == NULLPTR) && (right_bitmap_buf == NULLPTR)) ||
+ ((left_bitmap_buf == NULLPTR) && (right_bitmap_buf == NULLPTR))) {
+ // At most one bitmap is present
+ if ((left_bitmap_buf == NULLPTR) && (mid_bitmap_buf == NULLPTR)) {
+ return VisitBitBlocksVoid(right_bitmap_buf, right_offset, length,
+ std::forward<VisitNotNull>(visit_not_null),
+ std::forward<VisitNull>(visit_null));
+ } else if ((mid_bitmap_buf == NULLPTR) && (right_bitmap_buf == NULLPTR)) {
+ return VisitBitBlocksVoid(left_bitmap_buf, left_offset, length,
+ std::forward<VisitNotNull>(visit_not_null),
+ std::forward<VisitNull>(visit_null));
+ } else {
+ return VisitBitBlocksVoid(mid_bitmap_buf, mid_offset, length,
+ std::forward<VisitNotNull>(visit_not_null),
+ std::forward<VisitNull>(visit_null));
+ }
+ }
+ // Two bitmaps are present
+ if (left_bitmap_buf == NULLPTR) {
+ const uint8_t* mid_bitmap = mid_bitmap_buf->data();
+ const uint8_t* right_bitmap = right_bitmap_buf->data();
+ BinaryBitBlockCounter bit_counter(mid_bitmap, mid_offset, right_bitmap,
right_offset,
+ length);
+ int64_t position = 0;
+ while (position < length) {
+ BitBlockCount block = bit_counter.NextAndWord();
+ if (block.AllSet()) {
+ for (int64_t i = 0; i < block.length; ++i, ++position) {
+ visit_not_null(position);
+ }
+ } else if (block.NoneSet()) {
+ for (int64_t i = 0; i < block.length; ++i, ++position) {
+ visit_null();
+ }
+ } else {
+ for (int64_t i = 0; i < block.length; ++i, ++position) {
+ if (bit_util::GetBit(mid_bitmap, mid_offset + position) &&
+ bit_util::GetBit(right_bitmap, right_offset + position)) {
+ visit_not_null(position);
+ } else {
+ visit_null();
+ }
+ }
+ }
+ }
+ } else if (mid_bitmap_buf == NULLPTR) {
+ const uint8_t* left_bitmap = left_bitmap_buf->data();
+ const uint8_t* right_bitmap = right_bitmap_buf->data();
+ BinaryBitBlockCounter bit_counter(left_bitmap, left_offset, right_bitmap,
+ right_offset, length);
+ int64_t position = 0;
+ while (position < length) {
+ BitBlockCount block = bit_counter.NextAndWord();
+ if (block.AllSet()) {
+ for (int64_t i = 0; i < block.length; ++i, ++position) {
+ visit_not_null(position);
+ }
+ } else if (block.NoneSet()) {
+ for (int64_t i = 0; i < block.length; ++i, ++position) {
+ visit_null();
+ }
+ } else {
+ for (int64_t i = 0; i < block.length; ++i, ++position) {
+ if (bit_util::GetBit(left_bitmap, left_offset + position) &&
+ bit_util::GetBit(right_bitmap, right_offset + position)) {
+ visit_not_null(position);
+ } else {
+ visit_null();
+ }
+ }
+ }
+ }
+ } else {
+ const uint8_t* left_bitmap = left_bitmap_buf->data();
Review comment:
Thanks. Better to test each of the cases separately.
--
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]