You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/06/03 06:31:05 UTC

[GitHub] [arrow-rs] viirya commented on a diff in pull request #1767: Optionally disable `validate_decimal_precision` check in `DecimalBuilder.append_value` for interop test

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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org