viirya commented on code in PR #2247:
URL: https://github.com/apache/arrow-rs/pull/2247#discussion_r934041351
##########
arrow/src/array/array_decimal.rs:
##########
@@ -384,6 +391,59 @@ impl<'a> Decimal128Array {
}
}
+impl From<BigInt> for Decimal256 {
+ fn from(bigint: BigInt) -> Self {
+ Decimal256::from_big_int(&bigint, DECIMAL256_MAX_PRECISION,
DECIMAL_DEFAULT_SCALE)
+ .unwrap()
+ }
+}
+
+fn build_decimal_array_from<U: BasicDecimalArray<T, U>, T>(
+ null_buf: BooleanBufferBuilder,
+ buffer: Buffer,
+) -> U
+where
+ T: BasicDecimal,
+ U: From<ArrayData>,
+{
+ let data = unsafe {
+ ArrayData::new_unchecked(
+ U::default_type(),
+ null_buf.len(),
+ None,
+ Some(null_buf.into()),
+ 0,
+ vec![buffer],
+ vec![],
+ )
+ };
+ U::from(data)
+}
+
+impl<Ptr: Into<Decimal256>> FromIterator<Option<Ptr>> for Decimal256Array {
+ fn from_iter<I: IntoIterator<Item = Option<Ptr>>>(iter: I) -> Self {
+ let iter = iter.into_iter();
+ let (lower, upper) = iter.size_hint();
+ let size_hint = upper.unwrap_or(lower);
+
+ let mut null_buf = BooleanBufferBuilder::new(size_hint);
+
+ let mut buffer = MutableBuffer::from_len_zeroed(0);
Review Comment:
Changed to `with_capacity`.
--
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]