Skip to content

Commit c0a142f

Browse files
GH-48177: [C++][Parquet] Fix arrow-bit-utility-test failure on s390x
1 parent 83a5a61 commit c0a142f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

cpp/src/arrow/util/bit_stream_utils_internal.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)