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/// Core functionality for writing Arrow arrays as Avro data
37///
38/// Implements the primary writer interface and record encoding logic.
39pub mod writer;
40
41/// Avro schema parsing and representation
42///
43/// Provides types for parsing and representing Avro schema definitions.
44pub mod schema;
45
46/// Compression codec implementations for Avro
47///
48/// Provides support for various compression algorithms used in Avro files,
49/// including Deflate, Snappy, and ZStandard.
50pub mod compression;
51
52/// Data type conversions between Avro and Arrow types
53///
54/// This module contains the necessary types and functions to convert between
55/// Avro data types and Arrow data types.
56pub mod codec;
57
58/// Extension trait for AvroField to add Utf8View support
59///
60/// This trait adds methods for working with Utf8View support to the AvroField struct.
61pub trait AvroFieldExt {
62    /// Returns a new field with Utf8View support enabled for string data
63    ///
64    /// This will convert any string data to use StringViewArray instead of StringArray.
65    fn with_utf8view(&self) -> Self;
66}
67
68impl AvroFieldExt for codec::AvroField {
69    fn with_utf8view(&self) -> Self {
70        codec::AvroField::with_utf8view(self)
71    }
72}
73
74#[cfg(test)]
75mod test_util {
76    pub fn arrow_test_data(path: &str) -> String {
77        match std::env::var("ARROW_TEST_DATA") {
78            Ok(dir) => format!("{dir}/{path}"),
79            Err(_) => format!("../testing/data/{path}"),
80        }
81    }
82}