Skip to content

Commit

Permalink
Fix clippy warnings from toolchain bump
Browse files Browse the repository at this point in the history
  • Loading branch information
mcheshkov committed Sep 5, 2024
1 parent d79db21 commit 55511da
Show file tree
Hide file tree
Showing 94 changed files with 519 additions and 583 deletions.
4 changes: 2 additions & 2 deletions arrow-flight/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn flight_data_from_arrow_batch(
let mut dictionary_tracker = writer::DictionaryTracker::new(false);

let (encoded_dictionaries, encoded_batch) = data_gen
.encoded_batch(batch, &mut dictionary_tracker, &options)
.encoded_batch(batch, &mut dictionary_tracker, options)
.expect("DictionaryTracker configured above to not error on replacement");

let flight_dictionaries = encoded_dictionaries.into_iter().map(Into::into).collect();
Expand Down Expand Up @@ -68,7 +68,7 @@ pub fn flight_data_to_arrow_batch(
&data.data_body,
batch,
schema,
&dictionaries_by_field,
dictionaries_by_field,
)
})?
}
Expand Down
8 changes: 4 additions & 4 deletions arrow/benches/aggregate_kernels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ use arrow::util::bench_util::*;
use arrow::{array::*, datatypes::Float32Type};

fn bench_sum(arr_a: &Float32Array) {
criterion::black_box(sum(&arr_a).unwrap());
criterion::black_box(sum(arr_a).unwrap());
}

fn bench_min(arr_a: &Float32Array) {
criterion::black_box(min(&arr_a).unwrap());
criterion::black_box(min(arr_a).unwrap());
}

fn bench_max(arr_a: &Float32Array) {
criterion::black_box(max(&arr_a).unwrap());
criterion::black_box(max(arr_a).unwrap());
}

fn bench_min_string(arr_a: &StringArray) {
criterion::black_box(min_string(&arr_a).unwrap());
criterion::black_box(min_string(arr_a).unwrap());
}

fn add_benchmark(c: &mut Criterion) {
Expand Down
8 changes: 4 additions & 4 deletions arrow/benches/arithmetic_kernels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,24 @@ fn bench_add(arr_a: &ArrayRef, arr_b: &ArrayRef) {
fn bench_subtract(arr_a: &ArrayRef, arr_b: &ArrayRef) {
let arr_a = arr_a.as_any().downcast_ref::<Float32Array>().unwrap();
let arr_b = arr_b.as_any().downcast_ref::<Float32Array>().unwrap();
criterion::black_box(subtract(&arr_a, &arr_b).unwrap());
criterion::black_box(subtract(arr_a, arr_b).unwrap());
}

fn bench_multiply(arr_a: &ArrayRef, arr_b: &ArrayRef) {
let arr_a = arr_a.as_any().downcast_ref::<Float32Array>().unwrap();
let arr_b = arr_b.as_any().downcast_ref::<Float32Array>().unwrap();
criterion::black_box(multiply(&arr_a, &arr_b).unwrap());
criterion::black_box(multiply(arr_a, arr_b).unwrap());
}

fn bench_divide(arr_a: &ArrayRef, arr_b: &ArrayRef) {
let arr_a = arr_a.as_any().downcast_ref::<Float32Array>().unwrap();
let arr_b = arr_b.as_any().downcast_ref::<Float32Array>().unwrap();
criterion::black_box(divide(&arr_a, &arr_b).unwrap());
criterion::black_box(divide(arr_a, arr_b).unwrap());
}

fn bench_divide_scalar(array: &ArrayRef, divisor: f32) {
let array = array.as_any().downcast_ref::<Float32Array>().unwrap();
criterion::black_box(divide_scalar(&array, divisor).unwrap());
criterion::black_box(divide_scalar(array, divisor).unwrap());
}

fn bench_limit(arr_a: &ArrayRef, max: usize) {
Expand Down
8 changes: 4 additions & 4 deletions arrow/benches/array_from_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,22 @@ fn criterion_benchmark(c: &mut Criterion) {

let (field1, strings, field2, ints) = struct_array_values(128);
c.bench_function("struct_array_from_vec 128", |b| {
b.iter(|| struct_array_from_vec(&field1, &strings, &field2, &ints))
b.iter(|| struct_array_from_vec(field1, &strings, field2, &ints))
});

let (field1, strings, field2, ints) = struct_array_values(256);
c.bench_function("struct_array_from_vec 256", |b| {
b.iter(|| struct_array_from_vec(&field1, &strings, &field2, &ints))
b.iter(|| struct_array_from_vec(field1, &strings, field2, &ints))
});

let (field1, strings, field2, ints) = struct_array_values(512);
c.bench_function("struct_array_from_vec 512", |b| {
b.iter(|| struct_array_from_vec(&field1, &strings, &field2, &ints))
b.iter(|| struct_array_from_vec(field1, &strings, field2, &ints))
});

let (field1, strings, field2, ints) = struct_array_values(1024);
c.bench_function("struct_array_from_vec 1024", |b| {
b.iter(|| struct_array_from_vec(&field1, &strings, &field2, &ints))
b.iter(|| struct_array_from_vec(field1, &strings, field2, &ints))
});
}

Expand Down
8 changes: 4 additions & 4 deletions arrow/benches/boolean_kernels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn bench_or(lhs: &BooleanArray, rhs: &BooleanArray) {
}

fn bench_not(array: &BooleanArray) {
criterion::black_box(boolean_kernels::not(&array).unwrap());
criterion::black_box(boolean_kernels::not(array).unwrap());
}

fn add_benchmark(c: &mut Criterion) {
Expand All @@ -58,12 +58,12 @@ fn add_benchmark(c: &mut Criterion) {
.unwrap();

c.bench_function("and_sliced", |b| {
b.iter(|| bench_and(&array1_slice, &array2_slice))
b.iter(|| bench_and(array1_slice, array2_slice))
});
c.bench_function("or_sliced", |b| {
b.iter(|| bench_or(&array1_slice, &array2_slice))
b.iter(|| bench_or(array1_slice, array2_slice))
});
c.bench_function("not_sliced", |b| b.iter(|| bench_not(&array1_slice)));
c.bench_function("not_sliced", |b| b.iter(|| bench_not(array1_slice)));
}

criterion_group!(benches, add_benchmark);
Expand Down
4 changes: 2 additions & 2 deletions arrow/benches/filter_kernels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ fn bench_filter(data_array: &dyn Array, filter_array: &BooleanArray) {
criterion::black_box(filter(data_array, filter_array).unwrap());
}

fn bench_built_filter<'a>(filter: &Filter<'a>, data: &impl Array) {
criterion::black_box(filter(&data.data()));
fn bench_built_filter(filter: &Filter<'_>, data: &impl Array) {
criterion::black_box(filter(data.data()));
}

fn add_benchmark(c: &mut Criterion) {
Expand Down
4 changes: 2 additions & 2 deletions arrow/benches/take_kernels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ fn create_random_index(size: usize, null_density: f32) -> UInt32Array {
}

fn bench_take(values: &dyn Array, indices: &UInt32Array) {
criterion::black_box(take(values, &indices, None).unwrap());
criterion::black_box(take(values, indices, None).unwrap());
}

fn bench_take_bounds_check(values: &dyn Array, indices: &UInt32Array) {
criterion::black_box(
take(values, &indices, Some(TakeOptions { check_bounds: true })).unwrap(),
take(values, indices, Some(TakeOptions { check_bounds: true })).unwrap(),
);
}

Expand Down
4 changes: 2 additions & 2 deletions arrow/src/array/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ where
writeln!(f, " null,")?;
} else {
write!(f, " ")?;
print_item(&array, i, f)?;
print_item(array, i, f)?;
writeln!(f, ",")?;
}
}
Expand All @@ -639,7 +639,7 @@ where
writeln!(f, " null,")?;
} else {
write!(f, " ")?;
print_item(&array, i, f)?;
print_item(array, i, f)?;
writeln!(f, ",")?;
}
}
Expand Down
6 changes: 3 additions & 3 deletions arrow/src/array/array_binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl<OffsetSize: BinaryOffsetSizeTrait> GenericBinaryArray<OffsetSize> {
impl<'a, T: BinaryOffsetSizeTrait> GenericBinaryArray<T> {
/// constructs a new iterator
pub fn iter(&'a self) -> GenericBinaryIter<'a, T> {
GenericBinaryIter::<'a, T>::new(&self)
GenericBinaryIter::<'a, T>::new(self)
}
}

Expand Down Expand Up @@ -1039,7 +1039,7 @@ mod tests {
.add_child_data(values_data)
.build();
let list_array = ListArray::from(array_data);
BinaryArray::from(list_array);
let _ = BinaryArray::from(list_array);
}

#[test]
Expand Down Expand Up @@ -1114,7 +1114,7 @@ mod tests {
.add_child_data(values_data)
.build();
let list_array = FixedSizeListArray::from(array_data);
FixedSizeBinaryArray::from(list_array);
let _ = FixedSizeBinaryArray::from(list_array);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions arrow/src/array/array_boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl<'a> IntoIterator for &'a BooleanArray {
impl<'a> BooleanArray {
/// constructs a new iterator
pub fn iter(&'a self) -> BooleanIter<'a> {
BooleanIter::<'a>::new(&self)
BooleanIter::<'a>::new(self)
}
}

Expand Down Expand Up @@ -296,6 +296,6 @@ mod tests {
(values buffer)")]
fn test_boolean_array_invalid_buffer_len() {
let data = ArrayData::builder(DataType::Boolean).len(5).build();
BooleanArray::from(data);
let _ = BooleanArray::from(data);
}
}
5 changes: 2 additions & 3 deletions arrow/src/array/array_dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub struct DictionaryArray<K: ArrowPrimitiveType> {
is_ordered: bool,
}

impl<'a, K: ArrowPrimitiveType> DictionaryArray<K> {
impl<K: ArrowPrimitiveType> DictionaryArray<K> {
/// Return an array view of the keys of this dictionary as a PrimitiveArray.
pub fn keys(&self) -> &PrimitiveArray<K> {
&self.keys
Expand All @@ -81,8 +81,7 @@ impl<'a, K: ArrowPrimitiveType> DictionaryArray<K> {

(0..rd_buf.len())
.position(|i| rd_buf.value(i) == value)
.map(K::Native::from_usize)
.flatten()
.and_then(K::Native::from_usize)
}

/// Returns a reference to the dictionary values array
Expand Down
14 changes: 7 additions & 7 deletions arrow/src/array/array_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl<OffsetSize: OffsetSizeTrait> GenericListArray<OffsetSize> {

/// constructs a new iterator
pub fn iter<'a>(&'a self) -> GenericListArrayIter<'a, OffsetSize> {
GenericListArrayIter::<'a, OffsetSize>::new(&self)
GenericListArrayIter::<'a, OffsetSize>::new(self)
}

#[inline]
Expand Down Expand Up @@ -752,7 +752,7 @@ mod tests {
.len(3)
.add_child_data(value_data)
.build();
FixedSizeListArray::from(list_data);
let _ = FixedSizeListArray::from(list_data);
}

#[test]
Expand Down Expand Up @@ -1022,7 +1022,7 @@ mod tests {
.len(3)
.add_child_data(value_data)
.build();
ListArray::from(list_data);
let _ = ListArray::from(list_data);
}

#[test]
Expand All @@ -1037,7 +1037,7 @@ mod tests {
.len(3)
.add_buffer(value_offsets)
.build();
ListArray::from(list_data);
let _ = ListArray::from(list_data);
}

#[test]
Expand All @@ -1057,7 +1057,7 @@ mod tests {
.add_buffer(value_offsets)
.add_child_data(value_data)
.build();
ListArray::from(list_data);
let _ = ListArray::from(list_data);
}

#[test]
Expand All @@ -1067,7 +1067,7 @@ mod tests {
let buf = unsafe { Buffer::from_raw_parts(ptr, 8, 8) };
let buf2 = buf.slice(1);
let array_data = ArrayData::builder(DataType::Int32).add_buffer(buf2).build();
Int32Array::from(array_data);
let _ = Int32Array::from(array_data);
}

#[test]
Expand All @@ -1088,6 +1088,6 @@ mod tests {
.add_buffer(buf2)
.add_child_data(value_data)
.build();
ListArray::from(list_data);
let _ = ListArray::from(list_data);
}
}
8 changes: 4 additions & 4 deletions arrow/src/array/array_primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl<'a, T: ArrowPrimitiveType> IntoIterator for &'a PrimitiveArray<T> {
impl<'a, T: ArrowPrimitiveType> PrimitiveArray<T> {
/// constructs a new iterator
pub fn iter(&'a self) -> PrimitiveIter<'a, T> {
PrimitiveIter::<'a, T>::new(&self)
PrimitiveIter::<'a, T>::new(self)
}
}

Expand Down Expand Up @@ -573,7 +573,7 @@ mod tests {
assert_eq!(3, arr.len());
assert_eq!(0, arr.offset());
assert_eq!(0, arr.null_count());
let formatted = vec!["00:00:00.001", "10:30:00.005", "23:59:59.210"];
let formatted = ["00:00:00.001", "10:30:00.005", "23:59:59.210"];
for (i, formatted) in formatted.iter().enumerate().take(3) {
// check that we can't create dates or datetimes from time instances
assert_eq!(None, arr.value_as_datetime(i));
Expand All @@ -597,7 +597,7 @@ mod tests {
assert_eq!(3, arr.len());
assert_eq!(0, arr.offset());
assert_eq!(0, arr.null_count());
let formatted = vec!["00:00:00.001", "10:30:00.005", "23:59:59.210"];
let formatted = ["00:00:00.001", "10:30:00.005", "23:59:59.210"];
for (i, item) in formatted.iter().enumerate().take(3) {
// check that we can't create dates or datetimes from time instances
assert_eq!(None, arr.value_as_datetime(i));
Expand Down Expand Up @@ -931,7 +931,7 @@ mod tests {
(values buffer)")]
fn test_primitive_array_invalid_buffer_len() {
let data = ArrayData::builder(DataType::Int32).len(5).build();
Int32Array::from(data);
let _ = Int32Array::from(data);
}

#[test]
Expand Down
8 changes: 4 additions & 4 deletions arrow/src/array/array_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl<OffsetSize: StringOffsetSizeTrait> GenericStringArray<OffsetSize> {
}
}

impl<'a, Ptr, OffsetSize: StringOffsetSizeTrait> FromIterator<Option<Ptr>>
impl<Ptr, OffsetSize: StringOffsetSizeTrait> FromIterator<Option<Ptr>>
for GenericStringArray<OffsetSize>
where
Ptr: AsRef<str>,
Expand Down Expand Up @@ -264,7 +264,7 @@ impl<'a, T: StringOffsetSizeTrait> IntoIterator for &'a GenericStringArray<T> {
impl<'a, T: StringOffsetSizeTrait> GenericStringArray<T> {
/// constructs a new iterator
pub fn iter(&'a self) -> GenericStringIter<'a, T> {
GenericStringIter::<'a, T>::new(&self)
GenericStringIter::<'a, T>::new(self)
}
}

Expand Down Expand Up @@ -401,7 +401,7 @@ mod tests {
#[should_panic(expected = "[Large]StringArray expects Datatype::[Large]Utf8")]
fn test_string_array_from_int() {
let array = LargeStringArray::from(vec!["a", "b"]);
StringArray::from(array.data().clone());
let _ = StringArray::from(array.data().clone());
}

#[test]
Expand Down Expand Up @@ -511,7 +511,7 @@ mod tests {

#[test]
fn test_string_array_from_iter_values() {
let data = vec!["hello", "hello2"];
let data = ["hello", "hello2"];
let array1 = StringArray::from_iter_values(data.iter());

assert_eq!(array1.value(0), "hello");
Expand Down
4 changes: 2 additions & 2 deletions arrow/src/array/array_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ mod tests {
expected = "the field data types must match the array data in a StructArray"
)]
fn test_struct_array_from_mismatched_types() {
StructArray::from(vec![
let _ = StructArray::from(vec![
(
Field::new("b", DataType::Int16, false),
Arc::new(BooleanArray::from(vec![false, false, true, true]))
Expand Down Expand Up @@ -486,7 +486,7 @@ mod tests {
expected = "all child arrays of a StructArray must have the same length"
)]
fn test_invalid_struct_child_array_lengths() {
StructArray::from(vec![
let _ = StructArray::from(vec![
(
Field::new("b", DataType::Float32, false),
Arc::new(Float32Array::from(vec![1.1])) as Arc<Array>,
Expand Down
2 changes: 1 addition & 1 deletion arrow/src/array/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ mod tests {
vec![Buffer::from_slice_ref(&[1i32, 2, 3, 4, 5])],
vec![],
);
let v = vec![0, 1, 2, 3];
let v = [0, 1, 2, 3];
let b1 = Buffer::from(&v[..]);
let arr_data = ArrayData::builder(DataType::Int32)
.len(20)
Expand Down
Loading

0 comments on commit 55511da

Please sign in to comment.