Skip to content

Commit 5e8586a

Browse files
authored
Remove unnecessary Option from Int96 (#2471)
* Remove unnecessary Option from Int96 * Clippy
1 parent 4e4902f commit 5e8586a

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

parquet/src/data_type.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,27 @@ use crate::util::{
3636

3737
/// Rust representation for logical type INT96, value is backed by an array of `u32`.
3838
/// The type only takes 12 bytes, without extra padding.
39-
#[derive(Clone, Debug, PartialOrd, Default)]
39+
#[derive(Clone, Debug, PartialOrd, Default, PartialEq, Eq)]
4040
pub struct Int96 {
41-
value: Option<[u32; 3]>,
41+
value: [u32; 3],
4242
}
4343

4444
impl Int96 {
4545
/// Creates new INT96 type struct with no data set.
4646
pub fn new() -> Self {
47-
Self { value: None }
47+
Self { value: [0; 3] }
4848
}
4949

5050
/// Returns underlying data as slice of [`u32`].
5151
#[inline]
5252
pub fn data(&self) -> &[u32] {
53-
self.value
54-
.as_ref()
55-
.expect("set_data should have been called")
53+
&self.value
5654
}
5755

5856
/// Sets data for this INT96 type.
5957
#[inline]
6058
pub fn set_data(&mut self, elem0: u32, elem1: u32, elem2: u32) {
61-
self.value = Some([elem0, elem1, elem2]);
59+
self.value = [elem0, elem1, elem2];
6260
}
6361

6462
/// Converts this INT96 into an i64 representing the number of MILLISECONDS since Epoch
@@ -75,16 +73,6 @@ impl Int96 {
7573
}
7674
}
7775

78-
impl PartialEq for Int96 {
79-
fn eq(&self, other: &Int96) -> bool {
80-
match (&self.value, &other.value) {
81-
(Some(v1), Some(v2)) => v1 == v2,
82-
(None, None) => true,
83-
_ => false,
84-
}
85-
}
86-
}
87-
8876
impl From<Vec<u32>> for Int96 {
8977
fn from(buf: Vec<u32>) -> Self {
9078
assert_eq!(buf.len(), 3);

parquet/src/encodings/encoding/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ mod tests {
843843
run_test::<Int96Type>(
844844
-1,
845845
&[Int96::from(vec![1, 2, 3]), Int96::from(vec![2, 3, 4])],
846-
32,
846+
24,
847847
);
848848
run_test::<ByteArrayType>(
849849
-1,

0 commit comments

Comments
 (0)