[
https://issues.apache.org/jira/browse/ARROW-764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16315435#comment-16315435
]
ASF GitHub Bot commented on ARROW-764:
--------------------------------------
wesm commented on a change in pull request #1422: ARROW-764: [C++] Improves
performance of CopyBitmap and adds benchmarks
URL: https://github.com/apache/arrow/pull/1422#discussion_r160057731
##########
File path: cpp/src/arrow/util/bit-util.cc
##########
@@ -109,9 +109,37 @@ Status CopyBitmap(MemoryPool* pool, const uint8_t* data,
int64_t offset, int64_t
std::shared_ptr<Buffer> buffer;
RETURN_NOT_OK(GetEmptyBitmap(pool, length, &buffer));
uint8_t* dest = buffer->mutable_data();
- for (int64_t i = 0; i < length; ++i) {
- BitUtil::SetBitTo(dest, i, BitUtil::GetBit(data, i + offset));
+
+ int64_t byte_offset = offset / 8;
+ int64_t bit_offset = offset % 8;
+ int64_t num_bytes = BitUtil::BytesForBits(length);
+ int64_t bits_to_zero = num_bytes * 8 - length;
+
+ if (bit_offset > 0) {
+ auto carry_mask = BitUtil::kBitmask[bit_offset] - 1U;
+ auto carry_shift = 8U - bit_offset;
+
+ auto carry = 0U;
+ if (BitUtil::BytesForBits(length + bit_offset) > num_bytes) {
+ carry = (data[byte_offset + num_bytes] & carry_mask) << carry_shift;
+ }
+
+ auto i = num_bytes - 1;
+ while (i + 1 > 0) {
+ auto cur_byte = data[byte_offset + i];
Review comment:
We should write down explicit types for these autos
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> [C++] Improve performance of CopyBitmap, add benchmarks
> -------------------------------------------------------
>
> Key: ARROW-764
> URL: https://issues.apache.org/jira/browse/ARROW-764
> Project: Apache Arrow
> Issue Type: Improvement
> Components: C++
> Reporter: Wes McKinney
> Assignee: Adam Seibert
> Labels: pull-request-available
> Fix For: 0.9.0
>
>
> This is follow up work after a discussion in the patch for ARROW-657
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)