vustef commented on code in PR #8715: URL: https://github.com/apache/arrow-rs/pull/8715#discussion_r2499219469
########## parquet/src/arrow/array_reader/row_number.rs: ########## @@ -0,0 +1,107 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use crate::arrow::array_reader::ArrayReader; +use crate::errors::{ParquetError, Result}; +use crate::file::metadata::{ParquetMetaData, RowGroupMetaData}; +use arrow_array::{ArrayRef, Int64Array}; +use arrow_schema::DataType; +use std::any::Any; +use std::collections::HashSet; +use std::sync::Arc; + +pub(crate) struct RowNumberReader { + buffered_row_numbers: Vec<i64>, + remaining_row_numbers: std::iter::Flatten<std::vec::IntoIter<std::ops::Range<i64>>>, +} + +impl RowNumberReader { + pub(crate) fn try_new<'a>( + parquet_metadata: &'a ParquetMetaData, + row_groups: impl Iterator<Item = &'a RowGroupMetaData>, + ) -> Result<Self> { + // Collect ordinals from the selected row groups + let selected_ordinals: HashSet<i16> = row_groups + .map(|rg| { + rg.ordinal().ok_or_else(|| { Review Comment: This may be the issue. Ordinals are optional fields in metadata. We could assign ordinals while deserializing metadata, but that doesn't seem like a safe thing to do - e.g. while we are iterating, some row groups might not have ordinals, while some others might have it - so we'd have to throw an error in this case. I'm curious about opinions on this. -- 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]
