jerqi commented on code in PR #2666:
URL: https://github.com/apache/uniffle/pull/2666#discussion_r2497767730


##########
client-spark/common/src/main/java/org/apache/uniffle/shuffle/ShuffleWriteTaskStats.java:
##########
@@ -60,45 +77,72 @@ public void incPartitionRecord(int partitionId) {
   }
 
   public void incPartitionBlock(int partitionId) {
-    partitionBlocksWritten[partitionId]++;
+    if (blockNumberCheckEnabled) {
+      partitionBlocksWritten[partitionId]++;
+    }
   }
 
   public long getBlocksWritten(int partitionId) {
-    return partitionBlocksWritten[partitionId];
+    if (blockNumberCheckEnabled) {
+      return partitionBlocksWritten[partitionId];
+    }
+    return -1L;
   }
 
   public long getTaskAttemptId() {
     return taskAttemptId;
   }
 
   public String encode() {
+    final long start = System.currentTimeMillis();
     int partitions = partitionRecordsWritten.length;
-    ByteBuffer buffer =
-        ByteBuffer.allocate(2 * Long.BYTES + Integer.BYTES + partitions * 
Long.BYTES * 2);
+    int capacity = 2 * Long.BYTES + Integer.BYTES + partitions * Long.BYTES;
+    if (blockNumberCheckEnabled) {
+      capacity += partitions * Long.BYTES;
+    }
+    ByteBuffer buffer = ByteBuffer.allocate(capacity);
     buffer.putLong(taskId);
     buffer.putLong(taskAttemptId);
     buffer.putInt(partitions);
     for (long records : partitionRecordsWritten) {
       buffer.putLong(records);
     }
-    for (long blocks : partitionBlocksWritten) {
-      buffer.putLong(blocks);
+    if (blockNumberCheckEnabled) {
+      for (long blocks : partitionBlocksWritten) {
+        buffer.putLong(blocks);
+      }
     }
-    return new String(buffer.array(), ISO_8859_1);
+    byte[] compressed = 
ZstdCodec.getInstance(rssConf).compress(buffer.array());

Review Comment:
   Could you reuse our compressCodec instead of using `ZstdCodec` directly?



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