tustvold commented on code in PR #1912: URL: https://github.com/apache/arrow-rs/pull/1912#discussion_r901284237
########## 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: Panicking should be fine, it's a validation failure if the array contains negative indexes. TBH I keep meaning to change all these checked conversions to numeric casts (i.e. as), I wouldn't be surprised if this leads to non-trivial performance benefits. -- 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-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org