From 88da5f1a4b1def6a24bc8df86003462f7290eae1 Mon Sep 17 00:00:00 2001 From: Michael Maletich Date: Wed, 27 Nov 2024 07:29:48 -0600 Subject: [PATCH] Avoid copying --- arrow-ipc/src/writer.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arrow-ipc/src/writer.rs b/arrow-ipc/src/writer.rs index a7ea2225323..9649851f279 100644 --- a/arrow-ipc/src/writer.rs +++ b/arrow-ipc/src/writer.rs @@ -1429,8 +1429,14 @@ fn reencode_offsets( let start_offset = offset_slice.first().unwrap(); let end_offset = offset_slice.last().unwrap(); - let offsets: Buffer = match start_offset.as_usize() { - 0 => Buffer::from_slice_ref(offset_slice), + let offsets = match start_offset.as_usize() { + 0 => { + let size = size_of::(); + offsets.slice_with_length( + data.offset() * size, + (data.offset() + data.len() + 1) * size, + ) + } _ => offset_slice.iter().map(|x| *x - *start_offset).collect(), };