Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Fixed clippy from 1.53 (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao authored Jul 23, 2021
1 parent 8d7d08f commit 16c089e
Show file tree
Hide file tree
Showing 47 changed files with 192 additions and 208 deletions.
2 changes: 1 addition & 1 deletion benches/take_kernels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn create_random_index(size: usize, null_density: f32) -> PrimitiveArray<i32> {
}

fn bench_take(values: &dyn Array, indices: &PrimitiveArray<i32>) {
criterion::black_box(take::take(values, &indices).unwrap());
criterion::black_box(take::take(values, indices).unwrap());
}

fn add_benchmark(c: &mut Criterion) {
Expand Down
2 changes: 1 addition & 1 deletion examples/csv_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn main() -> Result<()> {

let file_path = &args[1];

let batch = read_path(&file_path, None)?;
let batch = read_path(file_path, None)?;
println!("{:?}", batch);
Ok(())
}
2 changes: 1 addition & 1 deletion examples/parquet_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn main() -> Result<()> {
let column = args[2].parse::<usize>().unwrap();
let row_group = args[3].parse::<usize>().unwrap();

let array = read_column_chunk(&file_path, row_group, column)?;
let array = read_column_chunk(file_path, row_group, column)?;
println!("{}", array);
Ok(())
}
6 changes: 3 additions & 3 deletions src/array/binary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ mod tests {
array.validity(),
&Some(Bitmap::from_u8_slice(&[0b00000101], 3))
);
assert_eq!(array.is_valid(0), true);
assert_eq!(array.is_valid(1), false);
assert_eq!(array.is_valid(2), true);
assert!(array.is_valid(0));
assert!(!array.is_valid(1));
assert!(array.is_valid(2));

let array2 = BinaryArray::<i32>::from_data(
array.offsets().clone(),
Expand Down
16 changes: 8 additions & 8 deletions src/array/boolean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,24 +141,24 @@ mod tests {

let array: BooleanArray = data.into_iter().collect();

assert_eq!(array.value(0), true);
assert_eq!(array.value(1), false);
assert_eq!(array.value(2), false);
assert!(array.value(0));
assert!(!array.value(1));
assert!(!array.value(2));
assert_eq!(array.values(), &Bitmap::from_u8_slice(&[0b00000001], 3));
assert_eq!(
array.validity(),
&Some(Bitmap::from_u8_slice(&[0b00000101], 3))
);
assert_eq!(array.is_valid(0), true);
assert_eq!(array.is_valid(1), false);
assert_eq!(array.is_valid(2), true);
assert!(array.is_valid(0));
assert!(!array.is_valid(1));
assert!(array.is_valid(2));

let array2 = BooleanArray::from_data(array.values().clone(), array.validity().clone());
assert_eq!(array, array2);

let array = array.slice(1, 2);
assert_eq!(array.value(0), false);
assert_eq!(array.value(1), false);
assert!(!array.value(0));
assert!(!array.value(1));
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/array/equal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ mod tests {

pub(super) fn test_equal(lhs: &dyn Array, rhs: &dyn Array, expected: bool) {
// equality is symmetric
assert_eq!(equal(lhs, lhs), true, "\n{:?}\n{:?}", lhs, lhs);
assert_eq!(equal(rhs, rhs), true, "\n{:?}\n{:?}", rhs, rhs);
assert!(equal(lhs, lhs), "\n{:?}\n{:?}", lhs, lhs);
assert!(equal(rhs, rhs), "\n{:?}\n{:?}", rhs, rhs);

assert_eq!(equal(lhs, rhs), expected, "\n{:?}\n{:?}", lhs, rhs);
assert_eq!(equal(rhs, lhs), expected, "\n{:?}\n{:?}", rhs, lhs);
Expand Down
2 changes: 1 addition & 1 deletion src/array/growable/dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn concatenate_values<K: DictionaryKey>(
arrays_values: &[&dyn Array],
capacity: usize,
) -> (Arc<dyn Array>, Vec<usize>) {
let mut mutable = make_growable(&arrays_values, false, capacity);
let mut mutable = make_growable(arrays_values, false, capacity);
let mut offsets = Vec::with_capacity(arrays_keys.len() + 1);
offsets.push(0);
for (i, values) in arrays_values.iter().enumerate() {
Expand Down
2 changes: 1 addition & 1 deletion src/array/ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn compare_f64<'a>(left: &'a dyn Array, right: &'a dyn Array) -> DynComparator<'
fn compare_string<'a, O: Offset>(left: &'a dyn Array, right: &'a dyn Array) -> DynComparator<'a> {
let left = left.as_any().downcast_ref::<Utf8Array<O>>().unwrap();
let right = right.as_any().downcast_ref::<Utf8Array<O>>().unwrap();
Box::new(move |i, j| left.value(i).cmp(&right.value(j)))
Box::new(move |i, j| left.value(i).cmp(right.value(j)))
}

fn compare_dict<'a, K>(
Expand Down
6 changes: 3 additions & 3 deletions src/array/primitive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ mod tests {
array.validity(),
&Some(Bitmap::from_u8_slice(&[0b00000101], 3))
);
assert_eq!(array.is_valid(0), true);
assert_eq!(array.is_valid(1), false);
assert_eq!(array.is_valid(2), true);
assert!(array.is_valid(0));
assert!(!array.is_valid(1));
assert!(array.is_valid(2));

let array2 = PrimitiveArray::<i32>::from_data(
DataType::Int32,
Expand Down
6 changes: 3 additions & 3 deletions src/array/utf8/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ mod tests {
array.validity(),
&Some(Bitmap::from_u8_slice(&[0b00000101], 3))
);
assert_eq!(array.is_valid(0), true);
assert_eq!(array.is_valid(1), false);
assert_eq!(array.is_valid(2), true);
assert!(array.is_valid(0));
assert!(!array.is_valid(1));
assert!(array.is_valid(2));

let array2 = Utf8Array::<i32>::from_data(
array.offsets().clone(),
Expand Down
14 changes: 7 additions & 7 deletions src/bitmap/bitmap_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl Not for &Bitmap {
type Output = Bitmap;

fn not(self) -> Bitmap {
unary(&self, |a| !a)
unary(self, |a| !a)
}
}

Expand All @@ -194,28 +194,28 @@ mod test {
fn test_eq() {
let lhs = create_bitmap([0b01101010], 8);
let rhs = create_bitmap([0b01001110], 8);
assert_eq!(eq(&lhs, &rhs), false);
assert_eq!(eq(&lhs, &lhs), true);
assert!(!eq(&lhs, &rhs));
assert!(eq(&lhs, &lhs));
}

#[test]
fn test_eq_len() {
let lhs = create_bitmap([0b01101010], 6);
let rhs = create_bitmap([0b00101010], 6);
assert_eq!(eq(&lhs, &rhs), true);
assert!(eq(&lhs, &rhs));
let rhs = create_bitmap([0b00001010], 6);
assert_eq!(eq(&lhs, &rhs), false);
assert!(!eq(&lhs, &rhs));
}

#[test]
fn test_eq_slice() {
let lhs = create_bitmap([0b10101010], 8).slice(1, 7);
let rhs = create_bitmap([0b10101011], 8).slice(1, 7);
assert_eq!(eq(&lhs, &rhs), true);
assert!(eq(&lhs, &rhs));

let lhs = create_bitmap([0b10101010], 8).slice(2, 6);
let rhs = create_bitmap([0b10101110], 8).slice(2, 6);
assert_eq!(eq(&lhs, &rhs), false);
assert!(!eq(&lhs, &rhs));
}

#[test]
Expand Down
10 changes: 5 additions & 5 deletions src/bitmap/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ mod tests {
unsafe { b.extend_from_trusted_len_iter_unchecked(iter) };
let b: Bitmap = b.into();
let mut iter = b.iter().enumerate();
assert_eq!(iter.next().unwrap().1, true);
assert!(iter.next().unwrap().1);
for (i, v) in iter {
assert_eq!((i - 1) % 6 == 0, v);
}
Expand All @@ -570,14 +570,14 @@ mod tests {
fn test_set() {
let mut bitmap = MutableBitmap::from_len_zeroed(12);
bitmap.set(0, true);
assert_eq!(bitmap.get(0), true);
assert!(bitmap.get(0));
bitmap.set(0, false);
assert_eq!(bitmap.get(0), false);
assert!(!bitmap.get(0));

bitmap.set(11, true);
assert_eq!(bitmap.get(11), true);
assert!(bitmap.get(11));
bitmap.set(11, false);
assert_eq!(bitmap.get(11), false);
assert!(!bitmap.get(11));
bitmap.set(11, true);

let bitmap: Option<Bitmap> = bitmap.into();
Expand Down
16 changes: 8 additions & 8 deletions src/bitmap/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,21 @@ mod tests {
0b01000000, 0b11111111,
];
for i in 0..8 {
assert_eq!(get_bit(input, i), false);
assert!(!get_bit(input, i));
}
assert_eq!(get_bit(input, 8), true);
assert!(get_bit(input, 8));
for i in 8 + 1..2 * 8 {
assert_eq!(get_bit(input, i), false);
assert!(!get_bit(input, i));
}
assert_eq!(get_bit(input, 2 * 8 + 1), true);
assert!(get_bit(input, 2 * 8 + 1));
for i in 2 * 8 + 2..3 * 8 {
assert_eq!(get_bit(input, i), false);
assert!(!get_bit(input, i));
}
assert_eq!(get_bit(input, 3 * 8 + 2), true);
assert!(get_bit(input, 3 * 8 + 2));
for i in 3 * 8 + 3..4 * 8 {
assert_eq!(get_bit(input, i), false);
assert!(!get_bit(input, i));
}
assert_eq!(get_bit(input, 4 * 8 + 3), true);
assert!(get_bit(input, 4 * 8 + 3));
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/buffer/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ mod tests {
fn test_new() {
let buffer = Buffer::<i32>::new();
assert_eq!(buffer.len(), 0);
assert_eq!(buffer.is_empty(), true);
assert!(buffer.is_empty());
}

#[test]
fn test_new_zeroed() {
let buffer = Buffer::<i32>::new_zeroed(2);
assert_eq!(buffer.len(), 2);
assert_eq!(buffer.is_empty(), false);
assert!(!buffer.is_empty());
assert_eq!(buffer.as_slice(), &[0, 0]);
}

Expand Down
6 changes: 3 additions & 3 deletions src/buffer/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,21 +621,21 @@ mod tests {
fn default() {
let b = MutableBuffer::<i32>::default();
assert_eq!(b.len(), 0);
assert_eq!(b.is_empty(), true);
assert!(b.is_empty());
}

#[test]
fn with_capacity() {
let b = MutableBuffer::<i32>::with_capacity(6);
assert!(b.capacity() >= 6);
assert_eq!(b.is_empty(), true);
assert!(b.is_empty());
}

#[test]
fn from_len_zeroed() {
let b = MutableBuffer::<i32>::from_len_zeroed(3);
assert_eq!(b.len(), 3);
assert_eq!(b.is_empty(), false);
assert!(!b.is_empty());
assert_eq!(b.as_slice(), &[0, 0, 0]);
}

Expand Down
4 changes: 2 additions & 2 deletions src/compute/aggregate/min_max.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn min_max_string<O: Offset, F: Fn(&str, &str) -> bool>(

for i in 0..array.len() {
let item = array.value(i);
if validity.get_bit(i) && (!has_value || cmp(&n, item)) {
if validity.get_bit(i) && (!has_value || cmp(n, item)) {
has_value = true;
n = item;
}
Expand All @@ -45,7 +45,7 @@ fn min_max_string<O: Offset, F: Fn(&str, &str) -> bool>(
for i in 1..array.len() {
// loop is up to `len`.
let item = unsafe { array.value_unchecked(i) };
if cmp(&n, item) {
if cmp(n, item) {
n = item;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/compute/arithmetics/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ mod tests {
let expected = PrimitiveArray::from(&vec![Some(10i64), Some(20i64), None, Some(30i64)])
.to(DataType::Duration(TimeUnit::Second));

let result = subtract_timestamps(&timestamp_a, &&timestamp_b).unwrap();
let result = subtract_timestamps(&timestamp_a, &timestamp_b).unwrap();
assert_eq!(result, expected);
}

Expand Down Expand Up @@ -526,7 +526,7 @@ mod tests {
])
.to(DataType::Duration(TimeUnit::Millisecond));

let result = subtract_timestamps(&timestamp_a, &&timestamp_b).unwrap();
let result = subtract_timestamps(&timestamp_a, &timestamp_b).unwrap();
assert_eq!(result, expected);
}

Expand Down
2 changes: 1 addition & 1 deletion src/compute/arity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ where
// the iteration, then the validity is changed to None to mark the value
// as Null
let bitmap: Bitmap = mut_bitmap.into();
let validity = combine_validities(&array.validity(), &Some(bitmap));
let validity = combine_validities(array.validity(), &Some(bitmap));

PrimitiveArray::<O>::from_data(data_type, values, validity)
}
Expand Down
8 changes: 4 additions & 4 deletions src/compute/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ where
let left_buffer = lhs.values();
let right_buffer = rhs.values();

let values = op(&left_buffer, &right_buffer);
let values = op(left_buffer, right_buffer);

Ok(BooleanArray::from_data(values, validity))
}
Expand All @@ -60,7 +60,7 @@ where
/// # }
/// ```
pub fn and(lhs: &BooleanArray, rhs: &BooleanArray) -> Result<BooleanArray> {
binary_boolean_kernel(&lhs, &rhs, |lhs, rhs| lhs & rhs)
binary_boolean_kernel(lhs, rhs, |lhs, rhs| lhs & rhs)
}

/// Performs `OR` operation on two arrays. If either left or right value is null then the
Expand All @@ -81,7 +81,7 @@ pub fn and(lhs: &BooleanArray, rhs: &BooleanArray) -> Result<BooleanArray> {
/// # }
/// ```
pub fn or(lhs: &BooleanArray, rhs: &BooleanArray) -> Result<BooleanArray> {
binary_boolean_kernel(&lhs, &rhs, |lhs, rhs| lhs | rhs)
binary_boolean_kernel(lhs, rhs, |lhs, rhs| lhs | rhs)
}

/// Performs unary `NOT` operation on an arrays. If value is null then the result is also
Expand Down Expand Up @@ -352,7 +352,7 @@ mod tests {
let b = b.slice(2, 4);
let b = b.as_any().downcast_ref::<BooleanArray>().unwrap();

let c = and(&a, &b).unwrap();
let c = and(a, b).unwrap();

let expected = BooleanArray::from(vec![Some(false), Some(false), None, Some(true)]);

Expand Down
Loading

0 comments on commit 16c089e

Please sign in to comment.