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

Function _bit_length_dictionary

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

Source from the content-addressed store, hash-verified

784 }
785
786 fn _bit_length_dictionary<K: ArrowDictionaryKeyType>() {
787 const TOTAL: i32 = 100;
788
789 let v = ["aaaa", "bb", "ccccc", "ddd", "eeeeee"];
790 let data: Vec<Option<&str>> = (0..TOTAL)
791 .map(|n| {
792 let i = n % 5;
793 if i == 3 { None } else { Some(v[i as usize]) }
794 })
795 .collect();
796
797 let dict_array: DictionaryArray<K> = data.clone().into_iter().collect();
798
799 let expected: Vec<Option<i32>> = data
800 .iter()
801 .map(|opt| opt.map(|s| (s.chars().count() * 8) as i32))
802 .collect();
803
804 let res = bit_length(&dict_array).unwrap();
805 let actual = res.as_any().downcast_ref::<DictionaryArray<K>>().unwrap();
806 let actual: Vec<Option<i32>> = actual
807 .values()
808 .as_any()
809 .downcast_ref::<Int32Array>()
810 .unwrap()
811 .take_iter(dict_array.keys_iter())
812 .collect();
813
814 for i in 0..TOTAL as usize {
815 assert_eq!(expected[i], actual[i],);
816 }
817 }
818
819 #[test]
820 fn test_fixed_size_list_length() {

Callers

nothing calls this directly

Calls 10

bit_lengthFunction · 0.85
collectMethod · 0.80
keys_iterMethod · 0.80
into_iterMethod · 0.45
cloneMethod · 0.45
iterMethod · 0.45
countMethod · 0.45
as_anyMethod · 0.45
take_iterMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected