QinXi-ai opened a new pull request, #27990:
URL: https://github.com/apache/datafusion/pull/27990

   ## Which issue does this PR close?
   
   Stacked on #27299. The [follow-up 
commit](https://github.com/QinXi-ai/datafusion/commit/c12035a4add639941ea19c707f10e614b2c05013)
 addresses [the partial-emission review 
suggestion](https://github.com/apache/datafusion/pull/27299#discussion_r4783027938).
   
   ## Rationale for this change
   
   When the grouped integer `COUNT(DISTINCT)` accumulator emits a prefix, it 
returns the counts and discards the corresponding inline first values. For a 
short prefix, `take_needed` allocates a vector for values that are immediately 
dropped.
   
   ## What changes are included in this PR?
   
   Drain the inline prefix in place when it contains at most half of the 
groups. For a larger prefix, keep the smaller tail with `split_off` so the old 
allocation can be released.
   
   ## What is the testing strategy for this PR?
   
   `partial_evaluation_keeps_first_values_aligned` exercises a partial emission 
followed by updates to the remaining groups. The 10 `aggregate::count_distinct` 
unit tests passed. A local allocation counter around 
`evaluate(EmitTo::First(256))` on 65,536 singleton `Int64` groups measured 4 
allocation calls and 4,264 bytes on the parent commit, and 3 calls and 2,216 
bytes on this commit. Emitting 60,000 groups took 4 allocations on both 
versions and retained the same capacity. Both runs checked the emitted and 
remaining counts.
   
   ## Are there any user-facing changes?
   
   No SQL or output changes.
   


-- 
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