Skip to main content

copy_to_canonical_width

Function copy_to_canonical_width 

Source
pub fn copy_to_canonical_width<F: NativeDecimalType>(
    values: &[F],
    validity: &Mask,
    target: DecimalDType,
) -> VortexResult<BufferHandle>
Expand description

Copies unscaled decimal values into a new buffer at the canonical width of target.

The copy holds values.len() values of DecimalDType::canonical_values_type. It never rescales, so the values keep the scale of the source.

  • A narrowing copy, where the canonical width is narrower than F, checks every valid value against the precision of target with check_precision. A value that fits the width but not the precision fails too. Null slots of the copy hold zeros.
  • A widening or same-width copy checks nothing and keeps the null slots. The caller must know that every valid value fits target, for example because target has at least the precision of the source dtype. Otherwise the copy holds values outside the precision, which is an incorrect result but not undefined behavior. A caller that owns a buffer that already has the canonical width can keep it and call check_precision instead.

ยงErrors

Returns an error if validity and values have different lengths, or if a narrowing copy finds a valid value outside the precision of target, as check_precision describes.