Skip to content

Commit 8cf84ab

Browse files
committed
Minor: make it clearer that clone() is not slow
1 parent 1f35b03 commit 8cf84ab

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

datafusion/core/src/datasource/statistics.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ pub async fn get_statistics_with_limit(
9393
// counts across all the files in question. If any file does not
9494
// provide any information or provides an inexact value, we demote
9595
// the statistic precision to inexact.
96-
num_rows = add_row_stats(file_stats.num_rows.clone(), num_rows);
96+
num_rows = add_row_stats(&file_stats.num_rows, &num_rows);
9797

9898
total_byte_size =
99-
add_row_stats(file_stats.total_byte_size.clone(), total_byte_size);
99+
add_row_stats(&file_stats.total_byte_size, &total_byte_size);
100100

101101
for (file_col_stats, col_stats) in file_stats
102102
.column_statistics
@@ -110,8 +110,7 @@ pub async fn get_statistics_with_limit(
110110
distinct_count: _,
111111
} = file_col_stats;
112112

113-
col_stats.null_count =
114-
add_row_stats(file_nc.clone(), col_stats.null_count.clone());
113+
col_stats.null_count = add_row_stats(file_nc, &col_stats.null_count);
115114
set_max_if_greater(file_max, &mut col_stats.max_value);
116115
set_min_if_lesser(file_min, &mut col_stats.min_value)
117116
}
@@ -165,12 +164,12 @@ pub(crate) fn create_max_min_accs(
165164
}
166165

167166
fn add_row_stats(
168-
file_num_rows: Precision<usize>,
169-
num_rows: Precision<usize>,
167+
file_num_rows: &Precision<usize>,
168+
num_rows: &Precision<usize>,
170169
) -> Precision<usize> {
171170
match (file_num_rows, &num_rows) {
172-
(Precision::Absent, _) => num_rows.to_inexact(),
173-
(lhs, Precision::Absent) => lhs.to_inexact(),
171+
(Precision::Absent, _) => num_rows.clone().to_inexact(),
172+
(lhs, Precision::Absent) => lhs.clone().to_inexact(),
174173
(lhs, rhs) => lhs.add(rhs),
175174
}
176175
}

0 commit comments

Comments
 (0)