You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2021/08/19 20:50:34 UTC

[arrow-rs] branch cherry_pick_38e5d228 created (now c9dd2d3)

This is an automated email from the ASF dual-hosted git repository.

alamb pushed a change to branch cherry_pick_38e5d228
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git.


      at c9dd2d3  Doctest for PrimitiveArray using from_iter_values. (#694)

This branch includes the following new commits:

     new c9dd2d3  Doctest for PrimitiveArray using from_iter_values. (#694)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[arrow-rs] 01/01: Doctest for PrimitiveArray using from_iter_values. (#694)

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch cherry_pick_38e5d228
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git

commit c9dd2d348e5a7c1fc6207c67fea5e40c881605cf
Author: Navin <na...@novemberkilo.com>
AuthorDate: Fri Aug 20 06:45:54 2021 +1000

    Doctest for PrimitiveArray using from_iter_values. (#694)
    
    * Doctest for PrimitiveArray using from_iter_values.
    
    * Better example for building a PrimitiveArray.
---
 arrow/src/array/array_primitive.rs | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arrow/src/array/array_primitive.rs b/arrow/src/array/array_primitive.rs
index 9c14f88..5777a03 100644
--- a/arrow/src/array/array_primitive.rs
+++ b/arrow/src/array/array_primitive.rs
@@ -44,6 +44,19 @@ const MICROSECONDS: i64 = 1_000_000;
 const NANOSECONDS: i64 = 1_000_000_000;
 
 /// Array whose elements are of primitive types.
+///
+/// # Example: From an iterator of values
+///
+/// ```
+/// use arrow::array::{Array, PrimitiveArray};
+/// use arrow::datatypes::Int32Type;
+/// let arr: PrimitiveArray<Int32Type> = PrimitiveArray::from_iter_values((0..10).map(|x| x + 1));
+/// assert_eq!(10, arr.len());
+/// assert_eq!(0, arr.null_count());
+/// for i in 0..10i32 {
+///     assert_eq!(i + 1, arr.value(i as usize));
+/// }
+/// ```
 pub struct PrimitiveArray<T: ArrowPrimitiveType> {
     /// Underlying ArrayData
     /// # Safety