@@ -365,6 +365,9 @@ inline bool BitReader::GetVlqInt(Int* v) {
365365 // In all case, we read a byte-aligned value, skipping remaining bits
366366 const uint8_t * data = NULLPTR;
367367 int max_size = 0 ;
368+ #if ARROW_LITTLE_ENDIAN
369+ // The data that we will pass to the LEB128 parser
370+ // In all case, we read a byte-aligned value, skipping remaining bits
368371
369372 // Number of bytes left in the buffered values, not including the current
370373 // byte (i.e., there may be an additional fraction of a byte).
@@ -381,6 +384,17 @@ inline bool BitReader::GetVlqInt(Int* v) {
381384 max_size = bytes_left ();
382385 data = buffer_ + (max_bytes_ - max_size);
383386 }
387+ #else
388+ // For VLQ reading, always read directly from buffer to avoid endianness issues
389+ // with buffered_values_ on big-endian systems like s390x
390+ // Calculate current position in buffer accounting for bit offset
391+ const int current_byte_offset = byte_offset_ + bit_util::BytesForBits (bit_offset_);
392+ const int bytes_left_in_buffer = max_bytes_ - current_byte_offset;
393+
394+ // Always read from buffer directly to avoid endianness issues
395+ data = buffer_ + current_byte_offset;
396+ max_size = bytes_left_in_buffer;
397+ #endif
384398
385399 const auto bytes_read = bit_util::ParseLeadingLEB128 (data, max_size, v);
386400 if (ARROW_PREDICT_FALSE (bytes_read == 0 )) {
0 commit comments