Skip to content

Commit

Permalink
Add descriptors to Fix Len binary (#54)
Browse files Browse the repository at this point in the history
Co-authored-by: thanhtm1 <[email protected]>
  • Loading branch information
potter420 and thanhtm1 authored Oct 2, 2021
1 parent e21196a commit e79e784
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/statistics/fixed_len_binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ use std::sync::Arc;
use parquet_format_async_temp::Statistics as ParquetStatistics;

use super::Statistics;
use crate::{
error::{ParquetError, Result},
schema::types::PhysicalType,
};
use crate::{error::{ParquetError, Result}, metadata::ColumnDescriptor, schema::types::PhysicalType};

#[derive(Debug, Clone, PartialEq)]
pub struct FixedLenStatistics {
pub descriptor: ColumnDescriptor,
pub null_count: Option<i64>,
pub distinct_count: Option<i64>,
pub max_value: Option<Vec<u8>>,
Expand All @@ -31,7 +29,7 @@ impl Statistics for FixedLenStatistics {
}
}

pub fn read(v: &ParquetStatistics, size: i32) -> Result<Arc<dyn Statistics>> {
pub fn read(v: &ParquetStatistics, size: i32, descriptor: ColumnDescriptor) -> Result<Arc<dyn Statistics>> {
if let Some(ref v) = v.max_value {
if v.len() != size as usize {
return Err(ParquetError::OutOfSpec(
Expand All @@ -48,6 +46,7 @@ pub fn read(v: &ParquetStatistics, size: i32) -> Result<Arc<dyn Statistics>> {
};

Ok(Arc::new(FixedLenStatistics {
descriptor,
null_count: v.null_count,
distinct_count: v.distinct_count,
max_value: v.max_value.clone().map(|mut x| {
Expand Down
2 changes: 1 addition & 1 deletion src/statistics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub fn deserialize_statistics(
PhysicalType::Float => primitive::read::<f32>(statistics, descriptor),
PhysicalType::Double => primitive::read::<f64>(statistics, descriptor),
PhysicalType::ByteArray => binary::read(statistics, descriptor),
PhysicalType::FixedLenByteArray(size) => fixed_len_binary::read(statistics, *size),
PhysicalType::FixedLenByteArray(size) => fixed_len_binary::read(statistics, *size, descriptor),
}
}

Expand Down

0 comments on commit e79e784

Please sign in to comment.