Skip to content

Commit

Permalink
edit configuration item
Browse files Browse the repository at this point in the history
  • Loading branch information
THUMarkLau committed May 11, 2024
1 parent 6249a4e commit 834e61d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.apache.tsfile.common.conf.TSFileDescriptor;
import org.apache.tsfile.common.constant.TsFileConstant;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.file.metadata.enums.CompressionType;
import org.apache.tsfile.file.metadata.enums.TSEncoding;
import org.apache.tsfile.fileSystem.FSType;
import org.apache.tsfile.utils.FSUtils;
Expand Down Expand Up @@ -1122,6 +1123,8 @@ public class IoTDBConfig {
*/
private String RateLimiterType = "FixedIntervalRateLimiter";

private CompressionType WALCompressionAlgorithm = CompressionType.UNCOMPRESSED;

IoTDBConfig() {}

public int getMaxLogEntriesNumPerBatch() {
Expand Down Expand Up @@ -3906,11 +3909,11 @@ public void setInnerCompactionTaskSelectionDiskRedundancy(
this.innerCompactionTaskSelectionDiskRedundancy = innerCompactionTaskSelectionDiskRedundancy;
}

public boolean isEnableWALCompression() {
return enableWALCompression;
public CompressionType getWALCompressionAlgorithm() {
return WALCompressionAlgorithm;
}

public void setEnableWALCompression(boolean enableWALCompression) {
this.enableWALCompression = enableWALCompression;
public void setWALCompressionAlgorithm(CompressionType WALCompressionAlgorithm) {
this.WALCompressionAlgorithm = WALCompressionAlgorithm;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

import org.apache.tsfile.common.conf.TSFileDescriptor;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.file.metadata.enums.CompressionType;
import org.apache.tsfile.file.metadata.enums.TSEncoding;
import org.apache.tsfile.fileSystem.FSType;
import org.apache.tsfile.utils.FilePathUtils;
Expand Down Expand Up @@ -429,10 +430,10 @@ public void loadProperties(Properties properties) throws BadNodeUrlException, IO
"io_task_queue_size_for_flushing",
Integer.toString(conf.getIoTaskQueueSizeForFlushing()))));

conf.setEnableWALCompression(
Boolean.parseBoolean(
conf.setWALCompressionAlgorithm(
CompressionType.valueOf(
properties.getProperty(
"enable_wal_compression", Boolean.toString(conf.isEnableWALCompression()))));
"wal_compression_algorithm", conf.getWALCompressionAlgorithm().toString())));

conf.setCompactionScheduleIntervalInMs(
Long.parseLong(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,17 @@ public abstract class LogWriter implements ILogWriter {
protected long size;
protected boolean isEndFile = false;
private final ByteBuffer headerBuffer = ByteBuffer.allocate(Integer.BYTES * 2 + 1);
private static final CompressionType compressionType = CompressionType.GZIP;
private final ICompressor compressor = ICompressor.getCompressor(CompressionType.GZIP);
private static final CompressionType compressionAlg =
IoTDBDescriptor.getInstance().getConfig().getWALCompressionAlgorithm();
private final ICompressor compressor = ICompressor.getCompressor(compressionAlg);
private final ByteBuffer compressedByteBuffer;
private static final long MIN_COMPRESS_SIZE = 1024 * 512;

protected LogWriter(File logFile) throws FileNotFoundException {
this.logFile = logFile;
this.logStream = new FileOutputStream(logFile, true);
this.logChannel = this.logStream.getChannel();
if (IoTDBDescriptor.getInstance().getConfig().isEnableWALCompression()) {
if (compressionAlg != CompressionType.UNCOMPRESSED) {
compressedByteBuffer =
ByteBuffer.allocate(
compressor.getMaxBytesForCompression(
Expand All @@ -75,7 +76,7 @@ public void write(ByteBuffer buffer) throws IOException {
boolean compressed = false;
int uncompressedSize = bufferSize;
if (!isEndFile
&& IoTDBDescriptor.getInstance().getConfig().isEnableWALCompression()
&& compressionAlg != CompressionType.UNCOMPRESSED
&& bufferSize > MIN_COMPRESS_SIZE /* Do not compress buffer that is less than 512KB */) {
compressedByteBuffer.clear();
compressor.compress(buffer, compressedByteBuffer);
Expand All @@ -91,7 +92,7 @@ public void write(ByteBuffer buffer) throws IOException {
*/
headerBuffer.clear();
headerBuffer.put(
compressed ? compressionType.serialize() : CompressionType.UNCOMPRESSED.serialize());
compressed ? compressionAlg.serialize() : CompressionType.UNCOMPRESSED.serialize());
headerBuffer.putInt(bufferSize);
if (compressed) {
headerBuffer.putInt(uncompressedSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,10 @@ data_replication_factor=1
# Datatype: long
# iot_consensus_cache_window_time_in_ms=-1

# WAL compression algorithm
# options: UNCOMPRESSED, SNAPPY, LZ4, GZIP, ZSTD
# wal_compress_algorithm=UNCOMPRESSED

####################
### IoTConsensus Configuration
####################
Expand Down

0 comments on commit 834e61d

Please sign in to comment.