MCPcopy Create free account
hub / github.com/apache/arrow-rs / test_dictionary_iter

Function test_dictionary_iter

arrow-array/src/array/dictionary_array.rs:1288–1313  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1286
1287 #[test]
1288 fn test_dictionary_iter() {
1289 // Construct a value array
1290 let values = Int8Array::from_iter_values([10_i8, 11, 12, 13, 14, 15, 16, 17]);
1291 let keys = Int16Array::from_iter_values([2_i16, 3, 4]);
1292
1293 // Construct a dictionary array from the above two
1294 let dict_array = DictionaryArray::new(keys, Arc::new(values));
1295
1296 let mut key_iter = dict_array.keys_iter();
1297 assert_eq!(2, key_iter.next().unwrap().unwrap());
1298 assert_eq!(3, key_iter.next().unwrap().unwrap());
1299 assert_eq!(4, key_iter.next().unwrap().unwrap());
1300 assert!(key_iter.next().is_none());
1301
1302 let mut iter = dict_array
1303 .values()
1304 .as_any()
1305 .downcast_ref::<Int8Array>()
1306 .unwrap()
1307 .take_iter(dict_array.keys_iter());
1308
1309 assert_eq!(12, iter.next().unwrap().unwrap());
1310 assert_eq!(13, iter.next().unwrap().unwrap());
1311 assert_eq!(14, iter.next().unwrap().unwrap());
1312 assert!(iter.next().is_none());
1313 }
1314
1315 #[test]
1316 fn test_dictionary_iter_with_null() {

Callers

nothing calls this directly

Calls 4

keys_iterMethod · 0.80
take_iterMethod · 0.45
as_anyMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected