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

Function test_gc_huge_array

arrow-array/src/array/byte_view_array.rs:1515–1561  ·  view source on GitHub ↗

Takes too long

()

Source from the content-addressed store, hash-verified

1513 #[test]
1514 #[cfg_attr(miri, ignore)] // Takes too long
1515 fn test_gc_huge_array() {
1516 // Construct multiple 128 MiB BinaryView entries so total > 4 GiB
1517 let block_len: usize = 128 * 1024 * 1024; // 128 MiB per view
1518 let num_views: usize = 36;
1519
1520 // Create a single 128 MiB data block with a simple byte pattern
1521 let buffer = Buffer::from_vec(vec![0xAB; block_len]);
1522 let buffer2 = Buffer::from_vec(vec![0xFF; block_len]);
1523
1524 // Append this block and then add many views pointing to it
1525 let mut builder = BinaryViewBuilder::new();
1526 let block_id = builder.append_block(buffer);
1527 for _ in 0..num_views / 2 {
1528 builder
1529 .try_append_view(block_id, 0, block_len as u32)
1530 .expect("append view into 128MiB block");
1531 }
1532 let block_id2 = builder.append_block(buffer2);
1533 for _ in 0..num_views / 2 {
1534 builder
1535 .try_append_view(block_id2, 0, block_len as u32)
1536 .expect("append view into 128MiB block");
1537 }
1538
1539 let array = builder.finish();
1540 let total = array.total_buffer_bytes_used();
1541 assert!(
1542 total > u32::MAX as usize,
1543 "Expected total non-inline bytes to exceed 4 GiB, got {}",
1544 total
1545 );
1546
1547 // Run gc and verify correctness
1548 let gced = array.gc();
1549 assert_eq!(gced.len(), num_views, "Length mismatch after gc");
1550 assert_eq!(gced.null_count(), 0, "Null count mismatch after gc");
1551 assert_ne!(
1552 gced.data_buffers().len(),
1553 1,
1554 "gc with huge buffer should not consolidate data into a single buffer"
1555 );
1556
1557 // Element-wise equality check across the entire array
1558 array.iter().zip(gced.iter()).for_each(|(orig, got)| {
1559 assert_eq!(orig, got, "Value mismatch after gc on huge array");
1560 });
1561 }
1562
1563 #[test]
1564 fn test_eq() {

Callers

nothing calls this directly

Calls 7

try_append_viewMethod · 0.80
gcMethod · 0.80
zipMethod · 0.80
append_blockMethod · 0.45
finishMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected