polars_arrow/io/avro/
mod.rs

1//! Read and write from and to Apache Avro
2
3pub use avro_schema;
4
5pub mod read;
6pub mod write;
7
8// macros that can operate in sync and async code.
9macro_rules! avro_decode {
10    ($reader:ident $($_await:tt)*) => {
11        {
12            let mut i = 0u64;
13            let mut buf = [0u8; 1];
14            let mut j = 0;
15            loop {
16                if j > 9 {
17                    // if j * 7 > 64
18                    polars_error::polars_bail!(oos = "zigzag decoding failed - corrupt avro file")
19                }
20                $reader.read_exact(&mut buf[..])$($_await)*?;
21                i |= (u64::from(buf[0] & 0x7F)) << (j * 7);
22                if (buf[0] >> 7) == 0 {
23                    break;
24                } else {
25                    j += 1;
26                }
27            }
28
29            Ok(i)
30        }
31    }
32}
33
34pub(crate) use avro_decode;