Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jan 15, 2024
1 parent 1786148 commit a045820
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{
datatypes::DataType,
};

pub(self) mod physical_binary;
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
6 changes: 5 additions & 1 deletion src/array/primitive/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ macro_rules! dyn_primitive {
.as_any()
.downcast_ref::<PrimitiveArray<$ty>>()
.unwrap();
Box::new(move |f, index| write!(f, "{}", $expr(array.value(index))))
Box::new(move |f, index| {
#[allow(clippy::redundant_closure_call)]
let value = $expr(array.value(index));
write!(f, "{}", value)
})
}};
}

Expand Down
2 changes: 2 additions & 0 deletions src/compute/aggregate/min_max.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::redundant_closure_call)]

use crate::bitmap::utils::{BitChunkIterExact, BitChunksExact};
use crate::datatypes::{DataType, PhysicalType, PrimitiveType};
use crate::error::{Error, Result};
Expand Down
2 changes: 1 addition & 1 deletion src/compute/sort/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ where
let mut values = if options.nulls_first {
null_indices.into_iter().chain(values).collect::<Vec<I>>()
} else {
values.chain(null_indices.into_iter()).collect::<Vec<I>>()
values.chain(null_indices).collect::<Vec<I>>()
};

values.truncate(limit.unwrap_or(values.len()));
Expand Down
2 changes: 1 addition & 1 deletion src/compute/sort/row/interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ mod tests {
#[test]
fn test_intern_duplicates() {
// Unsorted with duplicates
let values = vec![0_u8, 1, 8, 4, 1, 0];
let values = [0_u8, 1, 8, 4, 1, 0];
let mut interner = OrderPreservingInterner::default();

let interned = interner.intern(values.iter().map(std::slice::from_ref).map(Some));
Expand Down
4 changes: 2 additions & 2 deletions src/ffi/mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,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 @@ -147,7 +147,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
2 changes: 1 addition & 1 deletion 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
14 changes: 8 additions & 6 deletions src/scalar/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ 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!(
"Type {} does not support logical type {:?}",
std::any::type_name::<T>(),
data_type
)))
.unwrap()
panic!(
"{:?}",
Error::InvalidArgumentError(format!(
"Type {} does not support logical type {:?}",
std::any::type_name::<T>(),
data_type
))
);
}
Self { value, data_type }
}
Expand Down
4 changes: 2 additions & 2 deletions tests/it/array/utf8/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn test_extend_values() {
fn test_extend() {
let mut array = MutableUtf8Array::<i32>::new();

array.extend([Some("hi"), None, Some("there"), None].into_iter());
array.extend([Some("hi"), None, Some("there"), None]);

let array: Utf8Array<i32> = array.into();

Expand All @@ -149,7 +149,7 @@ fn test_extend() {
fn as_arc() {
let mut array = MutableUtf8Array::<i32>::new();

array.extend([Some("hi"), None, Some("there"), None].into_iter());
array.extend([Some("hi"), None, Some("there"), None]);

assert_eq!(
Utf8Array::<i32>::from([Some("hi"), None, Some("there"), None]),
Expand Down
4 changes: 2 additions & 2 deletions tests/it/bitmap/utils/zip_validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ fn complete() {
fn slices() {
let a = Bitmap::from([true, false]);
let a = Some(a.iter());
let offsets = vec![0, 2, 3];
let values = vec![1, 2, 3];
let offsets = [0, 2, 3];
let values = [1, 2, 3];
let iter = offsets.windows(2).map(|x| {
let start = x[0];
let end = x[1];
Expand Down
2 changes: 1 addition & 1 deletion tests/it/compute/arithmetics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn consistency() {
Interval(IntervalUnit::MonthDayNano),
];

let cases = datatypes.clone().into_iter().zip(datatypes.into_iter());
let cases = datatypes.clone().into_iter().zip(datatypes);

cases.for_each(|(lhs, rhs)| {
let lhs_a = new_empty_array(lhs.clone());
Expand Down
8 changes: 4 additions & 4 deletions tests/it/io/csv/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ fn decimal_only_integer() -> Result<()> {

#[test]
fn boolean() -> Result<()> {
let input = vec!["true", "True", "False", "F", "t"];
let input = ["true", "True", "False", "F", "t"];
let input = input.join("\n");

let expected = BooleanArray::from(&[Some(true), Some(true), Some(false), None, None]);
Expand All @@ -392,7 +392,7 @@ fn boolean() -> Result<()> {

#[test]
fn float32() -> Result<()> {
let input = vec!["12.34", "12", "0.0", "inf", "-inf", "dd"];
let input = ["12.34", "12", "0.0", "inf", "-inf", "dd"];
let input = input.join("\n");

let expected = Float32Array::from(&[
Expand All @@ -411,7 +411,7 @@ fn float32() -> Result<()> {

#[test]
fn deserialize_binary() -> Result<()> {
let input = vec!["aa", "bb"];
let input = ["aa", "bb"];
let input = input.join("\n");

let expected = BinaryArray::<i32>::from([Some(b"aa"), Some(b"bb")]);
Expand All @@ -423,7 +423,7 @@ fn deserialize_binary() -> Result<()> {

#[test]
fn deserialize_timestamp() -> Result<()> {
let input = vec!["1996-12-19T16:34:57-02:00", "1996-12-19T16:34:58-02:00"];
let input = ["1996-12-19T16:34:57-02:00", "1996-12-19T16:34:58-02:00"];
let input = input.join("\n");

let data_type = DataType::Timestamp(TimeUnit::Millisecond, Some("-01:00".to_string()));
Expand Down

0 comments on commit a045820

Please sign in to comment.