This is an automated email from the ASF dual-hosted git repository.

paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 8f2bfd0a fix: Ensure footer test passes on big endian (#609)
8f2bfd0a is described below

commit 8f2bfd0aac9b16edf4de595f194394884b71ab4a
Author: Dewey Dunnington <[email protected]>
AuthorDate: Tue Sep 17 11:54:52 2024 -0500

    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]>
---
 src/nanoarrow/ipc/decoder.c       | 6 +++---
 src/nanoarrow/ipc/decoder_test.cc | 7 +++++++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/nanoarrow/ipc/decoder.c b/src/nanoarrow/ipc/decoder.c
index b48374f2..c6eb2d03 100644
--- a/src/nanoarrow/ipc/decoder.c
+++ b/src/nanoarrow/ipc/decoder.c
@@ -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;
diff --git a/src/nanoarrow/ipc/decoder_test.cc 
b/src/nanoarrow/ipc/decoder_test.cc
index 10ecf750..ffd8f7f2 100644
--- a/src/nanoarrow/ipc/decoder_test.cc
+++ b/src/nanoarrow/ipc/decoder_test.cc
@@ -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;
@@ -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);

Reply via email to