Skip to content

Commit 8f2bfd0

Browse files
paleolimbotbkietz
andauthored
fix: Ensure footer test passes on big endian (#609)
This PR fixes the verification run failure for big endian, which is currently failing on the `NanoarrowIpcNanoarrowFooterRoundtrip` tests. Checked with: ```bash export NANOARROW_ARCH=s390x docker compose run --rm verify ``` --------- Co-authored-by: Benjamin Kietzman <[email protected]>
1 parent b3deaaf commit 8f2bfd0

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/nanoarrow/ipc/decoder.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1288,9 +1288,9 @@ ArrowErrorCode ArrowIpcDecoderDecodeFooter(struct ArrowIpcDecoder* decoder,
12881288
struct ArrowIpcFileBlock* record_batches =
12891289
(struct ArrowIpcFileBlock*)private_data->footer.record_batch_blocks.data;
12901290
for (int64_t i = 0; i < n; i++) {
1291-
record_batches[i].offset = blocks[i].offset;
1292-
record_batches[i].metadata_length = blocks[i].metaDataLength;
1293-
record_batches[i].body_length = blocks[i].bodyLength;
1291+
record_batches[i].offset = ns(Block_offset(blocks + i));
1292+
record_batches[i].metadata_length = ns(Block_metaDataLength(blocks + i));
1293+
record_batches[i].body_length = ns(Block_bodyLength(blocks + i));
12941294
}
12951295

12961296
decoder->footer = &private_data->footer;

src/nanoarrow/ipc/decoder_test.cc

+7
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,13 @@ TEST_P(ArrowSchemaParameterizedTestFixture, NanoarrowIpcNanoarrowFooterRoundtrip
984984
EXPECT_EQ(
985985
ArrowIpcEncoderFinalizeBuffer(encoder.get(), /*encapsulate=*/false, buffer.get()),
986986
NANOARROW_OK);
987+
988+
#ifdef __BIG_ENDIAN__
989+
uint32_t footer_size_le = bswap32(static_cast<uint32_t>(buffer->size_bytes));
990+
EXPECT_EQ(ArrowBufferAppendInt32(buffer.get(), footer_size_le), NANOARROW_OK);
991+
#else
987992
EXPECT_EQ(ArrowBufferAppendInt32(buffer.get(), buffer->size_bytes), NANOARROW_OK);
993+
#endif
988994
EXPECT_EQ(ArrowBufferAppendStringView(buffer.get(), "ARROW1"_asv), NANOARROW_OK);
989995

990996
struct ArrowBufferView buffer_view;
@@ -1005,6 +1011,7 @@ TEST_P(ArrowSchemaParameterizedTestFixture, NanoarrowIpcNanoarrowFooterRoundtrip
10051011
struct ArrowIpcFileBlock roundtripped_block;
10061012
memcpy(&roundtripped_block, decoder->footer->record_batch_blocks.data,
10071013
sizeof(roundtripped_block));
1014+
10081015
EXPECT_EQ(roundtripped_block.offset, dummy_block.offset);
10091016
EXPECT_EQ(roundtripped_block.metadata_length, dummy_block.metadata_length);
10101017
EXPECT_EQ(roundtripped_block.body_length, dummy_block.body_length);

0 commit comments

Comments
 (0)