This is an automated email from the ASF dual-hosted git repository.

tanxinyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new e4aec0a6cdb Enhance wal compression (#12853)
e4aec0a6cdb is described below

commit e4aec0a6cdbdbe00d9efb52e049cc7a9f379180f
Author: Potato <[email protected]>
AuthorDate: Thu Jul 4 14:02:09 2024 +0800

    Enhance wal compression (#12853)
    
    * try fix
    
    Signed-off-by: OneSizeFitQuorum <[email protected]>
    
    * fix review
    
    Signed-off-by: OneSizeFitQuorum <[email protected]>
    
    ---------
    
    Signed-off-by: OneSizeFitQuorum <[email protected]>
---
 .../db/storageengine/dataregion/wal/io/WALInputStream.java    | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/io/WALInputStream.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/io/WALInputStream.java
index 350f8f5e995..14854a05623 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/io/WALInputStream.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/io/WALInputStream.java
@@ -166,6 +166,7 @@ public class WALInputStream extends InputStream implements 
AutoCloseable {
   public void close() throws IOException {
     channel.close();
     MmapUtil.clean(dataBuffer);
+    MmapUtil.clean(compressedBuffer);
     dataBuffer = null;
   }
 
@@ -212,9 +213,7 @@ public class WALInputStream extends InputStream implements 
AutoCloseable {
       if (Objects.isNull(dataBuffer)
           || dataBuffer.capacity() < segmentInfo.uncompressedSize
           || dataBuffer.capacity() > segmentInfo.uncompressedSize * 2) {
-        if (!Objects.isNull(dataBuffer)) {
-          MmapUtil.clean(dataBuffer);
-        }
+        MmapUtil.clean(dataBuffer);
         dataBuffer = ByteBuffer.allocateDirect(segmentInfo.uncompressedSize);
       }
       dataBuffer.clear();
@@ -222,6 +221,7 @@ public class WALInputStream extends InputStream implements 
AutoCloseable {
       if (Objects.isNull(compressedBuffer)
           || compressedBuffer.capacity() < segmentInfo.dataInDiskSize
           || compressedBuffer.capacity() > segmentInfo.dataInDiskSize * 2) {
+        MmapUtil.clean(compressedBuffer);
         compressedBuffer = 
ByteBuffer.allocateDirect(segmentInfo.dataInDiskSize);
       }
       compressedBuffer.clear();
@@ -233,15 +233,12 @@ public class WALInputStream extends InputStream 
implements AutoCloseable {
       compressedBuffer.flip();
       IUnCompressor unCompressor = 
IUnCompressor.getUnCompressor(segmentInfo.compressionType);
       unCompressor.uncompress(compressedBuffer, dataBuffer);
-      MmapUtil.clean(compressedBuffer);
     } else {
       // An uncompressed segment
       if (Objects.isNull(dataBuffer)
           || dataBuffer.capacity() < segmentInfo.dataInDiskSize
           || dataBuffer.capacity() > segmentInfo.dataInDiskSize * 2) {
-        if (!Objects.isNull(dataBuffer)) {
-          MmapUtil.clean(dataBuffer);
-        }
+        MmapUtil.clean(dataBuffer);
         dataBuffer = ByteBuffer.allocateDirect(segmentInfo.dataInDiskSize);
       }
       dataBuffer.clear();

Reply via email to