AntoinePrv commented on code in PR #47994:
URL: https://github.com/apache/arrow/pull/47994#discussion_r2783049368


##########
cpp/src/arrow/util/bpacking_dispatch_internal.h:
##########
@@ -188,297 +202,431 @@ void unpack_width(const uint8_t* in, UnpackedUInt* out, 
int batch_size, int bit_
       return unpack_full(in, out, batch_size);
     } else {
       using UnpackerForWidth = Unpacker<UnpackedUInt, kPackedBitWidth>;
+      // Number of values extracted by one iteration of the kernel
       constexpr auto kValuesUnpacked = UnpackerForWidth::kValuesUnpacked;
+      // Number of bytes read, but not necessarily unpacked, by one iteration 
of the
+      // kernel. This constant prevent reading past buffer end.
+      constexpr auto kBytesRead = UnpackerForWidth::kBytesRead;
+
+      if constexpr (kValuesUnpacked > 0) {
+        const uint8_t* in_last = in_end - kBytesRead;
+        // Running the optimized kernel for batch extraction
+        while ((batch_size >= kValuesUnpacked) && (in <= in_last)) {

Review Comment:
   Do you think it would change? All that code is header only so it all end up 
in the same compilation unit.



-- 
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]

Reply via email to