-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MINOR] refactor: simplify ShuffleWriteClientImpl#genServerToBlocks() #594
Conversation
Codecov Report
@@ Coverage Diff @@
## master #594 +/- ##
============================================
+ Coverage 60.84% 60.85% +0.01%
- Complexity 1797 1800 +3
============================================
Files 214 214
Lines 12398 12387 -11
Branches 1051 1044 -7
============================================
- Hits 7543 7538 -5
+ Misses 4445 4444 -1
+ Partials 410 405 -5
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
1b6672a
to
ba92962
Compare
This change is graceful, but i think the performance will be degraded. I don't recommend using lambda in critical path if it brings redundant loop operation. |
Where does it bring redundant loop operation? |
Actually we can avoid collecting to list and do it in one pass by reverting 57721a3 |
I just misread. 😂 |
break; | ||
} | ||
Stream<ShuffleServerInfo> servers; | ||
if (replica > 1 && excludeDefectiveServers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to replica > 1 && excludeDefectiveServers && !defectiveServers.isEmpty()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about excludeDefectiveServers && defectiveServers != null && !defectiveServers.isEmpty()
?
Use defectiveServers != null
instead of replica > 1
to be consistent with following statements:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is OK for me.
.add(sbi); | ||
} | ||
if (excludeServers != null) { | ||
excludeServers.addAll(selected); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about put this logic after limit
of the follow line?
incubator-uniffle/client/src/main/java/org/apache/uniffle/client/impl/ShuffleWriteClientImpl.java
Line 235 in ffc93e6
List<ShuffleServerInfo> selected = servers.limit(replicaNum).collect(Collectors.toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean servers.limit(replicaNum).map((server) -> excludeServers.add(server)).collect(Collectors.toList());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, let's just avoid collect to list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @xianjingfeng for the review. |
What changes were proposed in this pull request?
Simplify
ShuffleWriteClientImpl#genServerToBlocks()
.Why are the changes needed?
Simplify code logic.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Covered by
ShuffleWriteClientImplTest#testSendDataWithDefectiveServers()
.