AntoinePrv commented on code in PR #47896:
URL: https://github.com/apache/arrow/pull/47896#discussion_r2454213174
##########
cpp/src/arrow/util/bpacking_dispatch_internal.h:
##########
@@ -47,7 +49,113 @@ int unpack_full(const uint8_t* in, Uint* out, int
batch_size) {
out[k] = FromLittleEndian(SafeLoadAs<Uint>(in + (k * sizeof(Uint))));
}
}
- return batch_size;
+}
+
+/// Compute the maximum spread in bytes that a packed integer can cover.
+///
+/// This is assuming contiguous packed integer starting with the given bit
offset away
+/// from a byte boundary.
+/// This function is non-monotonic, for instance with zero offset, three bit
integers
+/// will be split on the first byte boundary (hence having a spread of two
bytes) while
+/// four bit integer will be well behaved and never spread over byte boundary
(hence
+/// having a spread of one).
+constexpr int PackedMaxSpreadBytes(int width, int bit_offset) {
+ int max = static_cast<int>(bit_util::BytesForBits(width));
+ int start = bit_offset;
+ do {
+ const int byte_start = start / 8;
+ const int byte_end = (start + width - 1) / 8; // inclusive end bit
+ const int spread = byte_end - byte_start + 1;
+ max = spread > max ? spread : max;
+ start += width;
+ } while (start % 8 != bit_offset);
Review Comment:
Indeed, though that function is never used at runtime, only compile time.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]