Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-arrow/src/io/avro/mod.rs
6939 views
1
//! Read and write from and to Apache Avro
2
3
pub use avro_schema;
4
5
pub mod read;
6
pub mod write;
7
8
// macros that can operate in sync and async code.
9
macro_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
34
pub(crate) use avro_decode;
35
36