MCPcopy Create free account
hub / github.com/apache/arrow / ReverseBlockOffsets

Function ReverseBlockOffsets

cpp/src/arrow/util/bitmap_ops.cc:178–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178void ReverseBlockOffsets(const uint8_t* data, int64_t offset, int64_t length,
179 int64_t dest_offset, uint8_t* dest) {
180 int64_t num_bytes = bit_util::BytesForBits(offset % 8 + length);
181 // Shift by its byte offset
182 data += offset / 8;
183 dest += dest_offset / 8;
184
185 int64_t j_src = num_bytes - 1;
186 int64_t i_dest = 0;
187
188 while (length > 0) {
189 uint8_t right_trailing_bits_src = (length + offset) % 8;
190 right_trailing_bits_src = !right_trailing_bits_src ? 8 : right_trailing_bits_src;
191
192 uint8_t left_trailing_bits_dest = 8 - dest_offset % 8;
193 uint8_t left_trailing_mask_dest = 0xFF << (8 - left_trailing_bits_dest);
194 if (length <= 8 && (dest_offset % 8) + length < 8) {
195 uint8_t extra_bits = static_cast<uint8_t>(8 - ((dest_offset % 8) + length));
196 left_trailing_mask_dest <<= extra_bits;
197 left_trailing_mask_dest >>= extra_bits;
198 }
199
200 uint8_t right_reversed_block;
201 if (j_src == 0) {
202 right_reversed_block = static_cast<uint8_t>(
203 GetReversedBlock(data[0], data[0], right_trailing_bits_src));
204 } else {
205 right_reversed_block = static_cast<uint8_t>(
206 GetReversedBlock(data[j_src - 1], data[j_src], right_trailing_bits_src));
207 }
208
209 dest[i_dest] &= ~left_trailing_mask_dest;
210 dest[i_dest] |=
211 (right_reversed_block << (8 - left_trailing_bits_dest)) & left_trailing_mask_dest;
212
213 dest_offset += left_trailing_bits_dest;
214 length -= left_trailing_bits_dest;
215
216 if (left_trailing_bits_dest >= right_trailing_bits_src) j_src--;
217 i_dest++;
218 }
219}
220
221} // namespace
222

Callers 1

ReverseBitmapFunction · 0.85

Calls 2

BytesForBitsFunction · 0.85
GetReversedBlockFunction · 0.85

Tested by

no test coverage detected