Skip to content

Commit

Permalink
[WIP] Fix clippy warnings from toolchain bump
Browse files Browse the repository at this point in the history
  • Loading branch information
mcheshkov committed Aug 26, 2024
1 parent 4d8ef58 commit 60529b5
Show file tree
Hide file tree
Showing 65 changed files with 251 additions and 274 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/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
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
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion 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
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
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion 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
4 changes: 2 additions & 2 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
59 changes: 27 additions & 32 deletions arrow/src/array/equal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,24 +641,22 @@ mod tests {

#[test]
fn test_list_equal() {
let a = create_list_array(&[Some(&[1, 2, 3]), Some(&[4, 5, 6])]);
let b = create_list_array(&[Some(&[1, 2, 3]), Some(&[4, 5, 6])]);
let a = create_list_array([Some(&[1, 2, 3]), Some(&[4, 5, 6])]);
let b = create_list_array([Some(&[1, 2, 3]), Some(&[4, 5, 6])]);
test_equal(&a, &b, true);

let b = create_list_array(&[Some(&[1, 2, 3]), Some(&[4, 5, 7])]);
let b = create_list_array([Some(&[1, 2, 3]), Some(&[4, 5, 7])]);
test_equal(&a, &b, false);
}

// Test the case where null_count > 0
#[test]
fn test_list_null() {
let a =
create_list_array(&[Some(&[1, 2]), None, None, Some(&[3, 4]), None, None]);
let b =
create_list_array(&[Some(&[1, 2]), None, None, Some(&[3, 4]), None, None]);
let a = create_list_array([Some(&[1, 2]), None, None, Some(&[3, 4]), None, None]);
let b = create_list_array([Some(&[1, 2]), None, None, Some(&[3, 4]), None, None]);
test_equal(&a, &b, true);

let b = create_list_array(&[
let b = create_list_array([
Some(&[1, 2]),
None,
Some(&[5, 6]),
Expand All @@ -668,8 +666,7 @@ mod tests {
]);
test_equal(&a, &b, false);

let b =
create_list_array(&[Some(&[1, 2]), None, None, Some(&[3, 5]), None, None]);
let b = create_list_array([Some(&[1, 2]), None, None, Some(&[3, 5]), None, None]);
test_equal(&a, &b, false);

// a list where the nullness of values is determined by the list's bitmap
Expand Down Expand Up @@ -711,10 +708,8 @@ mod tests {
// Test the case where offset != 0
#[test]
fn test_list_offsets() {
let a =
create_list_array(&[Some(&[1, 2]), None, None, Some(&[3, 4]), None, None]);
let b =
create_list_array(&[Some(&[1, 2]), None, None, Some(&[3, 5]), None, None]);
let a = create_list_array([Some(&[1, 2]), None, None, Some(&[3, 4]), None, None]);
let b = create_list_array([Some(&[1, 2]), None, None, Some(&[3, 5]), None, None]);

let a_slice = a.slice(0, 3);
let b_slice = b.slice(0, 3);
Expand Down Expand Up @@ -746,40 +741,40 @@ mod tests {

#[test]
fn test_fixed_size_binary_equal() {
let a = create_fixed_size_binary_array(&[Some(b"hello"), Some(b"world")]);
let b = create_fixed_size_binary_array(&[Some(b"hello"), Some(b"world")]);
let a = create_fixed_size_binary_array([Some(b"hello"), Some(b"world")]);
let b = create_fixed_size_binary_array([Some(b"hello"), Some(b"world")]);
test_equal(&a, &b, true);

let b = create_fixed_size_binary_array(&[Some(b"hello"), Some(b"arrow")]);
let b = create_fixed_size_binary_array([Some(b"hello"), Some(b"arrow")]);
test_equal(&a, &b, false);
}

// Test the case where null_count > 0
#[test]
fn test_fixed_size_binary_null() {
let a = create_fixed_size_binary_array(&[Some(b"hello"), None, Some(b"world")]);
let b = create_fixed_size_binary_array(&[Some(b"hello"), None, Some(b"world")]);
let a = create_fixed_size_binary_array([Some(b"hello"), None, Some(b"world")]);
let b = create_fixed_size_binary_array([Some(b"hello"), None, Some(b"world")]);
test_equal(&a, &b, true);

let b = create_fixed_size_binary_array(&[Some(b"hello"), Some(b"world"), None]);
let b = create_fixed_size_binary_array([Some(b"hello"), Some(b"world"), None]);
test_equal(&a, &b, false);

let b = create_fixed_size_binary_array(&[Some(b"hello"), None, Some(b"arrow")]);
let b = create_fixed_size_binary_array([Some(b"hello"), None, Some(b"arrow")]);
test_equal(&a, &b, false);
}

#[test]
fn test_fixed_size_binary_offsets() {
// Test the case where offset != 0
let a = create_fixed_size_binary_array(&[
let a = create_fixed_size_binary_array([
Some(b"hello"),
None,
None,
Some(b"world"),
None,
None,
]);
let b = create_fixed_size_binary_array(&[
let b = create_fixed_size_binary_array([
Some(b"hello"),
None,
None,
Expand Down Expand Up @@ -918,26 +913,26 @@ mod tests {

#[test]
fn test_fixed_size_list_equal() {
let a = create_fixed_size_list_array(&[Some(&[1, 2, 3]), Some(&[4, 5, 6])]);
let b = create_fixed_size_list_array(&[Some(&[1, 2, 3]), Some(&[4, 5, 6])]);
let a = create_fixed_size_list_array([Some(&[1, 2, 3]), Some(&[4, 5, 6])]);
let b = create_fixed_size_list_array([Some(&[1, 2, 3]), Some(&[4, 5, 6])]);
test_equal(&a, &b, true);

let b = create_fixed_size_list_array(&[Some(&[1, 2, 3]), Some(&[4, 5, 7])]);
let b = create_fixed_size_list_array([Some(&[1, 2, 3]), Some(&[4, 5, 7])]);
test_equal(&a, &b, false);
}

// Test the case where null_count > 0
#[test]
fn test_fixed_list_null() {
let a = create_fixed_size_list_array(&[
let a = create_fixed_size_list_array([
Some(&[1, 2, 3]),
None,
None,
Some(&[4, 5, 6]),
None,
None,
]);
let b = create_fixed_size_list_array(&[
let b = create_fixed_size_list_array([
Some(&[1, 2, 3]),
None,
None,
Expand All @@ -947,7 +942,7 @@ mod tests {
]);
test_equal(&a, &b, true);

let b = create_fixed_size_list_array(&[
let b = create_fixed_size_list_array([
Some(&[1, 2, 3]),
None,
Some(&[7, 8, 9]),
Expand All @@ -957,7 +952,7 @@ mod tests {
]);
test_equal(&a, &b, false);

let b = create_fixed_size_list_array(&[
let b = create_fixed_size_list_array([
Some(&[1, 2, 3]),
None,
None,
Expand All @@ -971,15 +966,15 @@ mod tests {
#[test]
fn test_fixed_list_offsets() {
// Test the case where offset != 0
let a = create_fixed_size_list_array(&[
let a = create_fixed_size_list_array([
Some(&[1, 2, 3]),
None,
None,
Some(&[4, 5, 6]),
None,
None,
]);
let b = create_fixed_size_list_array(&[
let b = create_fixed_size_list_array([
Some(&[1, 2, 3]),
None,
None,
Expand Down
12 changes: 6 additions & 6 deletions arrow/src/array/equal/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ pub(super) fn child_logical_null_buffer(
let array_offset = parent_data.offset();
let bitmap_len = bit_util::ceil(parent_len * len, 8);
let mut buffer = MutableBuffer::from_len_zeroed(bitmap_len);
let mut null_slice = buffer.as_slice_mut();
let null_slice = buffer.as_slice_mut();
(array_offset..parent_len + array_offset).for_each(|index| {
let start = index * len;
let end = start + len;
let mask = parent_bitmap.is_set(index);
(start..end).for_each(|child_index| {
if mask && self_null_bitmap.is_set(child_index) {
bit_util::set_bit(&mut null_slice, child_index);
bit_util::set_bit(null_slice, child_index);
}
});
});
Expand All @@ -151,12 +151,12 @@ pub(super) fn child_logical_null_buffer(
// slow path
let array_offset = parent_data.offset();
let mut buffer = MutableBuffer::new_null(parent_len);
let mut null_slice = buffer.as_slice_mut();
let null_slice = buffer.as_slice_mut();
(0..parent_len).for_each(|index| {
if parent_bitmap.is_set(index + array_offset)
&& self_null_bitmap.is_set(index + array_offset)
{
bit_util::set_bit(&mut null_slice, index);
bit_util::set_bit(null_slice, index);
}
});
Some(buffer.into())
Expand All @@ -182,7 +182,7 @@ fn logical_list_bitmap<OffsetSize: OffsetSizeTrait>(
let offset_start = offsets.first().unwrap().to_usize().unwrap();
let offset_len = offsets.get(parent_data.len()).unwrap().to_usize().unwrap();
let mut buffer = MutableBuffer::new_null(offset_len - offset_start);
let mut null_slice = buffer.as_slice_mut();
let null_slice = buffer.as_slice_mut();

offsets
.windows(2)
Expand All @@ -194,7 +194,7 @@ fn logical_list_bitmap<OffsetSize: OffsetSizeTrait>(
let mask = parent_bitmap.is_set(index);
(start..end).for_each(|child_index| {
if mask && child_bitmap.is_set(child_index) {
bit_util::set_bit(&mut null_slice, child_index - offset_start);
bit_util::set_bit(null_slice, child_index - offset_start);
}
});
});
Expand Down
Loading

0 comments on commit 60529b5

Please sign in to comment.