Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Sep 19, 2023
1 parent fedd4a8 commit 50ba7b5
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 27 deletions.
2 changes: 1 addition & 1 deletion crates/nano-arrow/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
Expand Down
1 change: 1 addition & 0 deletions crates/nano-arrow/src/array/primitive/fmt.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::redundant_closure_call)]
use std::fmt::{Debug, Formatter, Result, Write};

use super::PrimitiveArray;
Expand Down
1 change: 1 addition & 0 deletions crates/nano-arrow/src/compute/aggregate/min_max.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::redundant_closure_call)]
use multiversion::multiversion;

use crate::array::{Array, BinaryArray, BooleanArray, PrimitiveArray, Utf8Array};
Expand Down
4 changes: 0 additions & 4 deletions crates/nano-arrow/src/compute/comparison/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions crates/nano-arrow/src/ffi/mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub unsafe fn slice<T: NativeType>(slice: &[T]) -> PrimitiveArray<T> {
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
Expand Down Expand Up @@ -143,7 +143,7 @@ pub unsafe fn bitmap(data: &[u8], offset: usize, length: usize) -> Result<Boolea
let null_count = 0;
let validity = None;

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
Expand Down
3 changes: 2 additions & 1 deletion crates/nano-arrow/src/io/ipc/read/array/dictionary.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::{HashSet, VecDeque};
use std::collections::{VecDeque};
use ahash::HashSet;
use std::convert::TryInto;
use std::io::{Read, Seek};

Expand Down
2 changes: 1 addition & 1 deletion crates/nano-arrow/src/io/ipc/write/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub(crate) mod writer;
pub use common::{Compression, Record, WriteOptions};
pub use schema::schema_to_bytes;
pub use serialize::write;
pub(self) use serialize::write_dictionary;
use serialize::write_dictionary;
pub use stream::StreamWriter;
pub use writer::FileWriter;

Expand Down
4 changes: 2 additions & 2 deletions crates/nano-arrow/src/io/parquet/read/row_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub fn to_deserializer<'a>(
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();
Expand Down Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/nano-arrow/src/io/parquet/write/dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn serialize_keys_values<K: DictionaryKey>(
// 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());
Expand Down
9 changes: 1 addition & 8 deletions crates/nano-arrow/src/io/parquet/write/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -402,7 +402,6 @@ pub fn array_to_page_simple(
primitive::array_to_page_plain::<i32, i32>(&array, options, type_)
},
DataType::Interval(IntervalUnit::YearMonth) => {
let type_ = type_;
let array = array
.as_any()
.downcast_ref::<PrimitiveArray<i32>>()
Expand All @@ -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::<PrimitiveArray<days_ms>>()
Expand All @@ -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()))
Expand All @@ -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()
Expand Down Expand Up @@ -541,7 +537,6 @@ pub fn array_to_page_simple(
}
},
DataType::Decimal(precision, _) => {
let type_ = type_;
let precision = *precision;
let array = array
.as_any()
Expand Down Expand Up @@ -674,7 +669,6 @@ fn array_to_page_nested(
primitive::nested_array_to_page::<f64, f64>(array, options, type_, nested)
},
Decimal(precision, _) => {
let type_ = type_;
let precision = *precision;
let array = array
.as_any()
Expand Down Expand Up @@ -727,7 +721,6 @@ fn array_to_page_nested(
}
},
Decimal256(precision, _) => {
let type_ = type_;
let precision = *precision;
let array = array
.as_any()
Expand Down
4 changes: 2 additions & 2 deletions crates/nano-arrow/src/io/parquet/write/pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ pub fn array_to_columns<A: AsRef<dyn Array> + 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)
Expand Down
4 changes: 2 additions & 2 deletions crates/nano-arrow/src/io/parquet/write/row_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ pub fn row_group_iter<A: AsRef<dyn Array> + '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
Expand Down
1 change: 0 additions & 1 deletion crates/nano-arrow/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]
//
Expand Down
3 changes: 1 addition & 2 deletions crates/nano-arrow/src/scalar/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ impl<T: NativeType> PrimitiveScalar<T> {
#[inline]
pub fn new(data_type: DataType, value: Option<T>) -> 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::<T>(),
data_type
)))
.unwrap()
}
Self { value, data_type }
}
Expand Down

0 comments on commit 50ba7b5

Please sign in to comment.