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

Function test_slice_memory_size

arrow-data/src/data.rs:2574–2607  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2572
2573 #[test]
2574 fn test_slice_memory_size() {
2575 let mut bit_v: [u8; 2] = [0; 2];
2576 bit_util::set_bit(&mut bit_v, 0);
2577 bit_util::set_bit(&mut bit_v, 3);
2578 bit_util::set_bit(&mut bit_v, 10);
2579 let data = ArrayData::builder(DataType::Int32)
2580 .len(16)
2581 .add_buffer(make_i32_buffer(16))
2582 .null_bit_buffer(Some(Buffer::from(bit_v)))
2583 .build()
2584 .unwrap();
2585 let new_data = data.slice(1, 14);
2586 assert_eq!(
2587 data.get_slice_memory_size().unwrap() - 8,
2588 new_data.get_slice_memory_size().unwrap()
2589 );
2590 let data_buffer = Buffer::from_slice_ref("abcdef".as_bytes());
2591 let offsets_buffer = Buffer::from_slice_ref([0_i32, 2_i32, 2_i32, 5_i32]);
2592 let string_data = ArrayData::try_new(
2593 DataType::Utf8,
2594 3,
2595 Some(Buffer::from_iter(vec![true, false, true])),
2596 0,
2597 vec![offsets_buffer, data_buffer],
2598 vec![],
2599 )
2600 .unwrap();
2601 let string_data_slice = string_data.slice(1, 2);
2602 //4 bytes of offset and 2 bytes of data reduced by slicing.
2603 assert_eq!(
2604 string_data.get_slice_memory_size().unwrap() - 6,
2605 string_data_slice.get_slice_memory_size().unwrap()
2606 );
2607 }
2608
2609 #[test]
2610 fn test_count_nulls() {

Callers

nothing calls this directly

Calls 10

set_bitFunction · 0.85
try_newFunction · 0.85
add_bufferMethod · 0.80
make_i32_bufferFunction · 0.70
from_iterFunction · 0.50
buildMethod · 0.45
null_bit_bufferMethod · 0.45
lenMethod · 0.45
sliceMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected