kosiew opened a new pull request, #26286:
URL: https://github.com/apache/datafusion/pull/26286

   ## Which issue does this PR close?
   
   - Part of #23393
   
   ## Rationale for this change
   
   `TopK` underreports retained memory when a common sort prefix is present 
because its memory accounting omits the optional 
`common_sort_prefix_converter`. This can cause memory reservations to 
underestimate TopK's retained memory, weakening memory-limit enforcement.
   
   ## What changes are included in this PR?
   
   - Include `common_sort_prefix_converter.size()` exactly once in 
`TopK::size()` when the converter is present.
   - Preserve the existing size calculation when the converter is absent.
   - Add a regression test covering both construction paths and checking that 
the memory reservation matches the reported size after batch insertion.
   
   ## Are these changes tested?
   
   Added `test_topk_size_common_sort_prefix_converter`, which verifies:
   
   - A common-prefix converter is created and reports a nonzero size.
   - Without a common prefix, `TopK::size()` retains its existing formula.
   - With a common prefix, the reported size increases by the converter's size.
   - After `insert_batch()`, the memory reservation matches `TopK::size()`.
   
   The test does not rely on global allocator measurements.
   
   ## Are there any user-facing changes?
   
   No changes to query results or public APIs. The change corrects internal 
memory accounting for TopK with a common sort prefix, potentially improving 
memory-limit enforcement.
   
   ## LLM-generated code disclosure
   
   This PR includes LLM-generated code and comments. All LLM-generated content 
has been manually reviewed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to