From a0081f92f00eb1080c34b48b32ad45b55522f138 Mon Sep 17 00:00:00 2001 From: Jefffrey Date: Sat, 28 Sep 2024 22:30:13 +1000 Subject: [PATCH] Remove number_of_rows from Column The number of rows in the stripe that the column belongs to does not accurately represent the number of rows in that column. Consider nested types within compound types. --- src/column.rs | 16 +--------------- src/stripe.rs | 4 ++-- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/column.rs b/src/column.rs index f9078baa..3bb5433d 100644 --- a/src/column.rs +++ b/src/column.rs @@ -31,23 +31,14 @@ use crate::stripe::Stripe; #[derive(Clone, Debug)] pub struct Column { - number_of_rows: u64, footer: Arc, name: String, data_type: DataType, } impl Column { - pub fn new( - name: &str, - data_type: &DataType, - footer: &Arc, - // TODO: inaccurate to grab this from stripe; consider list types - // (inner list will have more values/rows than in actual stripe) - number_of_rows: u64, - ) -> Self { + pub fn new(name: &str, data_type: &DataType, footer: &Arc) -> Self { Self { - number_of_rows, footer: footer.clone(), data_type: data_type.clone(), name: name.to_string(), @@ -98,7 +89,6 @@ impl Column { DataType::Struct { children, .. } => children .iter() .map(|col| Column { - number_of_rows: self.number_of_rows, footer: self.footer.clone(), name: col.name().to_string(), data_type: col.data_type().clone(), @@ -106,7 +96,6 @@ impl Column { .collect(), DataType::List { child, .. } => { vec![Column { - number_of_rows: self.number_of_rows, footer: self.footer.clone(), name: "item".to_string(), data_type: *child.clone(), @@ -115,13 +104,11 @@ impl Column { DataType::Map { key, value, .. } => { vec![ Column { - number_of_rows: self.number_of_rows, footer: self.footer.clone(), name: "key".to_string(), data_type: *key.clone(), }, Column { - number_of_rows: self.number_of_rows, footer: self.footer.clone(), name: "value".to_string(), data_type: *value.clone(), @@ -134,7 +121,6 @@ impl Column { .iter() .enumerate() .map(|(index, data_type)| Column { - number_of_rows: self.number_of_rows, footer: self.footer.clone(), name: format!("{index}"), data_type: data_type.clone(), diff --git a/src/stripe.rs b/src/stripe.rs index 1aa0c00c..d43e9cee 100644 --- a/src/stripe.rs +++ b/src/stripe.rs @@ -142,7 +142,7 @@ impl Stripe { let columns = projected_data_type .children() .iter() - .map(|col| Column::new(col.name(), col.data_type(), &footer, info.number_of_rows())) + .map(|col| Column::new(col.name(), col.data_type(), &footer)) .collect(); let mut stream_map = HashMap::new(); @@ -195,7 +195,7 @@ impl Stripe { let columns = projected_data_type .children() .iter() - .map(|col| Column::new(col.name(), col.data_type(), &footer, info.number_of_rows())) + .map(|col| Column::new(col.name(), col.data_type(), &footer)) .collect(); let mut stream_map = HashMap::new();