Search code examples
rustapache-arrow

How to append to existing apache arrow array


I can create an arrow array with a builder:

extern crate arrow;
use arrow::array::Int16Array;

// Create a new builder with a capacity of 100
let mut builder = Int16Array::builder(100);

// Append a slice of primitive values
builder.append_slice(&[2, 3, 4]).unwrap();

// Build the array
let finished_array = builder.finish();

But once I have finished building the array (thus called .finish), is there any option to create a new builder with the data offinished_array without copying the data into a new builder?

What I basically want is a cheap append operation.


Solution

  • After reading some more, I found out arrow arrays are alway immutable. An append operation to an array is not possible. If you want a zero copy append like behavior, you can write/ use a chunked array (this is not yet available in rust, but for instance is supported in pyarrow