Skip to content

Commit

Permalink
refactor: Filtered the Patents that apply to TsFile in the NOTICE, re…
Browse files Browse the repository at this point in the history
…-renamed the TsFileLZ4Compressor to LZ4Compressor
  • Loading branch information
chrisdutz committed Jan 5, 2024
1 parent badedcf commit 9197795
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
2 changes: 0 additions & 2 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ The Apache Software Foundation (http://www.apache.org/).

TsFile project uses 4 Chinese Patents:
* 201711384490X
* 201810111712.9
* 201711322631.5
* 201711319331.1

According to the Apache 2.0 License. The owner of the patents, Tsinghua University,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.tsfile.file.metadata.enums.CompressionType;

import com.github.luben.zstd.Zstd;
import net.jpountz.lz4.LZ4Compressor;
import net.jpountz.lz4.LZ4Factory;
import org.tukaani.xz.LZMA2Options;
import org.tukaani.xz.XZInputStream;
Expand Down Expand Up @@ -68,7 +67,7 @@ static ICompressor getCompressor(CompressionType name) {
case SNAPPY:
return new SnappyCompressor();
case LZ4:
return new TsFileLZ4Compressor();
return new LZ4Compressor();
case GZIP:
return new GZIPCompressor();
case ZSTD:
Expand Down Expand Up @@ -197,20 +196,20 @@ public CompressionType getType() {
}
}

class TsFileLZ4Compressor implements ICompressor {
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 LZ4Compressor compressor = factory.fastCompressor();
private static final net.jpountz.lz4.LZ4Compressor compressor = factory.fastCompressor();

public static LZ4Factory getFactory() {
return factory;
}

public TsFileLZ4Compressor() {
public LZ4Compressor() {
super();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

package org.apache.tsfile.compress;

import net.jpountz.lz4.LZ4Compressor;
import org.apache.tsfile.exception.compress.CompressionTypeNotSupportedException;
import org.apache.tsfile.file.metadata.enums.CompressionType;

import com.github.luben.zstd.Zstd;
import net.jpountz.lz4.LZ4Compressor;
import net.jpountz.lz4.LZ4SafeDecompressor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -201,7 +201,7 @@ class LZ4UnCompressor implements IUnCompressor {

private static final int MAX_COMPRESS_RATIO = 255;
private static final LZ4SafeDecompressor decompressor =
ICompressor.TsFileLZ4Compressor.getFactory().safeDecompressor();
ICompressor.LZ4Compressor.getFactory().safeDecompressor();

public LZ4UnCompressor() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void snappyTest() throws IOException {
public void lz4CompressorTest1() throws IOException {
PublicBAOS out = new PublicBAOS();
out.write(inputString.getBytes(StandardCharsets.UTF_8));
ICompressor compressor = new ICompressor.TsFileLZ4Compressor();
ICompressor compressor = new ICompressor.LZ4Compressor();
IUnCompressor unCompressor = new IUnCompressor.LZ4UnCompressor();
byte[] compressed = compressor.compress(out.getBuf());
byte[] uncompressed = unCompressor.uncompress(compressed);
Expand All @@ -96,7 +96,7 @@ public void lz4CompressorTest1() throws IOException {
public void lz4CompressorTest2() throws IOException {
PublicBAOS out = new PublicBAOS();
out.write(inputString.getBytes(StandardCharsets.UTF_8));
ICompressor compressor = new ICompressor.TsFileLZ4Compressor();
ICompressor compressor = new ICompressor.LZ4Compressor();
IUnCompressor unCompressor = new IUnCompressor.LZ4UnCompressor();
byte[] compressed = new byte[compressor.getMaxBytesForCompression(out.size())];
int size = compressor.compress(out.getBuf(), 0, out.size(), compressed);
Expand Down
6 changes: 3 additions & 3 deletions tsfile/src/test/java/org/apache/tsfile/compress/LZ4Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.tsfile.compress;

import org.apache.tsfile.compress.ICompressor.TsFileLZ4Compressor;
import org.apache.tsfile.compress.ICompressor.LZ4Compressor;
import org.apache.tsfile.compress.IUnCompressor.LZ4UnCompressor;

import org.junit.After;
Expand Down Expand Up @@ -51,7 +51,7 @@ public void testBytes1() throws IOException {
String input = randomString(2000000);
byte[] uncom = input.getBytes(StandardCharsets.UTF_8);
long time = System.currentTimeMillis();
ICompressor compressor = new TsFileLZ4Compressor();
ICompressor compressor = new LZ4Compressor();

byte[] compressed = compressor.compress(uncom);
System.out.println("compression time cost:" + (System.currentTimeMillis() - time));
Expand All @@ -68,7 +68,7 @@ public void testBytes1() throws IOException {

@Test
public void testBytes2() throws IOException {
TsFileLZ4Compressor compressor = new TsFileLZ4Compressor();
LZ4Compressor compressor = new LZ4Compressor();
IUnCompressor.LZ4UnCompressor unCompressor = new IUnCompressor.LZ4UnCompressor();

int n = 500000;
Expand Down

0 comments on commit 9197795

Please sign in to comment.