-
Notifications
You must be signed in to change notification settings - Fork 763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rust 2021] migrate to rust 2021 #1159
Changes from 1 commit
3bd1fa8
e66ff02
a694e36
6de4d09
15a8125
2cc09d1
7985114
549c68d
ba5c26d
79ee4a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ pub unsafe fn take_no_null_primitive<T: DFNumericType>( | |
av.iter_mut() | ||
.zip(index_values.iter()) | ||
.for_each(|(num, idx)| { | ||
let _ = &array_values; | ||
*num = *array_values.get_unchecked(*idx as usize); | ||
}); | ||
|
||
|
@@ -62,6 +63,7 @@ pub unsafe fn take_no_null_primitive_iter_unchecked< | |
let mut av = AlignedVec::<T::Native>::with_capacity_len_aligned(data_len); | ||
|
||
av.iter_mut().zip(indices_iter).for_each(|(num, idx)| { | ||
let _ = &array_values; | ||
*num = *array_values.get_unchecked(idx); | ||
}); | ||
let arr = av.into_primitive_array::<T>(None); | ||
|
@@ -79,7 +81,10 @@ pub fn take_no_null_primitive_iter<T: DFNumericType, I: IntoIterator<Item = usiz | |
|
||
let av = indices | ||
.into_iter() | ||
.map(|idx| array_values[idx]) | ||
.map(|idx| { | ||
let _ = &array_values; | ||
array_values[idx] | ||
}) | ||
.collect::<AlignedVec<_>>(); | ||
let arr = av.into_primitive_array(None); | ||
|
||
|
@@ -96,6 +101,7 @@ pub unsafe fn take_primitive_iter_unchecked<T: DFNumericType, I: IntoIterator<It | |
let array_values = arr.values(); | ||
|
||
let iter = indices.into_iter().map(|idx| { | ||
let _ = (&arr, &array_values); | ||
if arr.is_valid(idx) { | ||
Some(*array_values.get_unchecked(idx)) | ||
} else { | ||
|
@@ -117,6 +123,7 @@ pub fn take_primitive_iter<T: DFNumericType, I: IntoIterator<Item = usize>>( | |
let arr = indices | ||
.into_iter() | ||
.map(|idx| { | ||
let _ = (&arr, &array_values); | ||
if arr.is_valid(idx) { | ||
Some(array_values[idx]) | ||
} else { | ||
|
@@ -141,9 +148,12 @@ pub unsafe fn take_no_null_primitive_opt_iter_unchecked< | |
) -> Arc<PrimitiveArray<T>> { | ||
let array_values = arr.values(); | ||
|
||
let iter = indices | ||
.into_iter() | ||
.map(|opt_idx| opt_idx.map(|idx| *array_values.get_unchecked(idx))); | ||
let iter = indices.into_iter().map(|opt_idx| { | ||
opt_idx.map(|idx| { | ||
let _ = &array_values; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why rust 2021 turns to be more complicated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😭 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't think it becomes more complicated.
|
||
*array_values.get_unchecked(idx) | ||
}) | ||
}); | ||
let arr = PrimitiveArray::from_trusted_len_iter(iter); | ||
|
||
Arc::new(arr) | ||
|
@@ -164,6 +174,7 @@ pub unsafe fn take_primitive_opt_iter_unchecked< | |
|
||
let iter = indices.into_iter().map(|opt_idx| { | ||
opt_idx.and_then(|idx| { | ||
let _ = (&arr, &array_values); | ||
if arr.is_valid(idx) { | ||
Some(*array_values.get_unchecked(idx)) | ||
} else { | ||
|
@@ -205,7 +216,10 @@ pub fn take_no_null_bool_iter<I: IntoIterator<Item = usize>>( | |
) -> Arc<BooleanArray> { | ||
debug_assert_eq!(arr.null_count(), 0); | ||
|
||
let iter = indices.into_iter().map(|idx| Some(arr.value(idx))); | ||
let iter = indices.into_iter().map(|idx| { | ||
let _ = &arr; | ||
Some(arr.value(idx)) | ||
}); | ||
|
||
Arc::new(iter.collect()) | ||
} | ||
|
@@ -218,9 +232,10 @@ pub unsafe fn take_no_null_bool_iter_unchecked<I: IntoIterator<Item = usize>>( | |
indices: I, | ||
) -> Arc<BooleanArray> { | ||
debug_assert_eq!(arr.null_count(), 0); | ||
let iter = indices | ||
.into_iter() | ||
.map(|idx| Some(arr.value_unchecked(idx))); | ||
let iter = indices.into_iter().map(|idx| { | ||
let _ = &arr; | ||
Some(arr.value_unchecked(idx)) | ||
}); | ||
|
||
Arc::new(iter.collect()) | ||
} | ||
|
@@ -231,6 +246,7 @@ pub fn take_bool_iter<I: IntoIterator<Item = usize>>( | |
indices: I, | ||
) -> Arc<BooleanArray> { | ||
let iter = indices.into_iter().map(|idx| { | ||
let _ = &arr; | ||
if arr.is_null(idx) { | ||
None | ||
} else { | ||
|
@@ -249,6 +265,7 @@ pub unsafe fn take_bool_iter_unchecked<I: IntoIterator<Item = usize>>( | |
indices: I, | ||
) -> Arc<BooleanArray> { | ||
let iter = indices.into_iter().map(|idx| { | ||
let _ = &arr; | ||
if arr.is_null(idx) { | ||
None | ||
} else { | ||
|
@@ -268,6 +285,7 @@ pub unsafe fn take_bool_opt_iter_unchecked<I: IntoIterator<Item = Option<usize>> | |
) -> Arc<BooleanArray> { | ||
let iter = indices.into_iter().map(|opt_idx| { | ||
opt_idx.and_then(|idx| { | ||
let _ = &arr; | ||
if arr.is_null(idx) { | ||
None | ||
} else { | ||
|
@@ -286,9 +304,12 @@ pub unsafe fn take_no_null_bool_opt_iter_unchecked<I: IntoIterator<Item = Option | |
arr: &BooleanArray, | ||
indices: I, | ||
) -> Arc<BooleanArray> { | ||
let iter = indices | ||
.into_iter() | ||
.map(|opt_idx| opt_idx.map(|idx| arr.value_unchecked(idx))); | ||
let iter = indices.into_iter().map(|opt_idx| { | ||
opt_idx.map(|idx| { | ||
let _ = &arr; | ||
arr.value_unchecked(idx) | ||
}) | ||
}); | ||
|
||
Arc::new(iter.collect()) | ||
} | ||
|
@@ -299,9 +320,10 @@ pub unsafe fn take_no_null_utf8_iter_unchecked<I: IntoIterator<Item = usize>>( | |
arr: &StringArray, | ||
indices: I, | ||
) -> Arc<StringArray> { | ||
let iter = indices | ||
.into_iter() | ||
.map(|idx| Some(arr.value_unchecked(idx))); | ||
let iter = indices.into_iter().map(|idx| { | ||
let _ = &arr; | ||
Some(arr.value_unchecked(idx)) | ||
}); | ||
|
||
Arc::new(iter.collect()) | ||
} | ||
|
@@ -313,6 +335,7 @@ pub unsafe fn take_utf8_iter_unchecked<I: IntoIterator<Item = usize>>( | |
indices: I, | ||
) -> Arc<StringArray> { | ||
let iter = indices.into_iter().map(|idx| { | ||
let _ = &arr; | ||
if arr.is_null(idx) { | ||
None | ||
} else { | ||
|
@@ -329,9 +352,12 @@ pub unsafe fn take_no_null_utf8_opt_iter_unchecked<I: IntoIterator<Item = Option | |
arr: &StringArray, | ||
indices: I, | ||
) -> Arc<StringArray> { | ||
let iter = indices | ||
.into_iter() | ||
.map(|opt_idx| opt_idx.map(|idx| arr.value_unchecked(idx))); | ||
let iter = indices.into_iter().map(|opt_idx| { | ||
opt_idx.map(|idx| { | ||
let _ = &arr; | ||
arr.value_unchecked(idx) | ||
}) | ||
}); | ||
|
||
Arc::new(iter.collect()) | ||
} | ||
|
@@ -344,6 +370,7 @@ pub unsafe fn take_utf8_opt_iter_unchecked<I: IntoIterator<Item = Option<usize>> | |
) -> Arc<StringArray> { | ||
let iter = indices.into_iter().map(|opt_idx| { | ||
opt_idx.and_then(|idx| { | ||
let _ = &arr; | ||
if arr.is_null(idx) { | ||
None | ||
} else { | ||
|
@@ -359,7 +386,10 @@ pub fn take_no_null_utf8_iter<I: IntoIterator<Item = usize>>( | |
arr: &StringArray, | ||
indices: I, | ||
) -> Arc<StringArray> { | ||
let iter = indices.into_iter().map(|idx| Some(arr.value(idx))); | ||
let iter = indices.into_iter().map(|idx| { | ||
let _ = &arr; | ||
Some(arr.value(idx)) | ||
}); | ||
|
||
Arc::new(iter.collect()) | ||
} | ||
|
@@ -369,6 +399,7 @@ pub fn take_utf8_iter<I: IntoIterator<Item = usize>>( | |
indices: I, | ||
) -> Arc<StringArray> { | ||
let iter = indices.into_iter().map(|idx| { | ||
let _ = &arr; | ||
if arr.is_null(idx) { | ||
None | ||
} else { | ||
|
@@ -413,6 +444,7 @@ pub unsafe fn take_utf8(arr: &StringArray, indices: &UInt32Array) -> Arc<StringA | |
.skip(1) | ||
.enumerate() | ||
.for_each(|(idx, offset)| { | ||
let _ = (&indices, &arr); | ||
let index = indices.value_unchecked(idx) as usize; | ||
let s = arr.value_unchecked(index); | ||
length_so_far += s.len() as i64; | ||
|
@@ -432,6 +464,7 @@ pub unsafe fn take_utf8(arr: &StringArray, indices: &UInt32Array) -> Arc<StringA | |
.skip(1) | ||
.enumerate() | ||
.for_each(|(idx, offset)| { | ||
let _ = (&indices, &arr); | ||
if indices.is_valid(idx) { | ||
let index = indices.value_unchecked(idx) as usize; | ||
let s = arr.value_unchecked(index); | ||
|
@@ -452,6 +485,7 @@ pub unsafe fn take_utf8(arr: &StringArray, indices: &UInt32Array) -> Arc<StringA | |
|
||
if indices.null_count() == 0 { | ||
(0..data_len).for_each(|idx| { | ||
let _ = (&indices, &arr); | ||
let index = indices.value_unchecked(idx) as usize; | ||
if arr.is_valid(index) { | ||
let s = arr.value_unchecked(index); | ||
|
@@ -462,6 +496,7 @@ pub unsafe fn take_utf8(arr: &StringArray, indices: &UInt32Array) -> Arc<StringA | |
}); | ||
} else { | ||
(0..data_len).for_each(|idx| { | ||
let _ = (&indices, &arr); | ||
if indices.is_valid(idx) { | ||
let index = indices.value_unchecked(idx) as usize; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html
Auto gen by
cargo fix
. This is a conservative analysis: in many cases, these dummy lets can be safely removed and your program will work fine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like a good style : (
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can do it with macros? similar to '[&captures_var] (args) {} in C++`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can try to remove these dummy let manually. If it is really necessary, consider other options.