From 27d3e6707a488dd8823d3973d318daff5db27783 Mon Sep 17 00:00:00 2001 From: wenlongwlli Date: Sat, 23 Nov 2024 13:46:53 +0800 Subject: [PATCH] fix(server) dataLength of ShuffleBufferWithLinkedList not clear after toFlushEvent --- .../uniffle/server/buffer/ShuffleBufferWithLinkedList.java | 1 + .../server/buffer/ShuffleBufferWithLinkedListTest.java | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/server/src/main/java/org/apache/uniffle/server/buffer/ShuffleBufferWithLinkedList.java b/server/src/main/java/org/apache/uniffle/server/buffer/ShuffleBufferWithLinkedList.java index 553b2870b9..e35c42575e 100644 --- a/server/src/main/java/org/apache/uniffle/server/buffer/ShuffleBufferWithLinkedList.java +++ b/server/src/main/java/org/apache/uniffle/server/buffer/ShuffleBufferWithLinkedList.java @@ -120,6 +120,7 @@ public synchronized ShuffleDataFlushEvent toFlushEvent( blocks = new LinkedHashSet<>(); inFlushSize.addAndGet(encodedLength); encodedLength = 0; + dataLength = 0; return event; } diff --git a/server/src/test/java/org/apache/uniffle/server/buffer/ShuffleBufferWithLinkedListTest.java b/server/src/test/java/org/apache/uniffle/server/buffer/ShuffleBufferWithLinkedListTest.java index acc86a6db7..47fe3dd393 100644 --- a/server/src/test/java/org/apache/uniffle/server/buffer/ShuffleBufferWithLinkedListTest.java +++ b/server/src/test/java/org/apache/uniffle/server/buffer/ShuffleBufferWithLinkedListTest.java @@ -79,6 +79,11 @@ public void toFlushEventTest() { assertEquals(42, shuffleBuffer.getEncodedLength()); event = shuffleBuffer.toFlushEvent("appId", 0, 0, 1, null); assertEquals(42, event.getEncodedLength()); + assertEquals(10, event.getDataLength()); + shuffleBuffer.append(createData(10)); + event = shuffleBuffer.toFlushEvent("appId", 0, 0, 1, null); + assertEquals(42, event.getEncodedLength()); + assertEquals(10, event.getDataLength()); assertEquals(0, shuffleBuffer.getEncodedLength()); assertEquals(0, shuffleBuffer.getBlocks().size()); }