Skip to content

Commit

Permalink
Add ParquetMetadataWriter allow ad-hoc encoding of ParquetMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangb committed Jul 31, 2024
1 parent eeccaca commit b07d057
Show file tree
Hide file tree
Showing 3 changed files with 492 additions and 99 deletions.
32 changes: 32 additions & 0 deletions parquet/src/file/page_index/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,38 @@ impl<T: ParquetValueType> NativeIndex<T> {
boundary_order: index.boundary_order,
})
}

pub(crate) fn to_thrift(&self) -> ColumnIndex {
let min_values = self
.indexes
.iter()
.map(|x| x.min_bytes().map(|x| x.to_vec()))
.collect::<Option<Vec<_>>>()
.unwrap_or_else(|| vec![vec![]; self.indexes.len()]);

let max_values = self
.indexes
.iter()
.map(|x| x.max_bytes().map(|x| x.to_vec()))
.collect::<Option<Vec<_>>>()
.unwrap_or_else(|| vec![vec![]; self.indexes.len()]);

let null_counts = self
.indexes
.iter()
.map(|x| x.null_count())
.collect::<Option<Vec<_>>>();

ColumnIndex::new(
self.indexes.iter().map(|x| x.min().is_none()).collect(),
min_values,
max_values,
self.boundary_order,
null_counts,
None,
None,
)
}
}

#[cfg(test)]
Expand Down
Loading

0 comments on commit b07d057

Please sign in to comment.