viirya commented on code in PR #2383:
URL: https://github.com/apache/arrow-rs/pull/2383#discussion_r940955661
##########
arrow/src/array/array_decimal.rs:
##########
@@ -71,44 +71,47 @@ use crate::util::decimal::{BasicDecimal, Decimal128,
Decimal256};
/// assert_eq!(6, decimal_array.scale());
/// ```
///
-pub struct Decimal128Array {
- data: ArrayData,
- value_data: RawPtrBox<u8>,
- precision: usize,
- scale: usize,
-}
+pub type Decimal128Array = BasicDecimalArray<16>;
-pub struct Decimal256Array {
- data: ArrayData,
- value_data: RawPtrBox<u8>,
- precision: usize,
- scale: usize,
-}
+pub type Decimal256Array = BasicDecimalArray<32>;
mod private_decimal {
pub trait DecimalArrayPrivate {
fn raw_value_data_ptr(&self) -> *const u8;
}
}
-pub trait BasicDecimalArray<T: BasicDecimal, U: From<ArrayData>>:
- private_decimal::DecimalArrayPrivate
-{
- const VALUE_LENGTH: i32;
- const DEFAULT_TYPE: DataType;
- const MAX_PRECISION: usize;
- const MAX_SCALE: usize;
+pub struct BasicDecimalArray<const BYTE_WIDTH: usize> {
+ data: ArrayData,
+ value_data: RawPtrBox<u8>,
+ precision: usize,
+ scale: usize,
+}
+
+impl<const BYTE_WIDTH: usize> BasicDecimalArray<BYTE_WIDTH> {
+ pub const VALUE_LENGTH: i32 = BYTE_WIDTH as i32;
+ pub const DEFAULT_TYPE: DataType =
BasicDecimal::<BYTE_WIDTH>::DEFAULT_TYPE;
+ pub const MAX_PRECISION: usize = BasicDecimal::<BYTE_WIDTH>::MAX_PRECISION;
+ pub const MAX_SCALE: usize = BasicDecimal::<BYTE_WIDTH>::MAX_SCALE;
+ pub const TYPE_CONSTRUCTOR: fn(usize, usize) -> DataType =
Review Comment:
Can TYPE_CONSTRUCTOR be non-public?
--
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]