Skip to content

Commit 70094a5

Browse files
authored
expand docs for FixedSizeListArray (#4622)
* expand docs for FixedSizeListArray * mark nulls as ????
1 parent 399a3d1 commit 70094a5

1 file changed

Lines changed: 57 additions & 1 deletion

File tree

arrow-array/src/array/fixed_size_list_array.rs

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,60 @@ use arrow_schema::{ArrowError, DataType, FieldRef};
2626
use std::any::Any;
2727
use std::sync::Arc;
2828

29-
/// An array of [fixed size arrays](https://arrow.apache.org/docs/format/Columnar.html#fixed-size-list-layout)
29+
/// An array of [fixed length lists], similar to JSON arrays
30+
/// (e.g. `["A", "B"]`).
31+
///
32+
/// Lists are represented using a `values` child
33+
/// array where each list has a fixed size of `value_length`.
34+
///
35+
/// Use [`FixedSizeListBuilder`](crate::builder::FixedSizeListBuilder) to
36+
/// construct a [`FixedSizeListArray`].
37+
///
38+
/// # Representation
39+
///
40+
/// A [`FixedSizeListArray`] can represent a list of values of any other
41+
/// supported Arrow type. Each element of the `FixedSizeListArray` itself is
42+
/// a list which may contain NULL and non-null values,
43+
/// or may itself be NULL.
44+
///
45+
/// For example, this `FixedSizeListArray` stores lists of strings:
46+
///
47+
/// ```text
48+
/// ┌─────────────┐
49+
/// │ [A,B] │
50+
/// ├─────────────┤
51+
/// │ NULL │
52+
/// ├─────────────┤
53+
/// │ [C,NULL] │
54+
/// └─────────────┘
55+
/// ```
56+
///
57+
/// The `values` of this `FixedSizeListArray`s are stored in a child
58+
/// [`StringArray`] where logical null values take up `values_length` slots in the array
59+
/// as shown in the following diagram. The logical values
60+
/// are shown on the left, and the actual `FixedSizeListArray` encoding on the right
61+
///
62+
/// ```text
63+
/// ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐
64+
/// ┌ ─ ─ ─ ─ ─ ─ ─ ─┐
65+
/// ┌─────────────┐ │ ┌───┐ ┌───┐ ┌──────┐ │
66+
/// │ [A,B] │ │ 1 │ │ │ 1 │ │ A │ │ 0
67+
/// ├─────────────┤ │ ├───┤ ├───┤ ├──────┤ │
68+
/// │ NULL │ │ 0 │ │ │ 1 │ │ B │ │ 1
69+
/// ├─────────────┤ │ ├───┤ ├───┤ ├──────┤ │
70+
/// │ [C,NULL] │ │ 1 │ │ │ 0 │ │ ???? │ │ 2
71+
/// └─────────────┘ │ └───┘ ├───┤ ├──────┤ │
72+
/// | │ 0 │ │ ???? │ │ 3
73+
/// Logical Values │ Validity ├───┤ ├──────┤ │
74+
/// (nulls) │ │ 1 │ │ C │ │ 4
75+
/// │ ├───┤ ├──────┤ │
76+
/// │ │ 0 │ │ ???? │ │ 5
77+
/// │ └───┘ └──────┘ │
78+
/// │ Values │
79+
/// │ FixedSizeListArray (Array) │
80+
/// └ ─ ─ ─ ─ ─ ─ ─ ─┘
81+
/// └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
82+
/// ```
3083
///
3184
/// # Example
3285
///
@@ -60,6 +113,9 @@ use std::sync::Arc;
60113
/// assert_eq!( &[3, 4, 5], list1.as_any().downcast_ref::<Int32Array>().unwrap().values());
61114
/// assert_eq!( &[6, 7, 8], list2.as_any().downcast_ref::<Int32Array>().unwrap().values());
62115
/// ```
116+
///
117+
/// [`StringArray`]: crate::array::StringArray
118+
/// [fixed size arrays](https://arrow.apache.org/docs/format/Columnar.html#fixed-size-list-layout)
63119
#[derive(Clone)]
64120
pub struct FixedSizeListArray {
65121
data_type: DataType, // Must be DataType::FixedSizeList(value_length)

0 commit comments

Comments
 (0)