From 50ba7b53d4f528f94d0a3140117a3180c0ef6266 Mon Sep 17 00:00:00 2001 From: ritchie Date: Tue, 19 Sep 2023 08:26:43 +0200 Subject: [PATCH] clippy --- crates/nano-arrow/src/array/mod.rs | 2 +- crates/nano-arrow/src/array/primitive/fmt.rs | 1 + crates/nano-arrow/src/compute/aggregate/min_max.rs | 1 + crates/nano-arrow/src/compute/comparison/mod.rs | 4 ---- crates/nano-arrow/src/ffi/mmap.rs | 4 ++-- crates/nano-arrow/src/io/ipc/read/array/dictionary.rs | 3 ++- crates/nano-arrow/src/io/ipc/write/mod.rs | 2 +- crates/nano-arrow/src/io/parquet/read/row_group.rs | 4 ++-- crates/nano-arrow/src/io/parquet/write/dictionary.rs | 2 +- crates/nano-arrow/src/io/parquet/write/mod.rs | 9 +-------- crates/nano-arrow/src/io/parquet/write/pages.rs | 4 ++-- crates/nano-arrow/src/io/parquet/write/row_group.rs | 4 ++-- crates/nano-arrow/src/lib.rs | 1 - crates/nano-arrow/src/scalar/primitive.rs | 3 +-- 14 files changed, 17 insertions(+), 27 deletions(-) diff --git a/crates/nano-arrow/src/array/mod.rs b/crates/nano-arrow/src/array/mod.rs index b0b72f4ceb6f..601d48411536 100644 --- a/crates/nano-arrow/src/array/mod.rs +++ b/crates/nano-arrow/src/array/mod.rs @@ -23,7 +23,7 @@ use crate::bitmap::{Bitmap, MutableBitmap}; use crate::datatypes::DataType; use crate::error::Result; -pub(self) mod physical_binary; +pub mod physical_binary; /// A trait representing an immutable Arrow array. Arrow arrays are trait objects /// that are infallibly downcasted to concrete types according to the [`Array::data_type`]. diff --git a/crates/nano-arrow/src/array/primitive/fmt.rs b/crates/nano-arrow/src/array/primitive/fmt.rs index 37316d16f60f..3743a16a188e 100644 --- a/crates/nano-arrow/src/array/primitive/fmt.rs +++ b/crates/nano-arrow/src/array/primitive/fmt.rs @@ -1,3 +1,4 @@ +#![allow(clippy::redundant_closure_call)] use std::fmt::{Debug, Formatter, Result, Write}; use super::PrimitiveArray; diff --git a/crates/nano-arrow/src/compute/aggregate/min_max.rs b/crates/nano-arrow/src/compute/aggregate/min_max.rs index 7314fd3b71a5..e733c6657ccd 100644 --- a/crates/nano-arrow/src/compute/aggregate/min_max.rs +++ b/crates/nano-arrow/src/compute/aggregate/min_max.rs @@ -1,3 +1,4 @@ +#![allow(clippy::redundant_closure_call)] use multiversion::multiversion; use crate::array::{Array, BinaryArray, BooleanArray, PrimitiveArray, Utf8Array}; diff --git a/crates/nano-arrow/src/compute/comparison/mod.rs b/crates/nano-arrow/src/compute/comparison/mod.rs index d41bc5b7d420..97e2b373fa33 100644 --- a/crates/nano-arrow/src/compute/comparison/mod.rs +++ b/crates/nano-arrow/src/compute/comparison/mod.rs @@ -54,10 +54,6 @@ pub mod primitive; pub mod utf8; mod simd; -pub(crate) use primitive::{ - compare_values_op as primitive_compare_values_op, - compare_values_op_scalar as primitive_compare_values_op_scalar, -}; pub use simd::{Simd8, Simd8Lanes, Simd8PartialEq, Simd8PartialOrd}; use super::take::take_boolean; diff --git a/crates/nano-arrow/src/ffi/mmap.rs b/crates/nano-arrow/src/ffi/mmap.rs index 37ce4bb01791..03c1ac9aa30a 100644 --- a/crates/nano-arrow/src/ffi/mmap.rs +++ b/crates/nano-arrow/src/ffi/mmap.rs @@ -101,7 +101,7 @@ pub unsafe fn slice(slice: &[T]) -> PrimitiveArray { let validity = None; let data: &[u8] = bytemuck::cast_slice(slice); - let ptr = data.as_ptr() as *const u8; + let ptr = data.as_ptr(); let data = Arc::new(data); // safety: the underlying assumption of this function: the array will not be used @@ -143,7 +143,7 @@ pub unsafe fn bitmap(data: &[u8], offset: usize, length: usize) -> Result( let (columns, types) = if let Some(pages) = pages { let (columns, types): (Vec<_>, Vec<_>) = columns .into_iter() - .zip(pages.into_iter()) + .zip(pages) .map(|((column_meta, chunk), mut pages)| { // de-offset the start, since we read in chunks (and offset is from start of file) let mut meta: PageMetaData = column_meta.into(); @@ -285,7 +285,7 @@ pub fn read_columns_many<'a, R: Read + Seek>( } else { field_columns .into_iter() - .zip(fields.into_iter()) + .zip(fields) .map(|(columns, field)| to_deserializer(columns, field, num_rows, chunk_size, None)) .collect() } diff --git a/crates/nano-arrow/src/io/parquet/write/dictionary.rs b/crates/nano-arrow/src/io/parquet/write/dictionary.rs index c2e1ca8bff12..bf83055b64d4 100644 --- a/crates/nano-arrow/src/io/parquet/write/dictionary.rs +++ b/crates/nano-arrow/src/io/parquet/write/dictionary.rs @@ -43,7 +43,7 @@ fn serialize_keys_values( // discard indices whose values are null. let keys = keys .zip(validity.iter()) - .filter_map(|(key, is_valid)| is_valid.then(|| key)); + .filter(|&(_key, is_valid)| is_valid).map(|(key, _is_valid)| key); let num_bits = utils::get_bit_width(keys.clone().max().unwrap_or(0) as u64); let keys = utils::ExactSizedIter::new(keys, array.len() - validity.unset_bits()); diff --git a/crates/nano-arrow/src/io/parquet/write/mod.rs b/crates/nano-arrow/src/io/parquet/write/mod.rs index 4b1c178952fb..b74daea04d7e 100644 --- a/crates/nano-arrow/src/io/parquet/write/mod.rs +++ b/crates/nano-arrow/src/io/parquet/write/mod.rs @@ -93,7 +93,7 @@ pub fn slice_nested_leaf(nested: &[Nested]) -> (usize, usize) { out } -pub(self) fn decimal_length_from_precision(precision: usize) -> usize { +fn decimal_length_from_precision(precision: usize) -> usize { // digits = floor(log_10(2^(8*n - 1) - 1)) // ceil(digits) = log10(2^(8*n - 1) - 1) // 10^ceil(digits) = 2^(8*n - 1) - 1 @@ -402,7 +402,6 @@ pub fn array_to_page_simple( primitive::array_to_page_plain::(&array, options, type_) }, DataType::Interval(IntervalUnit::YearMonth) => { - let type_ = type_; let array = array .as_any() .downcast_ref::>() @@ -426,7 +425,6 @@ pub fn array_to_page_simple( fixed_len_bytes::array_to_page(&array, options, type_, statistics) }, DataType::Interval(IntervalUnit::DayTime) => { - let type_ = type_; let array = array .as_any() .downcast_ref::>() @@ -450,7 +448,6 @@ pub fn array_to_page_simple( fixed_len_bytes::array_to_page(&array, options, type_, statistics) }, DataType::FixedSizeBinary(_) => { - let type_ = type_; let array = array.as_any().downcast_ref().unwrap(); let statistics = if options.write_statistics { Some(fixed_len_bytes::build_statistics(array, type_.clone())) @@ -461,7 +458,6 @@ pub fn array_to_page_simple( fixed_len_bytes::array_to_page(array, options, type_, statistics) }, DataType::Decimal256(precision, _) => { - let type_ = type_; let precision = *precision; let array = array .as_any() @@ -541,7 +537,6 @@ pub fn array_to_page_simple( } }, DataType::Decimal(precision, _) => { - let type_ = type_; let precision = *precision; let array = array .as_any() @@ -674,7 +669,6 @@ fn array_to_page_nested( primitive::nested_array_to_page::(array, options, type_, nested) }, Decimal(precision, _) => { - let type_ = type_; let precision = *precision; let array = array .as_any() @@ -727,7 +721,6 @@ fn array_to_page_nested( } }, Decimal256(precision, _) => { - let type_ = type_; let precision = *precision; let array = array .as_any() diff --git a/crates/nano-arrow/src/io/parquet/write/pages.rs b/crates/nano-arrow/src/io/parquet/write/pages.rs index 427d84c07633..ce51bcdcda89 100644 --- a/crates/nano-arrow/src/io/parquet/write/pages.rs +++ b/crates/nano-arrow/src/io/parquet/write/pages.rs @@ -245,8 +245,8 @@ pub fn array_to_columns + Send + Sync>( values .iter() - .zip(nested.into_iter()) - .zip(types.into_iter()) + .zip(nested) + .zip(types) .zip(encoding.iter()) .map(|(((values, nested), type_), encoding)| { array_to_pages(*values, type_, &nested, options, *encoding) diff --git a/crates/nano-arrow/src/io/parquet/write/row_group.rs b/crates/nano-arrow/src/io/parquet/write/row_group.rs index f951346bb89d..d281b63cebda 100644 --- a/crates/nano-arrow/src/io/parquet/write/row_group.rs +++ b/crates/nano-arrow/src/io/parquet/write/row_group.rs @@ -30,8 +30,8 @@ pub fn row_group_iter + 'static + Send + Sync>( chunk .into_arrays() .into_iter() - .zip(fields.into_iter()) - .zip(encodings.into_iter()) + .zip(fields) + .zip(encodings) .flat_map(move |((array, type_), encoding)| { let encoded_columns = array_to_columns(array, type_, options, &encoding).unwrap(); encoded_columns diff --git a/crates/nano-arrow/src/lib.rs b/crates/nano-arrow/src/lib.rs index a774b513219e..a471066ba11a 100644 --- a/crates/nano-arrow/src/lib.rs +++ b/crates/nano-arrow/src/lib.rs @@ -1,5 +1,4 @@ #![doc = include_str!("doc/lib.md")] -#![deny(missing_docs)] // So that we have more control over what is `unsafe` inside an `unsafe` block #![allow(unused_unsafe)] // diff --git a/crates/nano-arrow/src/scalar/primitive.rs b/crates/nano-arrow/src/scalar/primitive.rs index 044b76281297..288d8ee2664e 100644 --- a/crates/nano-arrow/src/scalar/primitive.rs +++ b/crates/nano-arrow/src/scalar/primitive.rs @@ -16,12 +16,11 @@ impl PrimitiveScalar { #[inline] pub fn new(data_type: DataType, value: Option) -> Self { if !data_type.to_physical_type().eq_primitive(T::PRIMITIVE) { - Err(Error::InvalidArgumentError(format!( + panic!("{:?}", Error::InvalidArgumentError(format!( "Type {} does not support logical type {:?}", std::any::type_name::(), data_type ))) - .unwrap() } Self { value, data_type } }