alamb commented on code in PR #2746:
URL: https://github.com/apache/arrow-rs/pull/2746#discussion_r976854262
##########
arrow-data/src/transform/variable_size.rs:
##########
@@ -15,31 +15,33 @@
// specific language governing permissions and limitations
// under the License.
-use crate::{
- array::{ArrayData, OffsetSizeTrait},
- buffer::MutableBuffer,
-};
+use crate::ArrayData;
+use arrow_buffer::{ArrowNativeType, MutableBuffer};
+use num::traits::AsPrimitive;
+use num::Integer;
use super::{
Extend, _MutableArrayData,
utils::{extend_offsets, get_last_offset},
};
#[inline]
-fn extend_offset_values<T: OffsetSizeTrait>(
+fn extend_offset_values<T: ArrowNativeType + AsPrimitive<usize>>(
buffer: &mut MutableBuffer,
offsets: &[T],
values: &[u8],
start: usize,
len: usize,
) {
- let start_values = offsets[start].to_usize().unwrap();
- let end_values = offsets[start + len].to_usize().unwrap();
+ let start_values = offsets[start].as_();
Review Comment:
TIL: https://docs.rs/num/latest/num/cast/trait.AsPrimitive.html#tymethod.as_
`as_()` is something I have not seen before. Fascinating.
##########
arrow/src/array/array_decimal.rs:
##########
@@ -284,7 +284,11 @@ impl<T: DecimalType> DecimalArray<T> {
// safety: self.data is valid DataType::Decimal as checked above
let new_data_type = Self::TYPE_CONSTRUCTOR(precision, scale);
- Ok(self.data().clone().with_data_type(new_data_type).into())
+ let data = self.data().clone().into_builder().data_type(new_data_type);
Review Comment:
cc @liukun4515 -- I think it is fine
##########
arrow-data/src/transform/mod.rs:
##########
@@ -0,0 +1,672 @@
+// Licensed to the Apache Software Foundation (ASF) under one
Review Comment:
I think moving out the tests is a great idea -- I wonder if we need to do
anything more to make them discoverable 🤔
--
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]