This is an automated email from the ASF dual-hosted git repository.

tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new 5e8586a01 Remove unnecessary Option from Int96 (#2471)
5e8586a01 is described below

commit 5e8586a017a572283388b1c1ba98a802a243535c
Author: Raphael Taylor-Davies <[email protected]>
AuthorDate: Wed Aug 17 17:05:43 2022 +0100

    Remove unnecessary Option from Int96 (#2471)
    
    * Remove unnecessary Option from Int96
    
    * Clippy
---
 parquet/src/data_type.rs              | 22 +++++-----------------
 parquet/src/encodings/encoding/mod.rs |  2 +-
 2 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/parquet/src/data_type.rs b/parquet/src/data_type.rs
index 7870ca36a..469e75f4b 100644
--- a/parquet/src/data_type.rs
+++ b/parquet/src/data_type.rs
@@ -36,29 +36,27 @@ use crate::util::{
 
 /// Rust representation for logical type INT96, value is backed by an array of 
`u32`.
 /// The type only takes 12 bytes, without extra padding.
-#[derive(Clone, Debug, PartialOrd, Default)]
+#[derive(Clone, Debug, PartialOrd, Default, PartialEq, Eq)]
 pub struct Int96 {
-    value: Option<[u32; 3]>,
+    value: [u32; 3],
 }
 
 impl Int96 {
     /// Creates new INT96 type struct with no data set.
     pub fn new() -> Self {
-        Self { value: None }
+        Self { value: [0; 3] }
     }
 
     /// Returns underlying data as slice of [`u32`].
     #[inline]
     pub fn data(&self) -> &[u32] {
-        self.value
-            .as_ref()
-            .expect("set_data should have been called")
+        &self.value
     }
 
     /// Sets data for this INT96 type.
     #[inline]
     pub fn set_data(&mut self, elem0: u32, elem1: u32, elem2: u32) {
-        self.value = Some([elem0, elem1, elem2]);
+        self.value = [elem0, elem1, elem2];
     }
 
     /// Converts this INT96 into an i64 representing the number of 
MILLISECONDS since Epoch
@@ -75,16 +73,6 @@ impl Int96 {
     }
 }
 
-impl PartialEq for Int96 {
-    fn eq(&self, other: &Int96) -> bool {
-        match (&self.value, &other.value) {
-            (Some(v1), Some(v2)) => v1 == v2,
-            (None, None) => true,
-            _ => false,
-        }
-    }
-}
-
 impl From<Vec<u32>> for Int96 {
     fn from(buf: Vec<u32>) -> Self {
         assert_eq!(buf.len(), 3);
diff --git a/parquet/src/encodings/encoding/mod.rs 
b/parquet/src/encodings/encoding/mod.rs
index 050f1b9f8..5d833da7d 100644
--- a/parquet/src/encodings/encoding/mod.rs
+++ b/parquet/src/encodings/encoding/mod.rs
@@ -843,7 +843,7 @@ mod tests {
         run_test::<Int96Type>(
             -1,
             &[Int96::from(vec![1, 2, 3]), Int96::from(vec![2, 3, 4])],
-            32,
+            24,
         );
         run_test::<ByteArrayType>(
             -1,

Reply via email to