viirya commented on a change in pull request #1314:
URL: https://github.com/apache/arrow-rs/pull/1314#discussion_r807301627
##########
File path: arrow/src/array/array_dictionary.rs
##########
@@ -472,29 +473,11 @@ mod tests {
#[test]
fn test_dictionary_iter() {
// Construct a value array
- let value_data = ArrayData::builder(DataType::Int8)
- .len(8)
- .add_buffer(Buffer::from(
- &[10_i8, 11, 12, 13, 14, 15, 16, 17].to_byte_slice(),
- ))
- .build()
- .unwrap();
-
- // Construct a buffer for value offsets, for the nested array:
- let keys = Buffer::from(&[2_i16, 3, 4].to_byte_slice());
+ let values = Int8Array::from_iter_values([10_i8, 11, 12, 13, 14, 15,
16, 17]);
+ let keys = Int16Array::from_iter_values([2_i16, 3, 4]);
// Construct a dictionary array from the above two
- let key_type = DataType::Int16;
- let value_type = DataType::Int8;
- let dict_data_type =
- DataType::Dictionary(Box::new(key_type), Box::new(value_type));
- let dict_data = ArrayData::builder(dict_data_type)
- .len(3)
- .add_buffer(keys)
- .add_child_data(value_data)
- .build()
- .unwrap();
- let dict_array = Int16DictionaryArray::from(dict_data);
+ let dict_array = DictionaryArray::<Int16Type>::try_new(&keys,
&values).unwrap();
Review comment:
nice :thumbsup:
--
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]