Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable clone_on_ref_ptr clippy lint on common #11384

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions datafusion/common-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Make cheap clones clear: https://github.com/apache/datafusion/issues/11143
#![deny(clippy::clone_on_ref_ptr)]

pub mod common;

Expand Down
12 changes: 6 additions & 6 deletions datafusion/common/src/dfschema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl DFSchema {
schema: &SchemaRef,
) -> Result<Self> {
let dfschema = Self {
inner: schema.clone(),
inner: Arc::clone(schema),
field_qualifiers: qualifiers,
functional_dependencies: FunctionalDependencies::empty(),
};
Expand Down Expand Up @@ -311,7 +311,7 @@ impl DFSchema {
};
if !duplicated_field {
// self.inner.fields.push(field.clone());
schema_builder.push(field.clone());
schema_builder.push(Arc::clone(field));
qualifiers.push(qualifier.cloned());
}
}
Expand Down Expand Up @@ -1276,23 +1276,23 @@ mod tests {
let arrow_schema_ref = Arc::new(arrow_schema.clone());

let df_schema = DFSchema {
inner: arrow_schema_ref.clone(),
inner: Arc::clone(&arrow_schema_ref),
field_qualifiers: vec![None; arrow_schema_ref.fields.len()],
functional_dependencies: FunctionalDependencies::empty(),
};
let df_schema_ref = Arc::new(df_schema.clone());

{
let arrow_schema = arrow_schema.clone();
let arrow_schema_ref = arrow_schema_ref.clone();
let arrow_schema_ref = Arc::clone(&arrow_schema_ref);

assert_eq!(df_schema, arrow_schema.to_dfschema().unwrap());
assert_eq!(df_schema, arrow_schema_ref.to_dfschema().unwrap());
}

{
let arrow_schema = arrow_schema.clone();
let arrow_schema_ref = arrow_schema_ref.clone();
let arrow_schema_ref = Arc::clone(&arrow_schema_ref);

assert_eq!(df_schema_ref, arrow_schema.to_dfschema_ref().unwrap());
assert_eq!(df_schema_ref, arrow_schema_ref.to_dfschema_ref().unwrap());
Expand Down Expand Up @@ -1322,7 +1322,7 @@ mod tests {
let schema = Arc::new(Schema::new(vec![a_field, b_field]));

let df_schema = DFSchema {
inner: schema.clone(),
inner: Arc::clone(&schema),
field_qualifiers: vec![None; schema.fields.len()],
functional_dependencies: FunctionalDependencies::empty(),
};
Expand Down
19 changes: 12 additions & 7 deletions datafusion/common/src/hash_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ fn hash_list_array<OffsetSize>(
where
OffsetSize: OffsetSizeTrait,
{
let values = array.values().clone();
let values = Arc::clone(array.values());
let offsets = array.value_offsets();
let nulls = array.nulls();
let mut values_hashes = vec![0u64; values.len()];
Expand Down Expand Up @@ -274,7 +274,7 @@ fn hash_fixed_list_array(
random_state: &RandomState,
hashes_buffer: &mut [u64],
) -> Result<()> {
let values = array.values().clone();
let values = Arc::clone(array.values());
let value_len = array.value_length();
let offset_size = value_len as usize / array.len();
let nulls = array.nulls();
Expand Down Expand Up @@ -622,19 +622,19 @@ mod tests {
vec![
(
Arc::new(Field::new("bool", DataType::Boolean, false)),
boolarr.clone() as ArrayRef,
Arc::clone(&boolarr) as ArrayRef,
),
(
Arc::new(Field::new("i32", DataType::Int32, false)),
i32arr.clone() as ArrayRef,
Arc::clone(&i32arr) as ArrayRef,
),
(
Arc::new(Field::new("i32", DataType::Int32, false)),
i32arr.clone() as ArrayRef,
Arc::clone(&i32arr) as ArrayRef,
),
(
Arc::new(Field::new("bool", DataType::Boolean, false)),
boolarr.clone() as ArrayRef,
Arc::clone(&boolarr) as ArrayRef,
),
],
Buffer::from(&[0b001011]),
Expand Down Expand Up @@ -710,7 +710,12 @@ mod tests {
let random_state = RandomState::with_seeds(0, 0, 0, 0);

let mut one_col_hashes = vec![0; strings1.len()];
create_hashes(&[dict_array.clone()], &random_state, &mut one_col_hashes).unwrap();
create_hashes(
&[Arc::clone(&dict_array) as ArrayRef],
&random_state,
&mut one_col_hashes,
)
.unwrap();

let mut two_col_hashes = vec![0; strings1.len()];
create_hashes(
Expand Down
2 changes: 2 additions & 0 deletions datafusion/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Make cheap clones clear: https://github.com/apache/datafusion/issues/11143
#![deny(clippy::clone_on_ref_ptr)]

mod column;
mod dfschema;
Expand Down
Loading
Loading