This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new 0d1511cfafc minor: use as_primitive replace downcast_ref (#5898)
0d1511cfafc is described below
commit 0d1511cfafc76528df0e27deb726ed67f16e9deb
Author: Kikkon <[email protected]>
AuthorDate: Mon Jun 17 17:42:43 2024 +0800
minor: use as_primitive replace downcast_ref (#5898)
---
arrow-array/src/array/list_array.rs | 56 ++++++-------------------------------
1 file changed, 8 insertions(+), 48 deletions(-)
diff --git a/arrow-array/src/array/list_array.rs
b/arrow-array/src/array/list_array.rs
index ba3719392eb..dc1b9f07da1 100644
--- a/arrow-array/src/array/list_array.rs
+++ b/arrow-array/src/array/list_array.rs
@@ -632,21 +632,11 @@ mod tests {
assert_eq!(0, list_array.null_count());
assert_eq!(6, list_array.value_offsets()[2]);
assert_eq!(2, list_array.value_length(2));
- assert_eq!(
- 0,
- list_array
- .value(0)
- .as_any()
- .downcast_ref::<Int32Array>()
- .unwrap()
- .value(0)
- );
+ assert_eq!(0,
list_array.value(0).as_primitive::<Int32Type>().value(0));
assert_eq!(
0,
unsafe { list_array.value_unchecked(0) }
- .as_any()
- .downcast_ref::<Int32Array>()
- .unwrap()
+ .as_primitive::<Int32Type>()
.value(0)
);
for i in 0..3 {
@@ -672,21 +662,11 @@ mod tests {
assert_eq!(0, list_array.null_count());
assert_eq!(6, list_array.value_offsets()[1]);
assert_eq!(2, list_array.value_length(1));
- assert_eq!(
- 3,
- list_array
- .value(0)
- .as_any()
- .downcast_ref::<Int32Array>()
- .unwrap()
- .value(0)
- );
+ assert_eq!(3,
list_array.value(0).as_primitive::<Int32Type>().value(0));
assert_eq!(
3,
unsafe { list_array.value_unchecked(0) }
- .as_any()
- .downcast_ref::<Int32Array>()
- .unwrap()
+ .as_primitive::<Int32Type>()
.value(0)
);
}
@@ -721,21 +701,11 @@ mod tests {
assert_eq!(0, list_array.null_count());
assert_eq!(6, list_array.value_offsets()[2]);
assert_eq!(2, list_array.value_length(2));
- assert_eq!(
- 0,
- list_array
- .value(0)
- .as_any()
- .downcast_ref::<Int32Array>()
- .unwrap()
- .value(0)
- );
+ assert_eq!(0,
list_array.value(0).as_primitive::<Int32Type>().value(0));
assert_eq!(
0,
unsafe { list_array.value_unchecked(0) }
- .as_any()
- .downcast_ref::<Int32Array>()
- .unwrap()
+ .as_primitive::<Int32Type>()
.value(0)
);
for i in 0..3 {
@@ -761,21 +731,11 @@ mod tests {
assert_eq!(0, list_array.null_count());
assert_eq!(6, list_array.value_offsets()[1]);
assert_eq!(2, list_array.value_length(1));
- assert_eq!(
- 3,
- list_array
- .value(0)
- .as_any()
- .downcast_ref::<Int32Array>()
- .unwrap()
- .value(0)
- );
+ assert_eq!(3,
list_array.value(0).as_primitive::<Int32Type>().value(0));
assert_eq!(
3,
unsafe { list_array.value_unchecked(0) }
- .as_any()
- .downcast_ref::<Int32Array>()
- .unwrap()
+ .as_primitive::<Int32Type>()
.value(0)
);
}