Skip to content

Commit

Permalink
Remove number_of_rows from Column
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jefffrey committed Sep 28, 2024
1 parent 77f2c96 commit a0081f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
16 changes: 1 addition & 15 deletions src/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,14 @@ use crate::stripe::Stripe;

#[derive(Clone, Debug)]
pub struct Column {
number_of_rows: u64,
footer: Arc<StripeFooter>,
name: String,
data_type: DataType,
}

impl Column {
pub fn new(
name: &str,
data_type: &DataType,
footer: &Arc<StripeFooter>,
// 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<StripeFooter>) -> Self {
Self {
number_of_rows,
footer: footer.clone(),
data_type: data_type.clone(),
name: name.to_string(),
Expand Down Expand Up @@ -98,15 +89,13 @@ 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(),
})
.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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions src/stripe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit a0081f9

Please sign in to comment.