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

Function test_dictionary

arrow-array/src/ffi.rs:1129–1152  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1127
1128 #[test]
1129 fn test_dictionary() -> Result<()> {
1130 // create an array natively
1131 let values = vec!["a", "aaa", "aaa"];
1132 let dict_array: DictionaryArray<Int8Type> = values.into_iter().collect();
1133
1134 // export it
1135 let (array, schema) = to_ffi(&dict_array.to_data())?;
1136
1137 // (simulate consumer) import it
1138 let data = unsafe { from_ffi(array, &schema) }?;
1139 let array = make_array(data);
1140 let actual = array
1141 .as_any()
1142 .downcast_ref::<DictionaryArray<Int8Type>>()
1143 .unwrap();
1144
1145 // verify
1146 let new_values = vec!["a", "aaa", "aaa"];
1147 let expected: DictionaryArray<Int8Type> = new_values.into_iter().collect();
1148 assert_eq!(actual, &expected);
1149
1150 // (drop/release)
1151 Ok(())
1152 }
1153
1154 #[test]
1155 #[allow(deprecated)]

Callers

nothing calls this directly

Calls 9

to_ffiFunction · 0.85
from_ffiFunction · 0.85
collectMethod · 0.80
test_round_tripFunction · 0.70
make_arrayFunction · 0.50
into_iterMethod · 0.45
to_dataMethod · 0.45
as_anyMethod · 0.45
into_dataMethod · 0.45

Tested by

no test coverage detected