BiteTheDDDDt opened a new pull request, #57683:
URL: https://github.com/apache/doris/pull/57683

   ### What problem does this PR solve?
   Currently, the number of our wait_channel_timers corresponds to the number 
of `channels`. After the modifications in this PR, the number of 
wait_channel_timers will align with the number of `local channels`, thereby 
reducing unnecessary timer generation.
   
   This pull request refactors and improves code readability and safety in the 
`exchange_sink_operator.cpp` file by modernizing loop constructs, improving 
memory management, and enhancing error handling. The changes mainly focus on 
using range-based loops, smart pointers, and clearer logic for managing channel 
dependencies and timers.
   
   **Code modernization and safety improvements:**
   
   * Replaced traditional for-loops with range-based for-loops for iterating 
over `channels`, improving readability and reducing indexing errors in multiple 
methods (`init`, `open`). 
[[1]](diffhunk://#diff-70038347289359e40966cf399f9a4165f6423f3634ceb13d496da4d4627ce073L85-R86)
 
[[2]](diffhunk://#diff-70038347289359e40966cf399f9a4165f6423f3634ceb13d496da4d4627ce073L217-R217)
   * Updated memory management for `_writer` by switching from manual `reset` 
with `new` to `std::make_unique`, ensuring exception safety and clarity.
   * Used `contains` method instead of `find` for map lookups in 
`_create_channels`, making the code more concise and modern.
   * Changed range-based loop in the constructor to use `const auto&` for 
safety and clarity.
   
   **Dependency and error handling improvements:**
   
   * Added a null pointer check for local channel dependencies and improved 
timer management, ensuring that dependencies are valid and timers are only 
added for non-null dependencies.
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [ ] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [ ] No.
       - [ ] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   


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