vortex_arrow/lib.rs
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4//! Apache Arrow interoperability for Vortex.
5//!
6//! This crate owns every conversion between Vortex and Arrow. The authoritative entry point is
7//! the [`ArrowSession`]: importing Arrow schemas, fields, and data types into Vortex
8//! ([`ArrowSession::from_arrow_schema`], [`ArrowSession::from_arrow_field`],
9//! [`ArrowSession::from_arrow_datatype`]), importing Arrow arrays and record batches
10//! ([`ArrowSession::from_arrow_array`], [`ArrowSession::from_arrow_record_batch`]),
11//! exporting Vortex dtypes to Arrow
12//! ([`ArrowSession::to_arrow_schema`], [`ArrowSession::to_arrow_field`],
13//! [`ArrowSession::to_arrow_datatype`]), and executing Vortex arrays into Arrow
14//! ([`ArrowSession::execute_arrow`] and the [`ArrowArrayExecutor`] convenience trait).
15//!
16//! The [`ArrowSession`] session variable is created lazily on first use of
17//! [`ArrowSessionExt::arrow`], so no explicit registration is required for plain conversions.
18//! To import extension types that have no Arrow plugin, register the session with [`initialize`]
19//! (see [`ArrowSession`]).
20
21use vortex_array::dtype::session::DTypeSessionExt;
22use vortex_session::VortexSession;
23
24pub mod convert;
25mod datum;
26pub mod dtype;
27mod executor;
28mod iter;
29mod null_buffer;
30mod options;
31mod run_end_import;
32mod scalar;
33mod session;
34#[cfg(test)]
35mod tests;
36
37pub use convert::IntoVortexArray;
38pub use convert::nulls;
39pub use datum::*;
40pub use executor::*;
41pub use iter::*;
42pub use null_buffer::to_arrow_null_buffer;
43pub use null_buffer::to_null_buffer;
44pub use options::*;
45pub use scalar::ToArrowDatum;
46pub use session::*;
47
48/// Register vortex-arrow's session extensions into `session`.
49///
50/// This eagerly registers the [`ArrowSession`], which is otherwise created lazily on first use.
51/// Only a session registered here can look up the extension types of `session` by their Vortex IDs.
52/// A session that is created lazily on first use cannot, so it imports an extension type without an
53/// Arrow plugin as plain storage.
54pub fn initialize(session: &VortexSession) {
55 session.register(ArrowSession::new(&session.dtypes()));
56}