You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/06/21 12:43:02 UTC

[GitHub] [arrow-rs] alamb commented on a diff in pull request #1912: Add `DictionaryArray::key` function

alamb commented on code in PR #1912:
URL: https://github.com/apache/arrow-rs/pull/1912#discussion_r902570390


##########
arrow/src/array/array_dictionary.rs:
##########
@@ -169,6 +169,17 @@ impl<'a, K: ArrowPrimitiveType> DictionaryArray<K> {
             .iter()
             .map(|key| key.map(|k| k.to_usize().expect("Dictionary index not usize")))
     }
+
+    /// Return the value of `keys` (the dictionary key) at index `i`,
+    /// cast to `usize`, `None` if the value at `i` is `NULL`.
+    pub fn key(&self, i: usize) -> Option<usize> {
+        self.keys.is_valid(i).then(|| {
+            self.keys
+                .value(i)
+                .to_usize()
+                .expect("Dictionary index not usize")

Review Comment:
   Filed https://github.com/apache/arrow-rs/issues/1918 to track



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org