JonSnow1807 commented on code in PR #12113:
URL: https://github.com/apache/arrow-rs/pull/12113#discussion_r4503220885
##########
arrow-row/src/lib.rs:
##########
@@ -3387,6 +3456,92 @@ mod tests {
dictionary_eq(&decoded[0], &expected);
}
+ #[test]
+ fn test_gather_dictionary_byte_values() {
Review Comment:
Thanks for reviewing this. I’ve simplified
test_gather_dictionary_byte_values to use StringArray, since the string and
binary variants share the same gather implementation. The test still covers
sliced keys, null keys, and keys that reference null dictionary values.
##########
arrow-row/src/lib.rs:
##########
@@ -2293,6 +2296,72 @@ pub fn encode_dictionary_values<K:
ArrowDictionaryKeyType>(
fn gather_dictionary_values<K: ArrowDictionaryKeyType>(
array: &DictionaryArray<K>,
+) -> Result<ArrayRef, ArrowError> {
+ let values = array.values();
+ match values.data_type() {
+ DataType::Utf8 => gather_dictionary_byte_values::<K, Utf8Type>(
+ array,
+ values.as_any().downcast_ref::<StringArray>().unwrap(),
+ ),
+ DataType::LargeUtf8 => gather_dictionary_byte_values::<K,
LargeUtf8Type>(
+ array,
+ values.as_any().downcast_ref::<LargeStringArray>().unwrap(),
+ ),
+ DataType::Binary => gather_dictionary_byte_values::<K, BinaryType>(
+ array,
+ values.as_any().downcast_ref::<BinaryArray>().unwrap(),
+ ),
+ DataType::LargeBinary => gather_dictionary_byte_values::<K,
LargeBinaryType>(
+ array,
+ values.as_any().downcast_ref::<LargeBinaryArray>().unwrap(),
+ ),
+ _ => gather_dictionary_values_generic(array),
+ }
+}
+
+fn gather_dictionary_byte_values<K: ArrowDictionaryKeyType, T: ByteArrayType>(
Review Comment:
Added a short doc comment to gather_dictionary_byte_values. It explains how
the helper gathers values in dictionary-key order, preserves nulls, and returns
an error if the accumulated offsets overflow.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]