Get batch values to fill the first incomplete byte of the output.
| 158 | |
| 159 | /// Get batch values to fill the first incomplete byte of the output. |
| 160 | [[nodiscard]] rle_size_t GetBatchInByte(BitmapSpanMut out, rle_size_t batch_size) { |
| 161 | const auto out_bit_offset = out.bit_start(); |
| 162 | ARROW_DCHECK_GE(out_bit_offset, 0); |
| 163 | ARROW_DCHECK_LT(out_bit_offset, 8); |
| 164 | ARROW_DCHECK_GT(remaining(), 0); |
| 165 | ARROW_DCHECK_GE(batch_size, 0); |
| 166 | |
| 167 | // Empty bits in first byte that we can fill |
| 168 | const auto empty_bits = rle_size_t{8} - out_bit_offset; |
| 169 | // Number of bits in first byte that we want to fill |
| 170 | const auto desired_bits = std::min(empty_bits, batch_size); |
| 171 | // Try to advance, and get number of bits we had remaining |
| 172 | const auto n_bits = Advance(desired_bits); |
| 173 | // Copy relevant bits from the value pattern to the output. |
| 174 | *out.data() = bit_util::CopyBitsInInteger<uint8_t, /* kAllowFullCopy= */ false>({ |
| 175 | .src = value_pattern_, |
| 176 | .dst = *out.data(), |
| 177 | .start = static_cast<uint8_t>(out_bit_offset), |
| 178 | .end = static_cast<uint8_t>(out_bit_offset + n_bits), |
| 179 | }); |
| 180 | |
| 181 | return n_bits; |
| 182 | } |
| 183 | |
| 184 | /// Get batch in full bytes using memset. |
| 185 | [[nodiscard]] rle_size_t GetBatchFullBytes(BitmapSpanMut out, rle_size_t batch_size) { |