Vishwanatha-HD commented on code in PR #48180:
URL: https://github.com/apache/arrow/pull/48180#discussion_r2599504808


##########
cpp/src/arrow/compute/util.cc:
##########
@@ -118,7 +124,22 @@ void bits_to_indexes_internal(int64_t hardware_flags, 
const int num_bits,
   // Optionally process the last partial word with masking out bits outside 
range
   if (tail) {
     const uint8_t* bits_tail = bits + (num_bits - tail) / 8;
+#if ARROW_LITTLE_ENDIAN
     uint64_t word = SafeLoadUpTo8Bytes(bits_tail, (tail + 7) / 8);
+#else
+    int tail_bytes = (tail + 7) / 8;
+    uint64_t word;
+    if (tail_bytes == 8) {
+      word = util::SafeLoad(reinterpret_cast<const uint64_t*>(bits_tail));
+    } else {
+      // For bit manipulation, always load into least significant bits
+      // to ensure compatibility with CountTrailingZeros on Big-endian systems
+      word = 0;
+      for (int i = 0; i < tail_bytes; ++i) {
+        word |= static_cast<uint64_t>(bits_tail[i]) << (8 * i);
+      }
+    }
+#endif

Review Comment:
   Hi @zanmato1984.. 
   I made the code changes as per your suggestion above.. but unfortunately, 
the testcase doesnt pass.. The thing is that its not just the "byteswap" that 
is required on the BE systems.. 
   
   ./debug/arrow-compute-row-test 
--gtest_filter=KeyCompare.CompareColumnsToRowsCuriousFSB
   Note: Google Test filter = KeyCompare.CompareColumnsToRowsCuriousFSB
   [==========] Running 1 test from 1 test suite.
   [----------] Global test environment set-up.
   [----------] 1 test from KeyCompare
   [ RUN      ] KeyCompare.CompareColumnsToRowsCuriousFSB
   arrow/cpp/src/arrow/compute/row/compare_test.cc:103: Failure
   Expected equality of these values:
     num_rows_no_match
       Which is: 7
     1
   
   [  FAILED  ] KeyCompare.CompareColumnsToRowsCuriousFSB (2 ms)
   [----------] 1 test from KeyCompare (2 ms total)
   
   [----------] Global test environment tear-down
   [==========] 1 test from 1 test suite ran. (18 ms total)
   [  PASSED  ] 0 tests.
   [  FAILED  ] 1 test, listed below:
   [  FAILED  ] KeyCompare.CompareColumnsToRowsCuriousFSB
   
    1 FAILED TEST



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