Skip to content

Commit

Permalink
minor: add a diagram to docstring for DictionaryArray (#1909)
Browse files Browse the repository at this point in the history
* minor: add a diagram to docstring for DictionaryArray

* minor: clarify docstring on `DictionaryArray::lookup_key`

* Apply suggestions from code review

Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
Co-authored-by: Jörn Horstmann <git@jhorstmann.net>

* make values smaller and keys larger

Co-authored-by: Wakahisa <nevilledips@gmail.com>
Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
Co-authored-by: Jörn Horstmann <git@jhorstmann.net>
  • Loading branch information
4 people committed Jun 21, 2022
1 parent aee2628 commit 50a9dd5
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions arrow/src/array/array_dictionary.rs
Expand Up @@ -33,6 +33,34 @@ use crate::error::Result;
/// This is mostly used to represent strings or a limited set of primitive types as integers,
/// for example when doing NLP analysis or representing chromosomes by name.
///
/// [`DictionaryArray`] are represented using a `keys` array and a
/// `values` array, which may be different lengths. The `keys` array
/// stores indexes in the `values` array which holds
/// the corresponding logical value, as shown here:
///
/// ```text
/// ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
/// ┌─────────────────┐ ┌─────────┐ │ ┌─────────────────┐
/// │ │ A │ │ 0 │ │ A │ values[keys[0]]
/// ├─────────────────┤ ├─────────┤ │ ├─────────────────┤
/// │ │ D │ │ 2 │ │ B │ values[keys[1]]
/// ├─────────────────┤ ├─────────┤ │ ├─────────────────┤
/// │ │ B │ │ 2 │ │ B │ values[keys[2]]
/// └─────────────────┘ ├─────────┤ │ ├─────────────────┤
/// │ │ 1 │ │ D │ values[keys[3]]
/// ├─────────┤ │ ├─────────────────┤
/// │ │ 1 │ │ D │ values[keys[4]]
/// ├─────────┤ │ ├─────────────────┤
/// │ │ 0 │ │ A │ values[keys[5]]
/// └─────────┘ │ └─────────────────┘
/// │ values keys
/// ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
/// Logical array
/// Contents
/// DictionaryArray
/// length = 6
/// ```
///
/// Example **with nullable** data:
///
/// ```
Expand Down

0 comments on commit 50a9dd5

Please sign in to comment.