arrow_avro/
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//! Convert data to / from the [Apache Arrow] memory format and [Apache Avro]
19//!
20//! [Apache Arrow]: https://arrow.apache.org
21//! [Apache Avro]: https://avro.apache.org/
22
23#![doc(
24    html_logo_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_white-bg.svg",
25    html_favicon_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_transparent-bg.svg"
26)]
27#![cfg_attr(docsrs, feature(doc_auto_cfg))]
28#![warn(missing_docs)]
29#![allow(unused)] // Temporary
30
31/// Core functionality for reading Avro data into Arrow arrays
32///
33/// Implements the primary reader interface and record decoding logic.
34pub mod reader;
35
36// Avro schema parsing and representation
37//
38// Provides types for parsing and representing Avro schema definitions.
39mod schema;
40
41/// Compression codec implementations for Avro
42///
43/// Provides support for various compression algorithms used in Avro files,
44/// including Deflate, Snappy, and ZStandard.
45pub mod compression;
46
47/// Data type conversions between Avro and Arrow types
48///
49/// This module contains the necessary types and functions to convert between
50/// Avro data types and Arrow data types.
51pub mod codec;
52
53pub use reader::ReadOptions;
54
55/// Extension trait for AvroField to add Utf8View support
56///
57/// This trait adds methods for working with Utf8View support to the AvroField struct.
58pub trait AvroFieldExt {
59    /// Returns a new field with Utf8View support enabled for string data
60    ///
61    /// This will convert any string data to use StringViewArray instead of StringArray.
62    fn with_utf8view(&self) -> Self;
63}
64
65impl AvroFieldExt for codec::AvroField {
66    fn with_utf8view(&self) -> Self {
67        codec::AvroField::with_utf8view(self)
68    }
69}
70
71#[cfg(test)]
72mod test_util {
73    pub fn arrow_test_data(path: &str) -> String {
74        match std::env::var("ARROW_TEST_DATA") {
75            Ok(dir) => format!("{dir}/{path}"),
76            Err(_) => format!("../testing/data/{path}"),
77        }
78    }
79}