Skip to content

Commit

Permalink
Backport clippy fixes to active release (#475)
Browse files Browse the repository at this point in the history
* fix clippy warnings for rust 1.53 (#470)

* fix clippy warnings for rust 1.53

* update readme

* Fix up

Co-authored-by: Jiayu Liu <Jimexist@users.noreply.github.com>
  • Loading branch information
alamb and jimexist authored Jun 20, 2021
1 parent 1f7f4bc commit 153085f
Show file tree
Hide file tree
Showing 33 changed files with 317 additions and 339 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ By default, `cargo test` will look for these directories at their
standard location. The following environment variables can be used to override the location:

```bash
# Optionaly specify a different location for test data
# Optionally specify a different location for test data
export PARQUET_TEST_DATA=$(cd ../parquet-testing/data; pwd)
export ARROW_TEST_DATA=$(cd ../testing/data; pwd)
```
Expand Down Expand Up @@ -147,7 +147,7 @@ We recommend using `clippy` for checking lints during development. While we do n

Run the following to check for clippy lints.

```
```bash
cargo clippy
```

Expand Down Expand Up @@ -175,7 +175,7 @@ ls -l .git/hooks/pre-commit
If the file already exists, to avoid mistakenly **overriding**, you MAY have to check
the link source or file content. Else if not exist, let's safely soft link [pre-commit.sh](pre-commit.sh) as file `.git/hooks/pre-commit`:

```
```bash
ln -s ../../rust/pre-commit.sh .git/hooks/pre-commit
```

Expand Down
10 changes: 5 additions & 5 deletions arrow/src/array/array_binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,11 +972,11 @@ mod tests {
assert_eq!(array.value(1), b"two");
assert_eq!(array.value(3), b"");
assert_eq!(array.value(4), b"three");
assert_eq!(array.is_null(0), false);
assert_eq!(array.is_null(1), false);
assert_eq!(array.is_null(2), true);
assert_eq!(array.is_null(3), false);
assert_eq!(array.is_null(4), false);
assert!(!array.is_null(0));
assert!(!array.is_null(1));
assert!(array.is_null(2));
assert!(!array.is_null(3));
assert!(!array.is_null(4));
}

#[test]
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 @@ -147,7 +147,7 @@ impl From<Vec<bool>> for BooleanArray {

impl From<Vec<Option<bool>>> for BooleanArray {
fn from(data: Vec<Option<bool>>) -> Self {
BooleanArray::from_iter(data.iter())
data.iter().collect()
}
}

Expand Down
12 changes: 6 additions & 6 deletions arrow/src/array/array_dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,12 @@ mod tests {
assert_eq!(&DataType::Int32, keys.data_type());
assert_eq!(3, keys.null_count());

assert_eq!(true, keys.is_valid(0));
assert_eq!(false, keys.is_valid(1));
assert_eq!(true, keys.is_valid(2));
assert_eq!(false, keys.is_valid(3));
assert_eq!(false, keys.is_valid(4));
assert_eq!(true, keys.is_valid(5));
assert!(keys.is_valid(0));
assert!(!keys.is_valid(1));
assert!(keys.is_valid(2));
assert!(!keys.is_valid(3));
assert!(!keys.is_valid(4));
assert!(keys.is_valid(5));

assert_eq!(0, keys.value(0));
assert_eq!(1, keys.value(2));
Expand Down
18 changes: 9 additions & 9 deletions arrow/src/array/array_primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,19 +777,19 @@ mod tests {

let bool_arr = arr2.as_any().downcast_ref::<BooleanArray>().unwrap();

assert_eq!(false, bool_arr.is_valid(0));
assert!(!bool_arr.is_valid(0));

assert_eq!(true, bool_arr.is_valid(1));
assert_eq!(true, bool_arr.value(1));
assert!(bool_arr.is_valid(1));
assert!(bool_arr.value(1));

assert_eq!(true, bool_arr.is_valid(2));
assert_eq!(false, bool_arr.value(2));
assert!(bool_arr.is_valid(2));
assert!(!bool_arr.value(2));

assert_eq!(true, bool_arr.is_valid(3));
assert_eq!(true, bool_arr.value(3));
assert!(bool_arr.is_valid(3));
assert!(bool_arr.value(3));

assert_eq!(true, bool_arr.is_valid(4));
assert_eq!(false, bool_arr.value(4));
assert!(bool_arr.is_valid(4));
assert!(!bool_arr.value(4));
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions arrow/src/array/array_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,12 @@ mod tests {
assert_eq!(5, c0.len());
assert_eq!(3, c0.null_count());
assert!(c0.is_valid(0));
assert_eq!(false, c0.value(0));
assert!(!c0.value(0));
assert!(c0.is_null(1));
assert!(c0.is_null(2));
assert!(c0.is_null(3));
assert!(c0.is_valid(4));
assert_eq!(true, c0.value(4));
assert!(c0.value(4));

let c1 = struct_array.column(1);
let c1 = c1.as_any().downcast_ref::<Int32Array>().unwrap();
Expand Down Expand Up @@ -500,7 +500,7 @@ mod tests {
assert!(sliced_c0.is_null(0));
assert!(sliced_c0.is_null(1));
assert!(sliced_c0.is_valid(2));
assert_eq!(true, sliced_c0.value(2));
assert!(sliced_c0.value(2));

let sliced_c1 = sliced_array.column(1);
let sliced_c1 = sliced_c1.as_any().downcast_ref::<Int32Array>().unwrap();
Expand Down
30 changes: 15 additions & 15 deletions arrow/src/array/array_union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ mod tests {

assert_eq!(expected_array_values.len(), union.len());
for (i, expected_value) in expected_array_values.iter().enumerate() {
assert_eq!(false, union.is_null(i));
assert!(!union.is_null(i));
let slot = union.value(i);
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
assert_eq!(slot.len(), 1);
Expand All @@ -412,7 +412,7 @@ mod tests {
assert_eq!(5, union.len());
for i in 0..union.len() {
let slot = union.value(i);
assert_eq!(false, union.is_null(i));
assert!(!union.is_null(i));
match i {
0 => {
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
Expand Down Expand Up @@ -465,29 +465,29 @@ mod tests {
match i {
0 => {
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
assert_eq!(false, union.is_null(i));
assert!(!union.is_null(i));
assert_eq!(slot.len(), 1);
let value = slot.value(0);
assert_eq!(1_i32, value);
}
1 => {
let slot = slot.as_any().downcast_ref::<Int64Array>().unwrap();
assert_eq!(false, union.is_null(i));
assert!(!union.is_null(i));
assert_eq!(slot.len(), 1);
let value = slot.value(0);
assert_eq!(3_i64, value);
}
2 => {
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
assert_eq!(false, union.is_null(i));
assert!(!union.is_null(i));
assert_eq!(slot.len(), 1);
let value = slot.value(0);
assert_eq!(10_i32, value);
}
3 => assert!(union.is_null(i)),
4 => {
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
assert_eq!(false, union.is_null(i));
assert!(!union.is_null(i));
assert_eq!(slot.len(), 1);
let value = slot.value(0);
assert_eq!(6_i32, value);
Expand Down Expand Up @@ -516,15 +516,15 @@ mod tests {
match i {
0 => {
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
assert_eq!(false, union.is_null(i));
assert!(!union.is_null(i));
assert_eq!(slot.len(), 1);
let value = slot.value(0);
assert_eq!(10_i32, value);
}
1 => assert!(new_union.is_null(i)),
2 => {
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
assert_eq!(false, union.is_null(i));
assert!(!union.is_null(i));
assert_eq!(slot.len(), 1);
let value = slot.value(0);
assert_eq!(6_i32, value);
Expand Down Expand Up @@ -666,7 +666,7 @@ mod tests {

assert_eq!(expected_array_values.len(), union.len());
for (i, expected_value) in expected_array_values.iter().enumerate() {
assert_eq!(false, union.is_null(i));
assert!(!union.is_null(i));
let slot = union.value(i);
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
assert_eq!(slot.len(), 1);
Expand Down Expand Up @@ -701,7 +701,7 @@ mod tests {

for i in 0..union.len() {
let slot = union.value(i);
assert_eq!(false, union.is_null(i));
assert!(!union.is_null(i));
match i {
0 => {
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
Expand Down Expand Up @@ -766,22 +766,22 @@ mod tests {
match i {
0 => {
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
assert_eq!(false, union.is_null(i));
assert!(!union.is_null(i));
assert_eq!(slot.len(), 1);
let value = slot.value(0);
assert_eq!(1_i32, value);
}
1 => assert!(union.is_null(i)),
2 => {
let slot = slot.as_any().downcast_ref::<Float64Array>().unwrap();
assert_eq!(false, union.is_null(i));
assert!(!union.is_null(i));
assert_eq!(slot.len(), 1);
let value = slot.value(0);
assert!(value - 3_f64 < f64::EPSILON);
}
3 => {
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
assert_eq!(false, union.is_null(i));
assert!(!union.is_null(i));
assert_eq!(slot.len(), 1);
let value = slot.value(0);
assert_eq!(4_i32, value);
Expand Down Expand Up @@ -811,15 +811,15 @@ mod tests {
0 => assert!(new_union.is_null(i)),
1 => {
let slot = slot.as_any().downcast_ref::<Float64Array>().unwrap();
assert_eq!(false, new_union.is_null(i));
assert!(!new_union.is_null(i));
assert_eq!(slot.len(), 1);
let value = slot.value(0);
assert!(value - 3_f64 < f64::EPSILON);
}
2 => assert!(new_union.is_null(i)),
3 => {
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
assert_eq!(false, new_union.is_null(i));
assert!(!new_union.is_null(i));
assert_eq!(slot.len(), 1);
let value = slot.value(0);
assert_eq!(4_i32, value);
Expand Down
18 changes: 9 additions & 9 deletions arrow/src/array/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2264,11 +2264,11 @@ mod tests {
assert_eq!(a.len(), 7);
let array = a.finish();
assert_eq!(array.value(0), 1);
assert_eq!(array.is_null(1), true);
assert!(array.is_null(1));
assert_eq!(array.value(2), -2);
assert_eq!(array.value(3), 1);
assert_eq!(array.value(4), 2);
assert_eq!(array.is_null(5), true);
assert!(array.is_null(5));
assert_eq!(array.value(6), 4);

Ok(())
Expand Down Expand Up @@ -3201,9 +3201,9 @@ mod tests {
let ava: &UInt32Array = av.as_any().downcast_ref::<UInt32Array>().unwrap();
let avs: &[u32] = ava.values();

assert_eq!(array.is_null(0), false);
assert_eq!(array.is_null(1), true);
assert_eq!(array.is_null(2), false);
assert!(!array.is_null(0));
assert!(array.is_null(1));
assert!(!array.is_null(2));

assert_eq!(avs, &[12345678, 22345678]);
}
Expand Down Expand Up @@ -3258,7 +3258,7 @@ mod tests {
let av = array.values();
let ava: &StringArray = av.as_any().downcast_ref::<StringArray>().unwrap();

assert_eq!(ava.is_valid(0), false);
assert!(!ava.is_valid(0));
assert_eq!(ava.value(1), "def");
assert_eq!(ava.value(2), "abc");
assert_eq!(ava.value(3), "ghi");
Expand All @@ -3279,13 +3279,13 @@ mod tests {
builder.append("abc").unwrap();
let array = builder.finish();

assert_eq!(array.is_null(1), true);
assert_eq!(array.is_valid(1), false);
assert!(array.is_null(1));
assert!(!array.is_valid(1));

let keys = array.keys_array();

assert_eq!(keys.value(0), 1);
assert_eq!(keys.is_null(1), true);
assert!(keys.is_null(1));
// zero initialization is currently guaranteed by Buffer allocation and resizing
assert_eq!(keys.value(1), 0);
assert_eq!(keys.value(2), 2);
Expand Down
16 changes: 8 additions & 8 deletions arrow/src/array/equal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,18 +361,18 @@ mod tests {
let b =
BooleanArray::from(vec![true, false, false, false, true, false, true, true]);
let b = b.data();
assert_eq!(equal(a, b), false);
assert_eq!(equal(b, a), false);
assert!(!equal(a, b));
assert!(!equal(b, a));

let a_slice = a.slice(2, 3);
let b_slice = b.slice(3, 3);
assert_eq!(equal(&a_slice, &b_slice), true);
assert_eq!(equal(&b_slice, &a_slice), true);
assert!(equal(&a_slice, &b_slice));
assert!(equal(&b_slice, &a_slice));

let a_slice = a.slice(3, 4);
let b_slice = b.slice(4, 4);
assert_eq!(equal(&a_slice, &b_slice), false);
assert_eq!(equal(&b_slice, &a_slice), false);
assert!(!equal(&a_slice, &b_slice));
assert!(!equal(&b_slice, &a_slice));

// Test the optimization cases where null_count == 0 and starts at 0 and len >= size_of(u8)

Expand Down Expand Up @@ -486,8 +486,8 @@ mod tests {

fn test_equal(lhs: &ArrayData, rhs: &ArrayData, 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 arrow/src/array/null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ mod tests {

assert_eq!(null_arr.len(), 32);
assert_eq!(null_arr.null_count(), 32);
assert_eq!(null_arr.is_valid(0), false);
assert!(!null_arr.is_valid(0));

assert_eq!(0, null_arr.get_buffer_memory_size());
assert_eq!(
Expand Down
7 changes: 3 additions & 4 deletions arrow/src/array/ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ pub mod tests {
use crate::array::{Float64Array, Int32Array};
use crate::error::Result;
use std::cmp::Ordering;
use std::iter::FromIterator;

#[test]
fn test_i32() -> Result<()> {
Expand Down Expand Up @@ -298,7 +297,7 @@ pub mod tests {
#[test]
fn test_dict() -> Result<()> {
let data = vec!["a", "b", "c", "a", "a", "c", "c"];
let array = DictionaryArray::<Int16Type>::from_iter(data.into_iter());
let array = data.into_iter().collect::<DictionaryArray<Int16Type>>();

let cmp = build_compare(&array, &array)?;

Expand All @@ -311,9 +310,9 @@ pub mod tests {
#[test]
fn test_multiple_dict() -> Result<()> {
let d1 = vec!["a", "b", "c", "d"];
let a1 = DictionaryArray::<Int16Type>::from_iter(d1.into_iter());
let a1 = d1.into_iter().collect::<DictionaryArray<Int16Type>>();
let d2 = vec!["e", "f", "g", "a"];
let a2 = DictionaryArray::<Int16Type>::from_iter(d2.into_iter());
let a2 = d2.into_iter().collect::<DictionaryArray<Int16Type>>();

let cmp = build_compare(&a1, &a2)?;

Expand Down
Loading

0 comments on commit 153085f

Please sign in to comment.