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/error.rs
6940 views
1
use std::fmt::{Display, Formatter};
2
3
/// The different types of errors that reading from IPC can cause
4
#[derive(Debug)]
5
#[non_exhaustive]
6
pub enum OutOfSpecKind {
7
/// The IPC file does not start with [b'A', b'R', b'R', b'O', b'W', b'1']
8
InvalidHeader,
9
/// The IPC file does not end with [b'A', b'R', b'R', b'O', b'W', b'1']
10
InvalidFooter,
11
/// The first 4 bytes of the last 10 bytes is < 0
12
NegativeFooterLength,
13
/// The footer is an invalid flatbuffer
14
InvalidFlatbufferFooter(arrow_format::ipc::planus::Error),
15
/// The file's footer does not contain record batches
16
MissingRecordBatches,
17
/// The footer's record batches is an invalid flatbuffer
18
InvalidFlatbufferRecordBatches(arrow_format::ipc::planus::Error),
19
/// The file's footer does not contain a schema
20
MissingSchema,
21
/// The footer's schema is an invalid flatbuffer
22
InvalidFlatbufferSchema(arrow_format::ipc::planus::Error),
23
/// The file's schema does not contain fields
24
MissingFields,
25
/// The footer's dictionaries is an invalid flatbuffer
26
InvalidFlatbufferDictionaries(arrow_format::ipc::planus::Error),
27
/// The block is an invalid flatbuffer
28
InvalidFlatbufferBlock(arrow_format::ipc::planus::Error),
29
/// The dictionary message is an invalid flatbuffer
30
InvalidFlatbufferMessage(arrow_format::ipc::planus::Error),
31
/// The message does not contain a header
32
MissingMessageHeader,
33
/// The message's header is an invalid flatbuffer
34
InvalidFlatbufferHeader(arrow_format::ipc::planus::Error),
35
/// Relative positions in the file is < 0
36
UnexpectedNegativeInteger,
37
/// dictionaries can only contain dictionary messages; record batches can only contain records
38
UnexpectedMessageType,
39
/// RecordBatch messages do not contain buffers
40
MissingMessageBuffers,
41
/// The message's buffers is an invalid flatbuffer
42
InvalidFlatbufferBuffers(arrow_format::ipc::planus::Error),
43
/// RecordBatch messages does not contain nodes
44
MissingMessageNodes,
45
/// The message's nodes is an invalid flatbuffer
46
InvalidFlatbufferNodes(arrow_format::ipc::planus::Error),
47
/// The message's body length is an invalid flatbuffer
48
InvalidFlatbufferBodyLength(arrow_format::ipc::planus::Error),
49
/// The message does not contain data
50
MissingData,
51
/// The message's data is an invalid flatbuffer
52
InvalidFlatbufferData(arrow_format::ipc::planus::Error),
53
/// The version is an invalid flatbuffer
54
InvalidFlatbufferVersion(arrow_format::ipc::planus::Error),
55
/// The compression is an invalid flatbuffer
56
InvalidFlatbufferCompression(arrow_format::ipc::planus::Error),
57
/// The record contains a number of buffers that does not match the required number by the data type
58
ExpectedBuffer,
59
/// A buffer's size is smaller than the required for the number of elements
60
InvalidBuffer {
61
/// Declared number of elements in the buffer
62
length: usize,
63
/// The name of the `NativeType`
64
type_name: &'static str,
65
/// Bytes required for the `length` and `type`
66
required_number_of_bytes: usize,
67
/// The size of the IPC buffer
68
buffer_length: usize,
69
},
70
/// A buffer's size is larger than the file size
71
InvalidBuffersLength {
72
/// number of bytes of all buffers in the record
73
buffers_size: u64,
74
/// the size of the file
75
file_size: u64,
76
},
77
/// A bitmap's size is smaller than the required for the number of elements
78
InvalidBitmap {
79
/// Declared length of the bitmap
80
length: usize,
81
/// Number of bits on the IPC buffer
82
number_of_bits: usize,
83
},
84
/// The dictionary is_delta is an invalid flatbuffer
85
InvalidFlatbufferIsDelta(arrow_format::ipc::planus::Error),
86
/// The dictionary id is an invalid flatbuffer
87
InvalidFlatbufferId(arrow_format::ipc::planus::Error),
88
/// Invalid dictionary id
89
InvalidId {
90
/// The requested dictionary id
91
requested_id: i64,
92
},
93
/// Field id is not a dictionary
94
InvalidIdDataType {
95
/// The requested dictionary id
96
requested_id: i64,
97
},
98
/// FixedSizeBinaryArray has invalid datatype.
99
InvalidDataType,
100
}
101
102
impl Display for OutOfSpecKind {
103
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
104
write!(f, "{self:?}")
105
}
106
}
107
108