Skip to content

Commit

Permalink
fix: Ensure footer test passes on big endian (#609)
Browse files Browse the repository at this point in the history
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 <bengilgit@gmail.com>
  • Loading branch information
paleolimbot and bkietz authored Sep 17, 2024
1 parent b3deaaf commit 8f2bfd0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/nanoarrow/ipc/decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1288,9 +1288,9 @@ ArrowErrorCode ArrowIpcDecoderDecodeFooter(struct ArrowIpcDecoder* decoder,
struct ArrowIpcFileBlock* record_batches =
(struct ArrowIpcFileBlock*)private_data->footer.record_batch_blocks.data;
for (int64_t i = 0; i < n; i++) {
record_batches[i].offset = blocks[i].offset;
record_batches[i].metadata_length = blocks[i].metaDataLength;
record_batches[i].body_length = blocks[i].bodyLength;
record_batches[i].offset = ns(Block_offset(blocks + i));
record_batches[i].metadata_length = ns(Block_metaDataLength(blocks + i));
record_batches[i].body_length = ns(Block_bodyLength(blocks + i));
}

decoder->footer = &private_data->footer;
Expand Down
7 changes: 7 additions & 0 deletions src/nanoarrow/ipc/decoder_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,13 @@ TEST_P(ArrowSchemaParameterizedTestFixture, NanoarrowIpcNanoarrowFooterRoundtrip
EXPECT_EQ(
ArrowIpcEncoderFinalizeBuffer(encoder.get(), /*encapsulate=*/false, buffer.get()),
NANOARROW_OK);

#ifdef __BIG_ENDIAN__
uint32_t footer_size_le = bswap32(static_cast<uint32_t>(buffer->size_bytes));
EXPECT_EQ(ArrowBufferAppendInt32(buffer.get(), footer_size_le), NANOARROW_OK);
#else
EXPECT_EQ(ArrowBufferAppendInt32(buffer.get(), buffer->size_bytes), NANOARROW_OK);
#endif
EXPECT_EQ(ArrowBufferAppendStringView(buffer.get(), "ARROW1"_asv), NANOARROW_OK);

struct ArrowBufferView buffer_view;
Expand All @@ -1005,6 +1011,7 @@ TEST_P(ArrowSchemaParameterizedTestFixture, NanoarrowIpcNanoarrowFooterRoundtrip
struct ArrowIpcFileBlock roundtripped_block;
memcpy(&roundtripped_block, decoder->footer->record_batch_blocks.data,
sizeof(roundtripped_block));

EXPECT_EQ(roundtripped_block.offset, dummy_block.offset);
EXPECT_EQ(roundtripped_block.metadata_length, dummy_block.metadata_length);
EXPECT_EQ(roundtripped_block.body_length, dummy_block.body_length);
Expand Down

0 comments on commit 8f2bfd0

Please sign in to comment.