Add Zstandard and Brotli alg tests

This commit is contained in:
Mark Vainomaa 2017-03-26 21:15:47 +03:00
parent 5baff562c7
commit 6690855df5
4 changed files with 89 additions and 1 deletions

View File

@ -3,4 +3,16 @@
_(ametlik nimi uurimustööl?)_ _(ametlik nimi uurimustööl?)_
## Uurimustöö programmi jooksutamine ## Uurimustöö programmi jooksutamine
`git clone https://git.wut.ee/mikroskeem/java-class-compression-research` ja `mvn`. Java 8 on vajalik. `git clone https://git.wut.ee/mikroskeem/java-class-compression-research` ja `mvn`. Java 8 on vajalik.
## Testitud algoritmid
- BZip2
- GZip
- LZ4 (fast ja HC)
- LZMA
- XZ
- Zip
## Mittetuntud testitud algoritmid
- [Brotli](https://github.com/google/brotli)
- [Zstandard](https://github.com/facebook/zstd)

19
pom.xml
View File

@ -27,6 +27,11 @@
<enabled>true</enabled> <enabled>true</enabled>
</snapshots> </snapshots>
</repository> </repository>
<repository>
<id>bintray-nitram509-jbrotli</id>
<name>bintray</name>
<url>http://dl.bintray.com/nitram509/jbrotli</url>
</repository>
</repositories> </repositories>
<build> <build>
@ -102,5 +107,19 @@
<artifactId>lz4</artifactId> <artifactId>lz4</artifactId>
<version>1.3.0</version> <version>1.3.0</version>
</dependency> </dependency>
<!-- Brotli -->
<dependency>
<groupId>org.meteogroup.jbrotli</groupId>
<artifactId>jbrotli</artifactId>
<version>0.5.0</version>
</dependency>
<!-- Zstandard -->
<dependency>
<groupId>com.github.luben</groupId>
<artifactId>zstd-jni</artifactId>
<version>1.1.4</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,31 @@
package eu.mikroskeem.uurimustoo.algoritmidetest.algoritmid;
import lombok.Getter;
import org.meteogroup.jbrotli.BrotliStreamCompressor;
import org.meteogroup.jbrotli.BrotliStreamDeCompressor;
import org.meteogroup.jbrotli.libloader.BrotliLibraryLoader;
/**
* @author Mark Vainomaa
*/
public class Brotli extends AbstractAlgorithm {
@Getter private final String name = "Brotli";
static {
BrotliLibraryLoader.loadBrotli();
}
@Override
public byte[] compress(byte[] input) {
BrotliStreamCompressor compressor = new BrotliStreamCompressor();
return compressor.compressArray(input, true);
}
@Override
public byte[] decompress(byte[] input) {
BrotliStreamDeCompressor decompressor = new BrotliStreamDeCompressor();
byte[] buf = new byte[8192]; // *sigh*
decompressor.deCompress(input, buf);
return buf;
}
}

View File

@ -0,0 +1,26 @@
package eu.mikroskeem.uurimustoo.algoritmidetest.algoritmid;
import com.github.luben.zstd.ZstdInputStream;
import com.github.luben.zstd.ZstdOutputStream;
import lombok.Getter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* @author Mark Vainomaa
*/
public class Zstandard extends AbstractAlgorithm {
@Getter private final String name = "Zstandard";
@Override
public OutputStream createCompressor(OutputStream outputStream) throws IOException {
return new ZstdOutputStream(outputStream);
}
@Override
public InputStream createDecompressor(InputStream inputStream) throws IOException {
return new ZstdInputStream(inputStream);
}
}