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

Function test_nullable_run_array

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

Source from the content-addressed store, hash-verified

1410
1411 #[test]
1412 fn test_nullable_run_array() -> Result<()> {
1413 let nulls = NullBuffer::from(vec![true, false, true, true, false]);
1414 let value_data =
1415 PrimitiveArray::<Int8Type>::new(vec![1_i8, 2, 3, 4, 5].into(), Some(nulls));
1416
1417 // Construct a run_ends array:
1418 let run_ends_values = [5_i32, 6, 7, 8, 10];
1419 let run_ends_data =
1420 PrimitiveArray::<Int32Type>::from_iter_values(run_ends_values.iter().copied());
1421
1422 // Construct a run ends encoded array from the above two
1423 let ree_array = RunArray::<Int32Type>::try_new(&run_ends_data, &value_data).unwrap();
1424
1425 // export it
1426 let (array, schema) = to_ffi(&ree_array.to_data())?;
1427
1428 // (simulate consumer) import it
1429 let data = unsafe { from_ffi(array, &schema) }?;
1430 let array = make_array(data);
1431
1432 // perform some operation
1433 let array = array
1434 .as_any()
1435 .downcast_ref::<RunArray<Int32Type>>()
1436 .unwrap();
1437 assert_eq!(array.data_type(), ree_array.data_type());
1438 assert_eq!(array.run_ends().values(), ree_array.run_ends().values());
1439 assert_eq!(array.values(), ree_array.values());
1440
1441 Ok(())
1442 }
1443}
1444
1445#[cfg(test)]

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