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

Function test_null_count_handling

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

Source from the content-addressed store, hash-verified

723
724 #[test]
725 fn test_null_count_handling() {
726 let int32_data = ArrayData::builder(DataType::Int32)
727 .len(10)
728 .add_buffer(Buffer::from_slice_ref([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]))
729 .null_bit_buffer(Some(Buffer::from([0b01011111, 0b00000001])))
730 .build()
731 .unwrap();
732 let mut ffi_array = FFI_ArrowArray::new(&int32_data);
733 assert_eq!(3, ffi_array.null_count());
734 assert_eq!(Some(3), ffi_array.null_count_opt());
735 // Simulating uninitialized state
736 unsafe {
737 ffi_array.set_null_count(-1);
738 }
739 assert_eq!(None, ffi_array.null_count_opt());
740 let int32_data = unsafe { from_ffi_and_data_type(ffi_array, DataType::Int32) }.unwrap();
741 assert_eq!(3, int32_data.null_count());
742
743 let null_data = &ArrayData::new_null(&DataType::Null, 10);
744 let mut ffi_array = FFI_ArrowArray::new(null_data);
745 assert_eq!(10, ffi_array.null_count());
746 assert_eq!(Some(10), ffi_array.null_count_opt());
747 // Simulating uninitialized state
748 unsafe {
749 ffi_array.set_null_count(-1);
750 }
751 assert_eq!(None, ffi_array.null_count_opt());
752 let null_data = unsafe { from_ffi_and_data_type(ffi_array, DataType::Null) }.unwrap();
753 assert_eq!(0, null_data.null_count());
754 }
755
756 fn test_generic_string<Offset: OffsetSizeTrait>() -> Result<()> {
757 // create an array natively

Callers

nothing calls this directly

Calls 6

from_ffi_and_data_typeFunction · 0.85
add_bufferMethod · 0.80
buildMethod · 0.45
null_bit_bufferMethod · 0.45
lenMethod · 0.45
set_null_countMethod · 0.45

Tested by

no test coverage detected