Skip to content

Commit 6af5c95

Browse files
authored
feat: Add new() constructor for CachedParquetFileReader (apache#18575)
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Closes apache#18145 ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> Allows constructing `CachedParquetFileReader::new()` manually, allowing users to create it with a custom object reader (inner) object. ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> Adds a simple constructor for `CachedParquetFileReader` ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Added a test ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> Yes, new constructor available <!-- If there are any breaking changes to public APIs, please add the `api change` label. -->
1 parent 8226ebf commit 6af5c95

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

datafusion/datasource-parquet/src/reader.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,14 @@ impl ParquetFileReaderFactory for CachedParquetFileReaderFactory {
208208
inner = inner.with_footer_size_hint(hint)
209209
};
210210

211-
Ok(Box::new(CachedParquetFileReader {
212-
store: Arc::clone(&self.store),
213-
inner,
211+
Ok(Box::new(CachedParquetFileReader::new(
214212
file_metrics,
213+
Arc::clone(&self.store),
214+
inner,
215215
partitioned_file,
216-
metadata_cache: Arc::clone(&self.metadata_cache),
216+
Arc::clone(&self.metadata_cache),
217217
metadata_size_hint,
218-
}))
218+
)))
219219
}
220220
}
221221

@@ -231,6 +231,26 @@ pub struct CachedParquetFileReader {
231231
metadata_size_hint: Option<usize>,
232232
}
233233

234+
impl CachedParquetFileReader {
235+
pub fn new(
236+
file_metrics: ParquetFileMetrics,
237+
store: Arc<dyn ObjectStore>,
238+
inner: ParquetObjectReader,
239+
partitioned_file: PartitionedFile,
240+
metadata_cache: Arc<dyn FileMetadataCache>,
241+
metadata_size_hint: Option<usize>,
242+
) -> Self {
243+
Self {
244+
file_metrics,
245+
store,
246+
inner,
247+
partitioned_file,
248+
metadata_cache,
249+
metadata_size_hint,
250+
}
251+
}
252+
}
253+
234254
impl AsyncFileReader for CachedParquetFileReader {
235255
fn get_bytes(
236256
&mut self,

0 commit comments

Comments
 (0)