viirya commented on code in PR #2006:
URL: https://github.com/apache/arrow-rs/pull/2006#discussion_r914123744
##########
arrow/src/array/array_decimal.rs:
##########
@@ -32,7 +32,16 @@ use crate::datatypes::{
DECIMAL_MAX_SCALE,
};
use crate::error::{ArrowError, Result};
-use crate::util::decimal::{BasicDecimal, Decimal128};
+use crate::util::decimal::{BasicDecimal, Decimal128, Decimal256};
+use std::marker::PhantomData;
+
+pub struct GenericDecimalArray<T: BasicDecimal, const VALUE_LENGTH: i32> {
+ data: ArrayData,
+ value_data: RawPtrBox<u8>,
+ precision: usize,
+ scale: usize,
+ phantom: PhantomData<T>,
+}
Review Comment:
Compared to #2000, which defines a trait and let `DecimalArray` and
`Decimal256Array` extend the trait, this generic approach defines a struct
`GenericDecimalArray` and generalize on Decimal type (Decimal128/Decimal256).
Honestly I prefer #2000's trait approach. It looks more clear to me. But one
cons of #2000 is that it needs to use macro to reduce code duplication.
--
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]