Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-arrow/src/io/ipc/read/array/mod.rs
6940 views
1
mod primitive;
2
3
use std::collections::VecDeque;
4
5
pub use primitive::*;
6
mod boolean;
7
pub use boolean::*;
8
mod utf8;
9
pub use utf8::*;
10
mod binary;
11
pub use binary::*;
12
mod fixed_size_binary;
13
pub use fixed_size_binary::*;
14
mod list;
15
pub use list::*;
16
mod fixed_size_list;
17
pub use fixed_size_list::*;
18
mod struct_;
19
pub use struct_::*;
20
mod null;
21
pub use null::*;
22
mod dictionary;
23
pub use dictionary::*;
24
mod union;
25
pub use union::*;
26
mod binview;
27
mod map;
28
pub use binview::*;
29
pub use map::*;
30
use polars_error::{PolarsResult, *};
31
32
use super::{Compression, IpcBuffer, Node, OutOfSpecKind};
33
use crate::datatypes::ArrowDataType;
34
35
fn try_get_field_node<'a>(
36
field_nodes: &mut VecDeque<Node<'a>>,
37
dtype: &ArrowDataType,
38
) -> PolarsResult<Node<'a>> {
39
field_nodes.pop_front().ok_or_else(|| {
40
polars_err!(ComputeError: "IPC: unable to fetch the field for {:?}\n\nThe file or stream is corrupted.", dtype)
41
})
42
}
43
44
fn try_get_array_length(field_node: Node, limit: Option<usize>) -> PolarsResult<usize> {
45
let length: usize = field_node
46
.length()
47
.try_into()
48
.map_err(|_| polars_err!(oos = OutOfSpecKind::NegativeFooterLength))?;
49
Ok(limit.map(|limit| limit.min(length)).unwrap_or(length))
50
}
51
52