alamb commented on code in PR #6451:
URL: https://github.com/apache/arrow-rs/pull/6451#discussion_r1776089773
##########
parquet/src/arrow/arrow_reader/mod.rs:
##########
@@ -382,7 +381,7 @@ impl ArrowReaderMetadata {
/// `Self::metadata` is missing the page index, this function will attempt
/// to load the page index by making an object store request.
pub fn load<T: ChunkReader>(reader: &T, options: ArrowReaderOptions) ->
Result<Self> {
- let mut metadata = footer::parse_metadata(reader)?;
+ let mut metadata =
ParquetMetaDataReader::new().parse_and_finish(reader)?;
Review Comment:
So beautiful 👏
##########
parquet/src/file/footer.rs:
##########
@@ -51,34 +42,9 @@ use crate::schema::types::{self, SchemaDescriptor};
/// # See Also
/// [`decode_metadata`] for decoding the metadata from the bytes.
/// [`decode_footer`] for decoding the metadata length from the footer.
+#[deprecated(since = "53.1.0", note = "Use ParquetMetaDataReader")]
Review Comment:
👍
##########
parquet/src/file/footer.rs:
##########
@@ -123,137 +70,7 @@ pub fn decode_metadata(buf: &[u8]) ->
Result<ParquetMetaData> {
/// | len | 'PAR1' |
/// +-----+--------+
/// ```
+#[deprecated(since = "53.1.0", note = "Use
ParquetMetaDataReader::decode_footer")]
pub fn decode_footer(slice: &[u8; FOOTER_SIZE]) -> Result<usize> {
- // check this is indeed a parquet file
- if slice[4..] != PARQUET_MAGIC {
- return Err(general_err!("Invalid Parquet file. Corrupt footer"));
- }
-
- // get the metadata length from the footer
- let metadata_len = u32::from_le_bytes(slice[..4].try_into().unwrap());
- // u32 won't be larger than usize in most cases
- Ok(metadata_len as usize)
-}
-
-/// Parses column orders from Thrift definition.
-/// If no column orders are defined, returns `None`.
-fn parse_column_orders(
- t_column_orders: Option<Vec<TColumnOrder>>,
- schema_descr: &SchemaDescriptor,
-) -> Option<Vec<ColumnOrder>> {
- match t_column_orders {
- Some(orders) => {
- // Should always be the case
- assert_eq!(
- orders.len(),
- schema_descr.num_columns(),
- "Column order length mismatch"
- );
- let mut res = Vec::new();
- for (i, column) in schema_descr.columns().iter().enumerate() {
- match orders[i] {
- TColumnOrder::TYPEORDER(_) => {
- let sort_order = ColumnOrder::get_sort_order(
- column.logical_type(),
- column.converted_type(),
- column.physical_type(),
- );
- res.push(ColumnOrder::TYPE_DEFINED_ORDER(sort_order));
- }
- }
- }
- Some(res)
- }
- None => None,
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
- use bytes::Bytes;
-
- use crate::basic::SortOrder;
- use crate::basic::Type;
- use crate::format::TypeDefinedOrder;
- use crate::schema::types::Type as SchemaType;
-
- #[test]
- fn test_parse_metadata_size_smaller_than_footer() {
Review Comment:
I verified that these tests have already been ported to the reader module:
https://github.com/apache/arrow-rs/blob/6137e9121d0e859ce0abdb28cb31a23a037e11b5/parquet/src/file/metadata/reader.rs#L639-L654
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]