You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ne...@apache.org on 2022/02/19 16:02:33 UTC
[arrow-rs] branch master updated: Clean up DictionaryArray construction in test (#1314)
This is an automated email from the ASF dual-hosted git repository.
nevime 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 193b64c Clean up DictionaryArray construction in test (#1314)
193b64c is described below
commit 193b64c69f0560a1a01ae4c04004b81afb02fab6
Author: Andrew Lamb <an...@nerdnetworks.org>
AuthorDate: Sat Feb 19 11:02:28 2022 -0500
Clean up DictionaryArray construction in test (#1314)
---
arrow/src/array/array_dictionary.rs | 25 ++++---------------------
1 file changed, 4 insertions(+), 21 deletions(-)
diff --git a/arrow/src/array/array_dictionary.rs b/arrow/src/array/array_dictionary.rs
index 57153f1..7e82ad2 100644
--- a/arrow/src/array/array_dictionary.rs
+++ b/arrow/src/array/array_dictionary.rs
@@ -302,6 +302,7 @@ mod tests {
use super::*;
use crate::array::Int8Array;
+ use crate::datatypes::Int16Type;
use crate::{
array::Int16DictionaryArray, array::PrimitiveDictionaryBuilder,
datatypes::DataType,
@@ -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();
let mut key_iter = dict_array.keys_iter();
assert_eq!(2, key_iter.next().unwrap().unwrap());