Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Jun 8, 2023
1 parent 5f801d4 commit 161c22f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
19 changes: 9 additions & 10 deletions arrow-array/src/array/byte_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ use std::sync::Arc;
/// # Example: From a Vec
///
/// ```
/// # use arrow_array::{Array, GenericByteArray, types::Utf8Type};
/// let arr: GenericByteArray<Utf8Type> = vec!["hello", "world", ""].into();
/// # use arrow_array::{Array, StringArray};
/// let arr: StringArray = vec!["hello", "world", ""].into();
/// assert_eq!(arr.value_data(), b"helloworld");
/// assert_eq!(arr.value_offsets(), &[0, 5, 10, 10]);
/// let values: Vec<_> = arr.iter().collect();
Expand All @@ -48,19 +48,19 @@ use std::sync::Arc;
/// # Example: From an optional Vec
///
/// ```
/// # use arrow_array::{Array, GenericByteArray, types::Utf8Type};
/// let arr: GenericByteArray<Utf8Type> = vec![Some("hello"), Some("world"), Some(""), None].into();
/// # use arrow_array::{Array, BinaryArray, types::Utf8Type};
/// let arr: BinaryArray = vec![Some(&b"hello"[..]), Some(&b"world"[..]), Some(&b""[..]), None].into();
/// assert_eq!(arr.value_data(), b"helloworld");
/// assert_eq!(arr.value_offsets(), &[0, 5, 10, 10, 10]);
/// let values: Vec<_> = arr.iter().collect();
/// assert_eq!(values, &[Some("hello"), Some("world"), Some(""), None]);
/// assert_eq!(values, &[Some(&b"hello"[..]), Some(&b"world"[..]), Some(&b""[..]), None]);
/// ```
///
/// # Example: From an iterator of option
///
/// ```
/// # use arrow_array::{Array, GenericByteArray, types::Utf8Type};
/// let arr: GenericByteArray<Utf8Type> = (0..5).map(|x| (x % 2 == 0).then(|| x.to_string())).collect();
/// # use arrow_array::{Array, LargeStringArray};
/// let arr: LargeStringArray = (0..5).map(|x| (x % 2 == 0).then(|| x.to_string())).collect();
/// let values: Vec<_> = arr.iter().collect();
/// assert_eq!(values, &[Some("0"), None, Some("2"), None, Some("4")]);
/// ```
Expand All @@ -69,9 +69,8 @@ use std::sync::Arc;
///
/// ```
/// # use arrow_array::Array;
/// # use arrow_array::builder::GenericByteBuilder;
/// # use arrow_array::types::Utf8Type;
/// let mut builder = GenericByteBuilder::<Utf8Type>::new();
/// # use arrow_array::builder::StringBuilder;
/// let mut builder = StringBuilder::new();
/// builder.append_value("hello");
/// builder.append_null();
/// builder.append_value("world");
Expand Down
25 changes: 12 additions & 13 deletions arrow-array/src/array/primitive_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ pub use crate::types::ArrowPrimitiveType;
/// # Example: From a Vec
///
/// ```
/// # use arrow_array::{Array, PrimitiveArray, types::Int32Type};
/// let arr: PrimitiveArray<Int32Type> = vec![1, 2, 3, 4].into();
/// # use arrow_array::{Array, Int32Array};
/// let arr: Int32Array = vec![1, 2, 3, 4].into();
/// assert_eq!(4, arr.len());
/// assert_eq!(0, arr.null_count());
/// assert_eq!(arr.values(), &[1, 2, 3, 4])
Expand All @@ -210,30 +210,30 @@ pub use crate::types::ArrowPrimitiveType;
/// # Example: From an optional Vec
///
/// ```
/// # use arrow_array::{Array, PrimitiveArray, types::Int32Type};
/// let arr: PrimitiveArray<Int32Type> = vec![Some(1), None, Some(3), None].into();
/// # use arrow_array::{Array, Float32Array};
/// let arr: Float32Array = vec![Some(1.), None, Some(3.), None].into();
/// assert_eq!(4, arr.len());
/// assert_eq!(2, arr.null_count());
/// assert_eq!(arr.values(), &[1, 0, 3, 0])
/// assert_eq!(arr.values(), &[1., 0., 3., 0.])
/// ```
///
/// # Example: From an iterator of values
///
/// ```
/// # use arrow_array::{Array, PrimitiveArray, types::Int32Type};
/// let arr: PrimitiveArray<Int32Type> = (0..10).map(|x| x + 1).collect();
/// # use arrow_array::{Array, Int8Array};
/// let arr: Int8Array = (0..10).map(|x| x + 1).collect();
/// assert_eq!(10, arr.len());
/// assert_eq!(0, arr.null_count());
/// for i in 0..10i32 {
/// for i in 0..10 {
/// assert_eq!(i + 1, arr.value(i as usize));
/// }
/// ```
///
/// # Example: From an iterator of option
///
/// ```
/// # use arrow_array::{Array, PrimitiveArray, types::Int32Type};
/// let arr: PrimitiveArray<Int32Type> = (0..10).map(|x| (x % 2 == 0).then_some(x)).collect();
/// # use arrow_array::{Array, UInt32Array};
/// let arr: UInt32Array = (0..10).map(|x| (x % 2 == 0).then_some(x)).collect();
/// assert_eq!(10, arr.len());
/// assert_eq!(5, arr.null_count());
/// assert_eq!(arr.values(), &[0, 0, 2, 0, 4, 0, 6, 0, 8, 0])
Expand All @@ -243,9 +243,8 @@ pub use crate::types::ArrowPrimitiveType;
///
/// ```
/// # use arrow_array::Array;
/// # use arrow_array::builder::PrimitiveBuilder;
/// # use arrow_array::types::Int32Type;
/// let mut builder = PrimitiveBuilder::<Int32Type>::new();
/// # use arrow_array::builder::Int64Builder;
/// let mut builder = Int64Builder::new();
/// builder.append_value(1);
/// builder.append_null();
/// builder.append_value(2);
Expand Down

0 comments on commit 161c22f

Please sign in to comment.