cyb70289 commented on a change in pull request #11674: URL: https://github.com/apache/arrow/pull/11674#discussion_r748954085
########## File path: cpp/src/arrow/util/bitmap_ops.cc ########## @@ -237,71 +237,105 @@ bool OptionalBitmapEquals(const std::shared_ptr<Buffer>& left, int64_t left_offs namespace { -template <template <typename> class BitOp> -void AlignedBitmapOp(const uint8_t* left, int64_t left_offset, const uint8_t* right, - int64_t right_offset, uint8_t* out, int64_t out_offset, - int64_t length) { +template <template <typename> class BitOp, bool ComputeNewValidityCount> +int64_t AlignedBitmapOp(const uint8_t* left, int64_t left_offset, const uint8_t* right, + int64_t right_offset, uint8_t* out, int64_t out_offset, + int64_t length) { BitOp<uint8_t> op; DCHECK_EQ(left_offset % 8, right_offset % 8); DCHECK_EQ(left_offset % 8, out_offset % 8); + uint8_t* outFront = out; const int64_t nbytes = BitUtil::BytesForBits(length + left_offset % 8); left += left_offset / 8; right += right_offset / 8; out += out_offset / 8; + uint64_t outPopCount = 0; for (int64_t i = 0; i < nbytes; ++i) { out[i] = op(left[i], right[i]); } + if (ComputeNewValidityCount) { + outPopCount = CountSetBits(outFront, out_offset, length); + } + return outPopCount; } -template <template <typename> class BitOp> -void UnalignedBitmapOp(const uint8_t* left, int64_t left_offset, const uint8_t* right, - int64_t right_offset, uint8_t* out, int64_t out_offset, - int64_t length) { +template <template <typename> class BitOp, bool ComputeNewValidityCount> Review comment: But your benchmark graph shows no difference from unaligned op, and this function is only for unaligned op, no? -- 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