pub struct DecimalArray { /* private fields */ }
Expand description

DecimalArray stores fixed width decimal numbers, with a fixed precision and scale.

Examples

   use arrow::array::{Array, DecimalArray};
   use arrow::datatypes::DataType;

   // Create a DecimalArray with the default precision and scale
   let decimal_array: DecimalArray = vec![
      Some(8_887_000_000),
      None,
      Some(-8_887_000_000),
    ]
    .into_iter().collect();

   // set precision and scale so values are interpreted
   // as `8887.000000`, `Null`, and `-8887.000000`
   let decimal_array = decimal_array
    .with_precision_and_scale(23, 6)
    .unwrap();

   assert_eq!(&DataType::Decimal(23, 6), decimal_array.data_type());
   assert_eq!(8_887_000_000, decimal_array.value(0));
   assert_eq!("8887.000000", decimal_array.value_as_string(0));
   assert_eq!(3, decimal_array.len());
   assert_eq!(1, decimal_array.null_count());
   assert_eq!(32, decimal_array.value_offset(2));
   assert_eq!(16, decimal_array.value_length());
   assert_eq!(23, decimal_array.precision());
   assert_eq!(6, decimal_array.scale());

Implementations

Returns the element at index i as i128.

Returns the offset for the element at index i.

Note this doesn’t do any bound checking, for performance reason.

Returns the length for an element.

All elements have the same length as the array is a fixed size.

Returns a clone of the value data buffer

Creates a DecimalArray with default precision and scale, based on an iterator of i128 values without nulls

Return the precision (total digits) that can be stored by this array

Return the scale (digits after the decimal) that can be stored by this array

Returns a DecimalArray with the same data as self, with the specified precision.

Returns an Error if:

  1. precision is larger than DECIMAL_MAX_PRECISION
  2. scale is larger than DECIMAL_MAX_SCALE;
  3. scale is > precision

The default precision and scale used when not specified.

constructs a new iterator

Trait Implementations

Returns the array as Any so that it can be downcasted to a specific implementation. Read more

Returns a reference to the underlying data of this array.

Returns a reference-counted pointer to the underlying data of this array.

Returns a reference to the DataType of this array. Read more

Returns a zero-copy slice of this array with the indicated offset and length. Read more

Returns the length (i.e., number of elements) of this array. Read more

Returns whether this array is empty. Read more

Returns the offset into the underlying data used by this array(-slice). Note that the underlying data can be shared by many arrays. This defaults to 0. Read more

Returns whether the element at index is null. When using this function on a slice, the index is relative to the slice. Read more

Returns whether the element at index is not null. When using this function on a slice, the index is relative to the slice. Read more

Returns the total number of null values in this array. Read more

Returns the total number of bytes of memory pointed to by this array. The buffers store bytes in the Arrow memory format, and include the data as well as the validity map. Read more

Returns the total number of bytes of memory occupied physically by this array. This value will always be greater than returned by get_buffer_memory_size() and includes the overhead of the data structures that contain the pointers to the various buffers. Read more

returns two pointers that represent this array in the C Data Interface (FFI)

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Creates a value from an iterator. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Checks whether arrow array equals to json array.

Checks whether arrow array equals to json array.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.