Skip to main content

decode_arrow_ipc

Function decode_arrow_ipc 

Source
pub fn decode_arrow_ipc(ipc_buf: &[u8]) -> Result<DoraArray>
Expand description

Decode an Arrow IPC stream byte buffer back into ArrayData.

Expects the stream to contain exactly one record batch with a single column, as produced by encode_arrow_ipc (which writes a single batch whose one column is named "data"). The array is taken from that column by position; the column name is not inspected. Returns an error for an empty, truncated, multi-batch, or otherwise malformed stream, for a stream with trailing bytes after its end-of-stream marker, for a batch whose column count is not exactly one, and for any payload larger than 256 MB.

The trailing-byte rejection matches decode_arrow_ipc_zero_copy, so both decoders accept and reject exactly the same streams.

ยงExample

use dora_node_api::IntoArrow;
use dora_node_api::arrow_utils::{decode_arrow_ipc, encode_arrow_ipc};

let ipc = encode_arrow_ipc(&"hello".to_string().into_arrow())?;
let decoded = decode_arrow_ipc(&ipc)?;
let text: String = (&decoded).try_into()?;
assert_eq!(text, "hello");