bkmgit commented on a change in pull request #11882: URL: https://github.com/apache/arrow/pull/11882#discussion_r776929946
########## File path: cpp/src/arrow/util/bit_block_counter.h ########## @@ -424,6 +565,141 @@ class ARROW_EXPORT OptionalBinaryBitBlockCounter { } }; +/// \brief A class that computes popcounts on the result of bitwise operations +/// between three bitmaps, 64 bits at a time. A 64-bit word is loaded from each +/// bitmap, then the popcount is computed on e.g. the bitwise-and of the three +/// words. +class ARROW_EXPORT TernaryBitBlockCounter { + public: + TernaryBitBlockCounter(const uint8_t* left_bitmap, int64_t left_offset, + const uint8_t* mid_bitmap, int64_t mid_offset, + const uint8_t* right_bitmap, int64_t right_offset, + int64_t length) + : left_bitmap_(util::MakeNonNull(left_bitmap) + left_offset / 8), + left_offset_(left_offset % 8), + mid_bitmap_(util::MakeNonNull(mid_bitmap) + mid_offset / 8), + mid_offset_(mid_offset % 8), + right_bitmap_(util::MakeNonNull(right_bitmap) + right_offset / 8), + right_offset_(right_offset % 8), + bits_remaining_(length) {} + + /// \brief Return the popcount of the bitwise-and of the next run of + /// available bits, up to 64. The returned pair contains the size of run and + /// the number of true values. The last block will have a length less than 64 + /// if the bitmap length is not a multiple of 64, and will return 0-length + /// blocks in subsequent invocations. + BitBlockCount NextAndAndWord() { return NextWord<detail::BitBlockAndAnd>(); } Review comment: Ok -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org