Skip to content

Commit

Permalink
Enhance wal compression (#12853)
Browse files Browse the repository at this point in the history
* try fix

Signed-off-by: OneSizeFitQuorum <tanxinyu@apache.org>

* fix review

Signed-off-by: OneSizeFitQuorum <tanxinyu@apache.org>

---------

Signed-off-by: OneSizeFitQuorum <tanxinyu@apache.org>
  • Loading branch information
OneSizeFitsQuorum committed Jul 4, 2024
1 parent 8659754 commit e4aec0a
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public int read(byte[] b, int off, int len) throws IOException {
public void close() throws IOException {
channel.close();
MmapUtil.clean(dataBuffer);
MmapUtil.clean(compressedBuffer);
dataBuffer = null;
}

Expand Down Expand Up @@ -212,16 +213,15 @@ private void loadNextSegmentV2() throws IOException {
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();

if (Objects.isNull(compressedBuffer)
|| compressedBuffer.capacity() < segmentInfo.dataInDiskSize
|| compressedBuffer.capacity() > segmentInfo.dataInDiskSize * 2) {
MmapUtil.clean(compressedBuffer);
compressedBuffer = ByteBuffer.allocateDirect(segmentInfo.dataInDiskSize);
}
compressedBuffer.clear();
Expand All @@ -233,15 +233,12 @@ private void loadNextSegmentV2() throws IOException {
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();
Expand Down

0 comments on commit e4aec0a

Please sign in to comment.