viirya commented on code in PR #1767:
URL: https://github.com/apache/arrow-rs/pull/1767#discussion_r888650741
##########
arrow/src/array/data.rs:
##########
@@ -999,6 +999,27 @@ impl ArrayData {
pub fn validate_dictionary_offset(&self) -> Result<()> {
match &self.data_type {
+ DataType::Decimal(p, _) => {
+ let values_buffer = &self.buffers[0];
+
+ for pos in 0..values_buffer.len() {
+ let raw_val = unsafe {
+ std::slice::from_raw_parts(
+ values_buffer.as_ptr().add(pos),
+ 16_usize,
+ )
+ };
+ let as_array = raw_val.try_into();
+ match as_array {
+ Ok(v) if raw_val.len() == 16 => {
Review Comment:
`data` is private. :disappointed:
I simplified it as:
```rust
for pos in 0..values_buffer.len() {
let raw_val = unsafe {
std::slice::from_raw_parts(
values_buffer.as_ptr().add(pos),
16_usize,
)
};
let value = i128::from_le_bytes(raw_val.try_into().unwrap());
validate_decimal_precision(value, *p)?;
}
```
--
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]