Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
liukun4515 committed Aug 12, 2022
1 parent fac1f71 commit 2b353a3
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions arrow/src/array/array_decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,28 +332,20 @@ impl Decimal256Array {
// Validates decimal values in this array can be properly interpreted
// with the specified precision.
fn validate_decimal_precision(&self, precision: usize) -> Result<()> {
let current_end = self.data.len();
let mut current: usize = 0;
let data = &self.data;

while current != current_end {
if self.is_null(current) {
current += 1;
continue;
} else {
let offset = current + data.offset();
current += 1;
(0..self.len()).try_for_each(|idx| {
if self.is_valid(idx) {
let raw_val = unsafe {
let pos = self.value_offset_at(offset);
let pos = self.value_offset(idx);
std::slice::from_raw_parts(
self.raw_value_data_ptr().offset(pos as isize),
Self::VALUE_LENGTH as usize,
)
};
validate_decimal256_precision_with_lt_bytes(raw_val, precision)?;
validate_decimal256_precision_with_lt_bytes(raw_val, precision)
} else {
Ok(())
}
}
Ok(())
})
}

/// Returns a Decimal array with the same data as self, with the
Expand Down

0 comments on commit 2b353a3

Please sign in to comment.