-
Notifications
You must be signed in to change notification settings - Fork 816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation Improvements #4381
Conversation
@@ -317,6 +285,36 @@ | |||
//! assert_eq!(string.value(1), "foo"); | |||
//! ``` | |||
//! | |||
//! # Crate Topology |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is moved lower-down so that the first thing people see is how to use an array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good change
@@ -109,7 +77,7 @@ | |||
//! assert_eq!(min(&StringArray::from(vec!["b", "a", "c"])), Some("a")); | |||
//! ``` | |||
//! | |||
//! For more examples, and details consult the [arrow_array] docs. | |||
//! **For more examples, and details consult the [arrow_array] docs.** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very easy to miss, as it is sandwiched between a code block and heading. Making it bold helps avoid this
@@ -57,6 +57,8 @@ impl OffsetSizeTrait for i64 { | |||
/// An array of [variable length arrays](https://arrow.apache.org/docs/format/Columnar.html#variable-size-list-layout) | |||
/// | |||
/// See [`ListArray`] and [`LargeListArray`]` | |||
/// | |||
/// See [`GenericListBuilder`](crate::builder::GenericListBuilder) for how to construct a [`GenericListArray`] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the more complex types I opted to just point people to the builders, whilst the arrays can be constructed in other ways these necessarily require knowledge of how these types are structured, or are limited to a specific subset. I think it is better to just encourage people to use the builders as a first port of call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @tustvold -- the examples you updated are a great improvement, but removing the per-array type examples I feel pretty strongly is a step backwards for users (though it would certainly be easier to maintain)
/// # use arrow_array::{Array, BooleanArray}; | ||
/// let arr: BooleanArray = vec![true, true, false].into(); | ||
/// let values: Vec<_> = arr.iter().collect(); | ||
/// assert_eq!(&values, &[Some(true), Some(true), Some(false)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this assert adds anything to the doc example: I think it is already clear from the docs what the array contains.
/// let arr: BooleanArray = vec![true, true, false].into(); | ||
/// let values: Vec<_> = arr.iter().collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example seems unnecessarily complicated to me - why would we encourage this pattern instead of what was there
let arr = BooleanArray::from(vec![true, true, false])
@@ -57,6 +57,8 @@ impl OffsetSizeTrait for i64 { | |||
/// An array of [variable length arrays](https://arrow.apache.org/docs/format/Columnar.html#variable-size-list-layout) | |||
/// | |||
/// See [`ListArray`] and [`LargeListArray`]` | |||
/// | |||
/// See [`GenericListBuilder`](crate::builder::GenericListBuilder) for how to construct a [`GenericListArray`] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense 👍
@@ -317,6 +285,36 @@ | |||
//! assert_eq!(string.value(1), "foo"); | |||
//! ``` | |||
//! | |||
//! # Crate Topology |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌 very nice -- thank you @tustvold
/// assert_eq!(&array, &expected); | ||
/// ``` | ||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
/// assert_eq!(false, list2.as_any().downcast_ref::<Int32Array>().unwrap().is_valid(1)); | ||
/// assert_eq!(&[6, 7], list3.as_any().downcast_ref::<Int32Array>().unwrap().values()); | ||
/// ``` | ||
/// A [`GenericListArray`] of variable size lists, storing offsets as `i32`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add a link here to the builder too?
/// A [`GenericListArray`] of variable size lists, storing offsets as `i32`. | |
/// A [`GenericListArray`] of variable size lists, storing offsets as `i32`. | |
/// | |
/// See [`GenericListBuilder`](crate::builder::GenericListBuilder) for how to construct a [`GenericListArray`] |
/// assert_eq!(false, list2.as_any().downcast_ref::<Int32Array>().unwrap().is_valid(1)); | ||
/// assert_eq!(&[6, 7], list3.as_any().downcast_ref::<Int32Array>().unwrap().values()); | ||
/// ``` | ||
/// A [`GenericListArray`] of variable size lists, storing offsets as `i64`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// A [`GenericListArray`] of variable size lists, storing offsets as `i64`. | |
/// A [`GenericListArray`] of variable size lists, storing offsets as `i64`. | |
/// | |
/// See [`GenericListBuilder`](crate::builder::GenericListBuilder) for how to construct a [`GenericListArray`] |
pub type Decimal256Array = PrimitiveArray<Decimal256Type>; | ||
|
||
pub use crate::types::ArrowPrimitiveType; | ||
|
||
/// An array of [primitive values](https://arrow.apache.org/docs/format/Columnar.html#fixed-size-primitive-layout) | ||
/// | ||
/// # Example: From a Vec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are nice examples 👍
/// let arr: PrimitiveArray<Int32Type> = 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]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it worth pointing out that the 0
(for the null
locations) are arbitrary values?
Which issue does this PR close?
Part of #4071
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?