how can I create an Array from a set of raw values that is created elsewhere?
for example if i have
let offsets: &[i64] = [ 0, 5, 5, 10, 0, 0, 0, 0 ];
// "helloworld"
let values: &[u8] = [ 104, 101, 108, 108, 111, 119, 111, 114, 108, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
// "hello", null, "world"
let null_bitmap: &[u8] = [ 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
let utf8_array = // <how do i get from those values to a Utf8Array>
The desired outcome would be the equivalent of [Some("hello"), None, Some("world")]
For reference, this is how i would do it via arrow-rs
let array_data = ArrayData::builder(DataType::LargeUtf8)
.len(3)
.null_count(1)
.add_buffer(Buffer::from_slice_ref(offsets))
.add_buffer(Buffer::from_slice_ref(values))
.null_bit_buffer(Some(Buffer::from_slice_ref(null_bitmap)))
.build()
.unwrap();
let string_array = LargeStringArray::from(array_data);
I'm not sure what the representation of the data in those arrays is, exactly, but in
polars-arrowit looks like this: