//! APIs to read from and write to Arrow's IPC format.1//!2//! Inter-process communication is a method through which different processes3//! share and pass data between them. Its use-cases include parallel4//! processing of chunks of data across different CPU cores, transferring5//! data between different Apache Arrow implementations in other languages and6//! more. Under the hood Apache Arrow uses [FlatBuffers](https://google.github.io/flatbuffers/)7//! as its binary protocol, so every Arrow-centered streaming or serialiation8//! problem that could be solved using FlatBuffers could probably be solved9//! using the more integrated approach that is exposed in this module.10//!11//! [Arrow's IPC protocol](https://arrow.apache.org/docs/format/Columnar.html#serialization-and-interprocess-communication-ipc)12//! allows only batch or dictionary columns to be passed13//! around due to its reliance on a pre-defined data scheme. This constraint14//! provides a large performance gain because serialized data will always have a15//! known structutre, i.e. the same fields and datatypes, with the only variance16//! being the number of rows and the actual data inside the Batch. This dramatically17//! increases the deserialization rate, as the bytes in the file or stream are already18//! structured "correctly".19//!20//! Reading and writing IPC messages is done using one of two variants - either21//! [`FileReader`](read::FileReader) <-> [`FileWriter`](struct@write::FileWriter) or22//! [`StreamReader`](read::StreamReader) <-> [`StreamWriter`](struct@write::StreamWriter).23//! These two variants wrap a type `T` that implements [`Read`](std::io::Read), and in24//! the case of the `File` variant it also implements [`Seek`](std::io::Seek). In25//! practice it means that `File`s can be arbitrarily accessed while `Stream`s are only26//! read in certain order - the one they were written in (first in, first out).27mod compression;28mod endianness;2930pub mod append;31pub mod read;32pub mod write;33pub use arrow_format as format;3435const ARROW_MAGIC_V1: [u8; 4] = [b'F', b'E', b'A', b'1'];36const ARROW_MAGIC_V2: [u8; 6] = [b'A', b'R', b'R', b'O', b'W', b'1'];37pub(crate) const CONTINUATION_MARKER: [u8; 4] = [0xff; 4];3839/// Struct containing `dictionary_id` and nested `IpcField`, allowing users40/// to specify the dictionary ids of the IPC fields when writing to IPC.41#[derive(Debug, Clone, PartialEq, Default)]42pub struct IpcField {43/// optional children44pub fields: Vec<IpcField>,45/// dictionary id46pub dictionary_id: Option<i64>,47}4849impl IpcField {50/// Check (recursively) whether the [`IpcField`] contains a dictionary.51pub fn contains_dictionary(&self) -> bool {52self.dictionary_id.is_some() || self.fields.iter().any(|f| f.contains_dictionary())53}54}5556/// Struct containing fields and whether the file is written in little or big endian.57#[derive(Debug, Clone, PartialEq)]58pub struct IpcSchema {59/// The fields in the schema60pub fields: Vec<IpcField>,61/// Endianness of the file62pub is_little_endian: bool,63}646566