本文整理汇总了Java中net.jpountz.lz4.LZ4BlockOutputStream类的典型用法代码示例。如果您正苦于以下问题:Java LZ4BlockOutputStream类的具体用法?Java LZ4BlockOutputStream怎么用?Java LZ4BlockOutputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LZ4BlockOutputStream类属于net.jpountz.lz4包,在下文中一共展示了LZ4BlockOutputStream类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compress
import net.jpountz.lz4.LZ4BlockOutputStream; //导入依赖的package包/类
@Override
public byte[] compress( final byte[] data , final int start , final int length ) throws IOException{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
bOut.write( LENGTH_DUMMY , 0 , LENGTH_DUMMY.length );
LZ4BlockOutputStream out = new LZ4BlockOutputStream( bOut );
out.write( data , start , length );
out.flush();
out.finish();
byte[] compressByte = bOut.toByteArray();
ByteBuffer.wrap( compressByte ).putInt( length );
bOut.close();
out.close();
return compressByte;
}
示例2: serializeCompressLZ4
import net.jpountz.lz4.LZ4BlockOutputStream; //导入依赖的package包/类
public synchronized int serializeCompressLZ4(T obj, File file) {
try {
byte[] barray = conf.get().asByteArray(obj);
int compressedLength = barray.length;
int decompressedLength = -1;
// Notes: uses an LZ4 block size of 64KB, fast compressor
LZ4BlockOutputStream LZOS = new LZ4BlockOutputStream(new FileOutputStream(file));
FSTObjectOutput oos = conf.get().getObjectOutput(LZOS);
oos.writeObject(obj);
oos.flush();
LZOS.close();
return decompressedLength;
}
catch(Exception e) {
e.printStackTrace();
}
return -1;
}
示例3: compress
import net.jpountz.lz4.LZ4BlockOutputStream; //导入依赖的package包/类
@Override
public byte[] compress(byte[] data) throws IOException {
LZ4Factory factory = LZ4Factory.fastestInstance();
ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
LZ4Compressor compressor = factory.fastCompressor();
LZ4BlockOutputStream compressedOutput = new LZ4BlockOutputStream(byteOutput, 2048, compressor);
compressedOutput.write(data);
compressedOutput.close();
return byteOutput.toByteArray();
}
示例4: compress
import net.jpountz.lz4.LZ4BlockOutputStream; //导入依赖的package包/类
public static byte[] compress(byte srcBytes[]) throws IOException {
LZ4Factory factory = LZ4Factory.fastestInstance();
ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
LZ4Compressor compressor = factory.fastCompressor();
LZ4BlockOutputStream compressedOutput = new LZ4BlockOutputStream(
byteOutput, 2048, compressor);
compressedOutput.write(srcBytes);
compressedOutput.close();
return byteOutput.toByteArray();
}
示例5: openWriter
import net.jpountz.lz4.LZ4BlockOutputStream; //导入依赖的package包/类
private void openWriter() throws IOException {
if (written) {
throw new IllegalStateException("list is already closed");
}
if (writing) {
throw new IllegalStateException("already writing on this list");
}
if (compressionEnabled) {
this.tmpFile = Files.createTempFile(tmpDir, "listswap", ".tmp.gz");
} else {
this.tmpFile = Files.createTempFile(tmpDir, "listswap", ".tmp");
}
logger.log(Level.FINE, "opening tmp swap file {0}", tmpFile.toAbsolutePath());
writing = true;
try {
out = Files.newOutputStream(tmpFile);
bout = new SimpleBufferedOutputStream(out, DISK_BUFFER_SIZE);
if (compressionEnabled) {
zippedout = new LZ4BlockOutputStream(out);
oout = new ExtendedDataOutputStream(zippedout);
} else {
oout = new ExtendedDataOutputStream(bout);
}
} catch (IOException ex) {
closeWriter();
throw new RuntimeException(ex);
}
}
示例6: update
import net.jpountz.lz4.LZ4BlockOutputStream; //导入依赖的package包/类
public void update(byte[] key, byte[] value) throws IOException {
numKeys++;
try {
updateUnsafe(key, value);
} catch (NullPointerException e) {
file.getParentFile().mkdirs();
file.createNewFile();
this.os = new FaweOutputStream(new BufferedOutputStream(new ZstdOutputStream(new LZ4BlockOutputStream(new FileOutputStream(file)))));
updateUnsafe(key, value);
}
}
示例7: flushChanges
import net.jpountz.lz4.LZ4BlockOutputStream; //导入依赖的package包/类
default void flushChanges(File file) throws IOException {
try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file))) {
try (LZ4BlockOutputStream compressed = new LZ4BlockOutputStream(out)) {
// compressed.setLevel(Deflater.BEST_SPEED);
try (FaweOutputStream fos = new FaweOutputStream(compressed)) {
flushChanges(fos);
}
}
}
}
示例8: getOutputStream
import net.jpountz.lz4.LZ4BlockOutputStream; //导入依赖的package包/类
@Override
public OutputStream getOutputStream(final OutputStream out) throws IOException {
return new LZ4BlockOutputStream(out, blockSize);
}
示例9: wrapOut
import net.jpountz.lz4.LZ4BlockOutputStream; //导入依赖的package包/类
@Override
@Nonnull
public OutputStream wrapOut(@Nonnull OutputStream out, int option) throws IOException {
return option == -1 ? new LZ4BlockOutputStream(out) : new LZ4BlockOutputStream(out, option);
}