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/09/26 11:05:02 UTC

[arrow-rs] branch master updated: Doctests for DictionaryArrays. (#805)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new a1f48e8  Doctests for DictionaryArrays. (#805)
a1f48e8 is described below

commit a1f48e8debc1fbc0dd53af75a5e2a1916cb00050
Author: Navin <na...@novemberkilo.com>
AuthorDate: Sun Sep 26 21:04:57 2021 +1000

    Doctests for DictionaryArrays. (#805)
---
 arrow/src/array/mod.rs | 104 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)

diff --git a/arrow/src/array/mod.rs b/arrow/src/array/mod.rs
index 3775ffb..63b8b61 100644
--- a/arrow/src/array/mod.rs
+++ b/arrow/src/array/mod.rs
@@ -206,13 +206,117 @@ pub type Float32Array = PrimitiveArray<Float32Type>;
 /// ```
 pub type Float64Array = PrimitiveArray<Float64Type>;
 
+///
+/// A dictionary array where each element is a single value indexed by an integer key.
+///
+/// # Example: Using `collect`
+/// ```
+/// # use arrow::array::{Array, Int8DictionaryArray, Int8Array, StringArray};
+/// # use std::sync::Arc;
+///
+/// let array: Int8DictionaryArray = vec!["a", "a", "b", "c"].into_iter().collect();
+/// let values: Arc<dyn Array> = Arc::new(StringArray::from(vec!["a", "b", "c"]));
+/// assert_eq!(array.keys(), &Int8Array::from(vec![0, 0, 1, 2]));
+/// assert_eq!(array.values(), &values);
+/// ```
 pub type Int8DictionaryArray = DictionaryArray<Int8Type>;
+///
+/// A dictionary array where each element is a single value indexed by an integer key.
+///
+/// # Example: Using `collect`
+/// ```
+/// # use arrow::array::{Array, Int16DictionaryArray, Int16Array, StringArray};
+/// # use std::sync::Arc;
+///
+/// let array: Int16DictionaryArray = vec!["a", "a", "b", "c"].into_iter().collect();
+/// let values: Arc<dyn Array> = Arc::new(StringArray::from(vec!["a", "b", "c"]));
+/// assert_eq!(array.keys(), &Int16Array::from(vec![0, 0, 1, 2]));
+/// assert_eq!(array.values(), &values);
+/// ```
 pub type Int16DictionaryArray = DictionaryArray<Int16Type>;
+///
+/// A dictionary array where each element is a single value indexed by an integer key.
+///
+/// # Example: Using `collect`
+/// ```
+/// # use arrow::array::{Array, Int32DictionaryArray, Int32Array, StringArray};
+/// # use std::sync::Arc;
+///
+/// let array: Int32DictionaryArray = vec!["a", "a", "b", "c"].into_iter().collect();
+/// let values: Arc<dyn Array> = Arc::new(StringArray::from(vec!["a", "b", "c"]));
+/// assert_eq!(array.keys(), &Int32Array::from(vec![0, 0, 1, 2]));
+/// assert_eq!(array.values(), &values);
+/// ```
 pub type Int32DictionaryArray = DictionaryArray<Int32Type>;
+///
+/// A dictionary array where each element is a single value indexed by an integer key.
+///
+/// # Example: Using `collect`
+/// ```
+/// # use arrow::array::{Array, Int64DictionaryArray, Int64Array, StringArray};
+/// # use std::sync::Arc;
+///
+/// let array: Int64DictionaryArray = vec!["a", "a", "b", "c"].into_iter().collect();
+/// let values: Arc<dyn Array> = Arc::new(StringArray::from(vec!["a", "b", "c"]));
+/// assert_eq!(array.keys(), &Int64Array::from(vec![0, 0, 1, 2]));
+/// assert_eq!(array.values(), &values);
+/// ```
 pub type Int64DictionaryArray = DictionaryArray<Int64Type>;
+///
+/// A dictionary array where each element is a single value indexed by an integer key.
+///
+/// # Example: Using `collect`
+/// ```
+/// # use arrow::array::{Array, UInt8DictionaryArray, UInt8Array, StringArray};
+/// # use std::sync::Arc;
+///
+/// let array: UInt8DictionaryArray = vec!["a", "a", "b", "c"].into_iter().collect();
+/// let values: Arc<dyn Array> = Arc::new(StringArray::from(vec!["a", "b", "c"]));
+/// assert_eq!(array.keys(), &UInt8Array::from(vec![0, 0, 1, 2]));
+/// assert_eq!(array.values(), &values);
+/// ```
 pub type UInt8DictionaryArray = DictionaryArray<UInt8Type>;
+///
+/// A dictionary array where each element is a single value indexed by an integer key.
+///
+/// # Example: Using `collect`
+/// ```
+/// # use arrow::array::{Array, UInt16DictionaryArray, UInt16Array, StringArray};
+/// # use std::sync::Arc;
+///
+/// let array: UInt16DictionaryArray = vec!["a", "a", "b", "c"].into_iter().collect();
+/// let values: Arc<dyn Array> = Arc::new(StringArray::from(vec!["a", "b", "c"]));
+/// assert_eq!(array.keys(), &UInt16Array::from(vec![0, 0, 1, 2]));
+/// assert_eq!(array.values(), &values);
+/// ```
 pub type UInt16DictionaryArray = DictionaryArray<UInt16Type>;
+///
+/// A dictionary array where each element is a single value indexed by an integer key.
+///
+/// # Example: Using `collect`
+/// ```
+/// # use arrow::array::{Array, UInt32DictionaryArray, UInt32Array, StringArray};
+/// # use std::sync::Arc;
+///
+/// let array: UInt32DictionaryArray = vec!["a", "a", "b", "c"].into_iter().collect();
+/// let values: Arc<dyn Array> = Arc::new(StringArray::from(vec!["a", "b", "c"]));
+/// assert_eq!(array.keys(), &UInt32Array::from(vec![0, 0, 1, 2]));
+/// assert_eq!(array.values(), &values);
+/// ```
 pub type UInt32DictionaryArray = DictionaryArray<UInt32Type>;
+///
+/// A dictionary array where each element is a single value indexed by an integer key.
+///
+/// # Example: Using `collect`
+/// ```
+/// # use arrow::array::{Array, UInt64DictionaryArray, UInt64Array, StringArray};
+/// # use std::sync::Arc;
+///
+/// let array: UInt64DictionaryArray = vec!["a", "a", "b", "c"].into_iter().collect();
+/// let values: Arc<dyn Array> = Arc::new(StringArray::from(vec!["a", "b", "c"]));
+/// assert_eq!(array.keys(), &UInt64Array::from(vec![0, 0, 1, 2]));
+/// assert_eq!(array.values(), &values);
+/// ```
 pub type UInt64DictionaryArray = DictionaryArray<UInt64Type>;
 
 pub type TimestampSecondArray = PrimitiveArray<TimestampSecondType>;