Skip to content

Commit 4fc9374

Browse files
tustvoldzhangli20
authored and
zhangli20
committed
Fix FFI array offset handling (apache#5964)
1 parent 5a5a4af commit 4fc9374

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arrow/src/ffi.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,10 @@ impl<'a> ImportedArrowArray<'a> {
400400
(length + 1) * (bits / 8)
401401
}
402402
(DataType::Utf8, 2) | (DataType::Binary, 2) => {
403+
if self.array.is_empty() {
404+
return Ok(0);
405+
}
406+
403407
// the len of the data buffer (buffer 2) equals the last value of the offset buffer (buffer 1)
404408
let len = self.buffer_len(1, dt)?;
405409
// first buffer is the null buffer => add(1)
@@ -410,6 +414,10 @@ impl<'a> ImportedArrowArray<'a> {
410414
(unsafe { *offset_buffer.add(len / size_of::<i32>() - 1) }) as usize
411415
}
412416
(DataType::LargeUtf8, 2) | (DataType::LargeBinary, 2) => {
417+
if self.array.is_empty() {
418+
return Ok(0);
419+
}
420+
413421
// the len of the data buffer (buffer 2) equals the last value of the offset buffer (buffer 1)
414422
let len = self.buffer_len(1, dt)?;
415423
// first buffer is the null buffer => add(1)

0 commit comments

Comments
 (0)