Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ public class TSFileConfig implements Serializable {

private String objectStorageTsFileOutput = "org.apache.iotdb.os.fileSystem.OSTsFileOutput";

private boolean lz4UseJni = true;

/** customizedProperties, this should be empty by default. */
private Properties customizedProperties = new Properties();

Expand Down Expand Up @@ -690,4 +692,12 @@ public String getObjectStorageTsFileOutput() {
public void setObjectStorageTsFileOutput(String objectStorageTsFileOutput) {
this.objectStorageTsFileOutput = objectStorageTsFileOutput;
}

public boolean isLz4UseJni() {
return lz4UseJni;
}

public void setLz4UseJni(boolean lz4UseJni) {
this.lz4UseJni = lz4UseJni;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void overwriteConfigByCustomSettings(Properties properties) {
writer.setString(conf::setEncryptFlag, "encrypt_flag");
writer.setString(conf::setEncryptType, "encrypt_type");
writer.setString(conf::setEncryptKeyFromPath, "encrypt_key_path");
writer.setBoolean(conf::setLz4UseJni, "lz4_use_jni");
}

private static class PropertiesOverWriter {
Expand All @@ -110,6 +111,10 @@ public void setString(Consumer<String> setter, String propertyKey) {
set(setter, propertyKey, Function.identity());
}

public void setBoolean(Consumer<Boolean> setter, String propertyKey) {
set(setter, propertyKey, Boolean::parseBoolean);
}

private <T> void set(
Consumer<T> setter, String propertyKey, Function<String, T> propertyValueConverter) {
String value = this.properties.getProperty(propertyKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.tsfile.compress;

import org.apache.tsfile.common.conf.TSFileDescriptor;
import org.apache.tsfile.exception.compress.CompressionTypeNotSupportedException;
import org.apache.tsfile.exception.compress.GZIPCompressOverflowException;
import org.apache.tsfile.file.metadata.enums.CompressionType;
Expand Down Expand Up @@ -201,7 +202,10 @@ class LZ4Compressor implements ICompressor {
* This instance should be cached to avoid performance problem. See:
* https://github.com/lz4/lz4-java/issues/152 and https://github.com/apache/spark/pull/24905
*/
private static final LZ4Factory factory = LZ4Factory.fastestInstance();
private static final LZ4Factory factory =
TSFileDescriptor.getInstance().getConfig().isLz4UseJni()
? LZ4Factory.fastestInstance()
: LZ4Factory.safeInstance();

private static final net.jpountz.lz4.LZ4Compressor compressor = factory.fastCompressor();

Expand Down
Loading