colinmjj commented on code in PR #157:
URL: https://github.com/apache/incubator-uniffle/pull/157#discussion_r945392056
##########
client-spark/common/src/main/java/org/apache/spark/shuffle/writer/WriterBuffer.java:
##########
@@ -39,35 +39,34 @@ public WriterBuffer(int bufferSize) {
}
public void addRecord(byte[] recordBuffer, int length) {
- if (askForMemory(length)) {
- // buffer has data already, add buffer to list
- if (nextOffset > 0) {
- buffers.add(new WrappedBuffer(buffer, nextOffset));
- nextOffset = 0;
- }
- if (length > bufferSize) {
- buffer = new byte[length];
- memoryUsed += length;
- } else {
- buffer = new byte[bufferSize];
- memoryUsed += bufferSize;
- }
+ int require = calculateMemoryCost(length);
+ int hasCopied = 0;
+ if (require > 0 && buffer != null && buffer.length - nextOffset > 0) {
Review Comment:
How about:
```
// comments
if (require > 0) {
// comments
if (buffer != null) {
int hasCopied = xxx;
// commnets
if (hasCopied > 0) {
}
}
}
```
--
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]