Problem
TransformSortMergeLimit compacts retained DataBlocks after heap cursors have been built. With string sort keys, cursor rows can keep the pre-compaction StringView backing buffers alive while num_bytes reflects only the compacted block. This can understate the resident memory used by local Top-N.
Follow-up to #20186.
Follow-up
- Track cursor-held row memory per retained input block, or rebuild cursors from compacted sort rows.
- Remove the corresponding accounting when a block is evicted, and reset it when the heap is drained.
- Add regression coverage with synthetic sparse StringView sort keys.
- Preserve the no-copy fast paths for discarded, dense, and non-string blocks.
- Verify that spill decisions use the full retained-memory estimate.
Problem
TransformSortMergeLimitcompacts retainedDataBlocks after heap cursors have been built. With string sort keys, cursor rows can keep the pre-compaction StringView backing buffers alive whilenum_bytesreflects only the compacted block. This can understate the resident memory used by local Top-N.Follow-up to #20186.
Follow-up