austin362667 commented on code in PR #6671:
URL: https://github.com/apache/arrow-rs/pull/6671#discussion_r1826594133
##########
arrow-string/src/length.rs:
##########
@@ -138,20 +141,12 @@ pub fn bit_length(array: &dyn Array) -> Result<ArrayRef,
ArrowError> {
Ok(bit_length_impl::<Int64Type>(list.offsets(), list.nulls()))
}
DataType::Utf8View => {
- let string_view_array = array
- .as_any()
- .downcast_ref::<StringViewArray>()
- .ok_or_else(|| ArrowError::ComputeError("Expected Utf8View
array".to_string()))?;
- let mut bit_lengths = Vec::with_capacity(array.len());
- for i in 0..array.len() {
- let bit_length = if string_view_array.is_valid(i) {
- (string_view_array.value(i).len() * 8) as i32
- } else {
- 0
- };
- bit_lengths.push(bit_length);
- }
-
+ let list = array.as_string_view();
+ let bit_lengths = list
+ .views()
+ .iter()
+ .map(|view| (*view as i32) * 8)
Review Comment:
Sure! Thanks @alamb for review
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]