arrow_ipc/
lib.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18//! Support for the [Arrow IPC Format]
19//!
20//! The Arrow IPC format defines how to read and write [`RecordBatch`]es to/from
21//! a file or stream of bytes. This format can be used to serialize and deserialize
22//! data to files and over the network.
23//!
24//! There are two variants of the IPC format:
25//! 1. [IPC Streaming Format]: Supports streaming data sources, implemented by
26//!    [StreamReader] and [StreamWriter]
27//!
28//! 2. [IPC File Format]: Supports random access, implemented by [FileReader] and
29//!    [FileWriter].
30//!
31//! See the [`reader`] and [`writer`] modules for more information.
32//!
33//! [Arrow IPC Format]: https://arrow.apache.org/docs/format/Columnar.html#serialization-and-interprocess-communication-ipc
34//! [IPC Streaming Format]: https://arrow.apache.org/docs/format/Columnar.html#ipc-streaming-format
35//! [StreamReader]: reader::StreamReader
36//! [StreamWriter]: writer::StreamWriter
37//! [IPC File Format]: https://arrow.apache.org/docs/format/Columnar.html#ipc-file-format
38//! [FileReader]: reader::FileReader
39//! [FileWriter]: writer::FileWriter
40
41#![warn(missing_docs)]
42pub mod convert;
43pub mod reader;
44pub mod writer;
45
46mod compression;
47
48#[allow(clippy::redundant_closure)]
49#[allow(clippy::needless_lifetimes)]
50#[allow(clippy::extra_unused_lifetimes)]
51#[allow(clippy::redundant_static_lifetimes)]
52#[allow(clippy::redundant_field_names)]
53#[allow(non_camel_case_types)]
54#[allow(missing_docs)] // Because this is autogenerated
55pub mod gen;
56
57pub use self::gen::File::*;
58pub use self::gen::Message::*;
59pub use self::gen::Schema::*;
60pub use self::gen::SparseTensor::*;
61pub use self::gen::Tensor::*;
62
63const ARROW_MAGIC: [u8; 6] = [b'A', b'R', b'R', b'O', b'W', b'1'];
64const CONTINUATION_MARKER: [u8; 4] = [0xff; 4];
65
66impl Endianness {
67    /// Returns true if the endianness of the source system matches the endianness of the target system.
68    pub fn equals_to_target_endianness(self) -> bool {
69        match self {
70            Self::Little => cfg!(target_endian = "little"),
71            Self::Big => cfg!(target_endian = "big"),
72            _ => false,
73        }
74    }
75}