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

Function _length_dictionary

arrow-string/src/length.rs:743–772  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

741 }
742
743 fn _length_dictionary<K: ArrowDictionaryKeyType>() {
744 const TOTAL: i32 = 100;
745
746 let v = ["aaaa", "bb", "ccccc", "ddd", "eeeeee"];
747 let data: Vec<Option<&str>> = (0..TOTAL)
748 .map(|n| {
749 let i = n % 5;
750 if i == 3 { None } else { Some(v[i as usize]) }
751 })
752 .collect();
753
754 let dict_array: DictionaryArray<K> = data.clone().into_iter().collect();
755
756 let expected: Vec<Option<i32>> =
757 data.iter().map(|opt| opt.map(|s| s.len() as i32)).collect();
758
759 let res = length(&dict_array).unwrap();
760 let actual = res.as_any().downcast_ref::<DictionaryArray<K>>().unwrap();
761 let actual: Vec<Option<i32>> = actual
762 .values()
763 .as_any()
764 .downcast_ref::<Int32Array>()
765 .unwrap()
766 .take_iter(dict_array.keys_iter())
767 .collect();
768
769 for i in 0..TOTAL as usize {
770 assert_eq!(expected[i], actual[i],);
771 }
772 }
773
774 #[test]
775 fn bit_length_dictionary() {

Callers

nothing calls this directly

Calls 10

lengthFunction · 0.85
collectMethod · 0.80
keys_iterMethod · 0.80
into_iterMethod · 0.45
cloneMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45
as_anyMethod · 0.45
take_iterMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected