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

Function test_run_array

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

Source from the content-addressed store, hash-verified

1378
1379 #[test]
1380 fn test_run_array() -> Result<()> {
1381 let value_data =
1382 PrimitiveArray::<Int8Type>::from_iter_values([10_i8, 11, 12, 13, 14, 15, 16, 17]);
1383
1384 // Construct a run_ends array:
1385 let run_ends_values = [4_i32, 6, 7, 9, 13, 18, 20, 22];
1386 let run_ends_data =
1387 PrimitiveArray::<Int32Type>::from_iter_values(run_ends_values.iter().copied());
1388
1389 // Construct a run ends encoded array from the above two
1390 let ree_array = RunArray::<Int32Type>::try_new(&run_ends_data, &value_data).unwrap();
1391
1392 // export it
1393 let (array, schema) = to_ffi(&ree_array.to_data())?;
1394
1395 // (simulate consumer) import it
1396 let data = unsafe { from_ffi(array, &schema) }?;
1397 let array = make_array(data);
1398
1399 // perform some operation
1400 let array = array
1401 .as_any()
1402 .downcast_ref::<RunArray<Int32Type>>()
1403 .unwrap();
1404 assert_eq!(array.data_type(), ree_array.data_type());
1405 assert_eq!(array.run_ends().values(), ree_array.run_ends().values());
1406 assert_eq!(array.values(), ree_array.values());
1407
1408 Ok(())
1409 }
1410
1411 #[test]
1412 fn test_nullable_run_array() -> Result<()> {

Callers

nothing calls this directly

Calls 7

try_newFunction · 0.85
to_ffiFunction · 0.85
from_ffiFunction · 0.85
make_arrayFunction · 0.50
iterMethod · 0.45
to_dataMethod · 0.45
as_anyMethod · 0.45

Tested by

no test coverage detected