XiaoHongbo-Hope commented on code in PR #116: URL: https://github.com/apache/paimon-rust/pull/116#discussion_r2912537457
########## crates/paimon/src/arrow/reader.rs: ########## @@ -0,0 +1,170 @@ +// 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::io::{FileIO, FileRead, FileStatus}; +use crate::table::ArrowRecordBatchStream; +use crate::{DataSplit, Error}; +use async_stream::try_stream; +use bytes::Bytes; +use futures::future::BoxFuture; +use futures::{StreamExt, TryFutureExt}; +use parquet::arrow::arrow_reader::ArrowReaderOptions; +use parquet::arrow::async_reader::{AsyncFileReader, MetadataFetch}; +use parquet::arrow::ParquetRecordBatchStreamBuilder; +use parquet::file::metadata::ParquetMetaData; +use parquet::file::metadata::ParquetMetaDataReader; +use std::ops::Range; +use std::sync::Arc; +use tokio::try_join; + +/// Builder to create ArrowReader +pub struct ArrowReaderBuilder { + batch_size: Option<usize>, + file_io: FileIO, +} + +impl ArrowReaderBuilder { + /// Create a new ArrowReaderBuilder + pub(crate) fn new(file_io: FileIO) -> Self { + ArrowReaderBuilder { + batch_size: None, + file_io, + } + } + + /// Build the ArrowReader. + pub fn build(self) -> ArrowReader { + ArrowReader { + batch_size: self.batch_size, + file_io: self.file_io, + } + } +} + +/// Reads data from Parquet files +#[derive(Clone)] +pub struct ArrowReader { + batch_size: Option<usize>, + file_io: FileIO, +} + +impl ArrowReader { + /// Take a stream of DataSplits and read every data file in each split. + /// Returns a stream of Arrow RecordBatches from all files. + pub fn read(self, data_splits: &[DataSplit]) -> crate::Result<ArrowRecordBatchStream> { + let file_io = self.file_io.clone(); + let batch_size = self.batch_size; + let paths_to_read: Vec<String> = data_splits + .iter() + .flat_map(|ds| ds.data_file_entries().map(|(p, _)| p)) + .map(|p| { + if !p.to_ascii_lowercase().ends_with(".parquet") { Review Comment: > Thanks for your very kind explanation. And thanks again for pointing out the issue in python side, I wiil check it. -- 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]
