Skip to content

Commit

Permalink
Added end to end unit test which shows the problem is fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
HawaiianSpork committed Jan 23, 2025
1 parent 64ded99 commit 2c9d9ab
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions arrow-ipc/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2478,6 +2478,37 @@ mod tests {
ensure_roundtrip(Arc::new(ls.finish()));
}

#[test]
fn test_large_slice_string_list_of_lists() {
// The reason for the special test is to verify reencode_offsets which looks both at
// the starting offset and the data offset. So need a dataset where the starting_offset
// is zero but the data offset is not.
let mut ls = ListBuilder::new(ListBuilder::new(StringBuilder::new()));

for _ in 0..4000 {
ls.values().append(true);
ls.append(true)
}

let mut s = String::new();
for row_number in 0..4000 {
if row_number % 2 == 0 {
for list_element in 0..1000 {
s.clear();
use std::fmt::Write;
write!(&mut s, "value{row_number}-{list_element}").unwrap();
ls.values().values().append_value(&s);
}
ls.values().append(true);
ls.append(true)
} else {
ls.append(false); // null
}
}

ensure_roundtrip(Arc::new(ls.finish()));
}

/// Read/write a record batch to a File and Stream and ensure it is the same at the outout
fn ensure_roundtrip(array: ArrayRef) {
let num_rows = array.len();
Expand Down

0 comments on commit 2c9d9ab

Please sign in to comment.