Allocate a buffer and concatenate bitmaps into it.
| 103 | |
| 104 | // Allocate a buffer and concatenate bitmaps into it. |
| 105 | Status ConcatenateBitmaps(const std::vector<Bitmap>& bitmaps, MemoryPool* pool, |
| 106 | std::shared_ptr<Buffer>* out) { |
| 107 | int64_t out_length = 0; |
| 108 | for (const auto& bitmap : bitmaps) { |
| 109 | if (internal::AddWithOverflow(out_length, bitmap.range.length, &out_length)) { |
| 110 | return Status::Invalid("Length overflow when concatenating arrays"); |
| 111 | } |
| 112 | } |
| 113 | ARROW_ASSIGN_OR_RAISE(*out, AllocateBitmap(out_length, pool)); |
| 114 | uint8_t* dst = (*out)->mutable_data(); |
| 115 | |
| 116 | int64_t bitmap_offset = 0; |
| 117 | for (auto bitmap : bitmaps) { |
| 118 | if (bitmap.AllSet()) { |
| 119 | bit_util::SetBitsTo(dst, bitmap_offset, bitmap.range.length, true); |
| 120 | } else { |
| 121 | internal::CopyBitmap(bitmap.data, bitmap.range.offset, bitmap.range.length, dst, |
| 122 | bitmap_offset); |
| 123 | } |
| 124 | bitmap_offset += bitmap.range.length; |
| 125 | } |
| 126 | |
| 127 | return Status::OK(); |
| 128 | } |
| 129 | |
| 130 | int64_t SumBufferSizesInBytes(const BufferVector& buffers) { |
| 131 | int64_t size = 0; |
no test coverage detected