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 2021/06/06 12:37:19 UTC

[GitHub] [arrow-rs] novemberkilo commented on a change in pull request #414: Doctests for DecimalArray.

novemberkilo commented on a change in pull request #414:
URL: https://github.com/apache/arrow-rs/pull/414#discussion_r646126995



##########
File path: arrow/src/array/array_binary.rs
##########
@@ -613,6 +613,32 @@ impl Array for FixedSizeBinaryArray {
 }
 
 /// A type of `DecimalArray` whose elements are binaries.
+///
+/// # Examples
+///
+/// ```
+///    use arrow::array::{ArrayData, Array, DecimalArray};
+///    use arrow::buffer::Buffer;
+///    use arrow::datatypes::DataType;
+///    // let val_8887: [u8; 16] = [192, 219, 180, 17, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
+///    // let val_neg_8887: [u8; 16] = [64, 36, 75, 238, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255];
+///    let values: [u8; 32] = [
+///        192, 219, 180, 17, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 36, 75, 238, 253,
+///        255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+///    ];
+///    let array_data = ArrayData::builder(DataType::Decimal(23, 6))
+///        .len(2)
+///        .add_buffer(Buffer::from(&values[..]))
+///        .build();
+///    let decimal_array = DecimalArray::from(array_data);
+///    assert_eq!(2, decimal_array.len());
+///    assert_eq!(8_887_000_000, decimal_array.value(0));
+///    assert_eq!(-8_887_000_000, decimal_array.value(1));
+///    assert_eq!(16, decimal_array.value_length());
+///    assert_eq!(23, decimal_array.precision());
+///    assert_eq!(6, decimal_array.scale());

Review comment:
       @alamb I have followed your suggestion to replace the example with one that uses `DecimalBuilder` instead. If I am following correctly, I won't be able to really use any of #406 there will I?




-- 
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.

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