This is an automated email from the ASF dual-hosted git repository.
mbrobbel pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new d0824767dd Minor: avoid an `Arc::clone` in CacheOptions for Parquet
PredicateCache (#8338)
d0824767dd is described below
commit d0824767dd4bcf581894b06b7388d60fafb70035
Author: Andrew Lamb <[email protected]>
AuthorDate: Sat Sep 13 02:00:44 2025 -0700
Minor: avoid an `Arc::clone` in CacheOptions for Parquet PredicateCache
(#8338)
# Which issue does this PR close?
# Rationale for this change
I found this while working on
https://github.com/apache/arrow-rs/pull/7997
Basically, the fact that the CacheOptionsBuilder had both owned and non
owned fields made it a bit akward to work with -- if it is going to be
zero copy (references) we pay the price of tracking lifetimes already.
We may as well just do so for the Arc as well
I don't expect this to make any measurable different in performance. I
am mostly treating it as a cleanup
# What changes are included in this PR?
Remove one Arc::clone
# Are these changes tested?
By existing CI
If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
# Are there any user-facing changes?
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
If there are any breaking changes to public APIs, please call them out.
---
parquet/src/arrow/array_reader/builder.rs | 8 ++++----
parquet/src/arrow/async_reader/mod.rs | 3 +--
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/parquet/src/arrow/array_reader/builder.rs
b/parquet/src/arrow/array_reader/builder.rs
index d5e36fbcb4..1ee7cc50ac 100644
--- a/parquet/src/arrow/array_reader/builder.rs
+++ b/parquet/src/arrow/array_reader/builder.rs
@@ -44,12 +44,12 @@ pub struct CacheOptionsBuilder<'a> {
/// Projection mask to apply to the cache
pub projection_mask: &'a ProjectionMask,
/// Cache to use for storing row groups
- pub cache: Arc<Mutex<RowGroupCache>>,
+ pub cache: &'a Arc<Mutex<RowGroupCache>>,
}
impl<'a> CacheOptionsBuilder<'a> {
/// create a new cache options builder
- pub fn new(projection_mask: &'a ProjectionMask, cache:
Arc<Mutex<RowGroupCache>>) -> Self {
+ pub fn new(projection_mask: &'a ProjectionMask, cache: &'a
Arc<Mutex<RowGroupCache>>) -> Self {
Self {
projection_mask,
cache,
@@ -79,7 +79,7 @@ impl<'a> CacheOptionsBuilder<'a> {
#[derive(Clone)]
pub struct CacheOptions<'a> {
pub projection_mask: &'a ProjectionMask,
- pub cache: Arc<Mutex<RowGroupCache>>,
+ pub cache: &'a Arc<Mutex<RowGroupCache>>,
pub role: CacheRole,
}
@@ -144,7 +144,7 @@ impl<'a> ArrayReaderBuilder<'a> {
if cache_options.projection_mask.leaf_included(col_idx) {
Ok(Some(Box::new(CachedArrayReader::new(
reader,
- Arc::clone(&cache_options.cache),
+ Arc::clone(cache_options.cache),
col_idx,
cache_options.role,
self.metrics.clone(), // cheap clone
diff --git a/parquet/src/arrow/async_reader/mod.rs
b/parquet/src/arrow/async_reader/mod.rs
index 8279f653de..33b03fbbca 100644
--- a/parquet/src/arrow/async_reader/mod.rs
+++ b/parquet/src/arrow/async_reader/mod.rs
@@ -619,8 +619,7 @@ where
metadata: self.metadata.as_ref(),
};
- let cache_options_builder =
- CacheOptionsBuilder::new(&cache_projection,
row_group_cache.clone());
+ let cache_options_builder =
CacheOptionsBuilder::new(&cache_projection, &row_group_cache);
let filter = self.filter.as_mut();
let mut plan_builder =
ReadPlanBuilder::new(batch_size).with_selection(selection);