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/write/mod.rs
6940 views
1
//! APIs to write to Avro format.
2
use avro_schema::file::Block;
3
4
mod schema;
5
pub use schema::to_record;
6
mod serialize;
7
pub use serialize::{BoxSerializer, can_serialize, new_serializer};
8
9
/// consumes a set of [`BoxSerializer`] into an [`Block`].
10
/// # Panics
11
/// Panics iff the number of items in any of the serializers is not equal to the number of rows
12
/// declared in the `block`.
13
pub fn serialize(serializers: &mut [BoxSerializer], block: &mut Block) {
14
let Block {
15
data,
16
number_of_rows,
17
} = block;
18
19
data.clear(); // restart it
20
21
// _the_ transpose (columns -> rows)
22
for _ in 0..*number_of_rows {
23
for serializer in &mut *serializers {
24
let item_data = serializer.next().unwrap();
25
data.extend(item_data);
26
}
27
}
28
}
29
30