当前位置: 首页>>代码示例>>Java>>正文


Java LZ4FastDecompressor类代码示例

本文整理汇总了Java中net.jpountz.lz4.LZ4FastDecompressor的典型用法代码示例。如果您正苦于以下问题:Java LZ4FastDecompressor类的具体用法?Java LZ4FastDecompressor怎么用?Java LZ4FastDecompressor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LZ4FastDecompressor类属于net.jpountz.lz4包,在下文中一共展示了LZ4FastDecompressor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: uncompress

import net.jpountz.lz4.LZ4FastDecompressor; //导入依赖的package包/类
@Override
public byte[] uncompress(byte[] data) throws IOException {
	LZ4Factory factory = LZ4Factory.fastestInstance();
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	LZ4FastDecompressor decompresser = factory.fastDecompressor();
	LZ4BlockInputStream lzis = new LZ4BlockInputStream(new ByteArrayInputStream(data), decompresser);
	
	int count;
	byte[] buffer = new byte[2048];
	while ((count = lzis.read(buffer)) != -1) {
		baos.write(buffer, 0, count);
	}
	lzis.close();
	
	return baos.toByteArray();
}
 
开发者ID:yu120,项目名称:compress,代码行数:17,代码来源:Lz4Compress.java

示例2: readFieldsC

import net.jpountz.lz4.LZ4FastDecompressor; //导入依赖的package包/类
public void readFieldsC(DataInput in) throws IOException {
	int decompressedLength = in.readInt();
	int compressedLength = in.readInt();
	byte[] compressed = new byte[compressedLength];
	in.readFully(compressed, 0, compressedLength);
	LZ4Factory factory = LZ4Factory.fastestInstance();
	LZ4FastDecompressor decompressor = factory.fastDecompressor();
	byte[] uncompressedByteArray = new byte[decompressedLength];
	decompressor.decompress(compressed, 0, uncompressedByteArray, 0, decompressedLength);		
	//byte[] uncompressedByteArray = WritableUtils.readCompressedByteArray(in);
	UnsafeByteArrayInputStream inStream = new UnsafeByteArrayInputStream(uncompressedByteArray);

	size = inStream.readInt();
	tables = new HashMap<String, Table>();
	for (int i = 0; i < size; i++)
	{
		String tableName = inStream.readUTF();
		Table table = new Table(null, null);
		table.readFields(inStream);
		tables.put(tableName, table);
	}
}
 
开发者ID:wmoustafa,项目名称:granada,代码行数:23,代码来源:Database.java

示例3: onDeserialize

import net.jpountz.lz4.LZ4FastDecompressor; //导入依赖的package包/类
@Override
protected void onDeserialize(Deserializer buf) {
    super.onDeserialize(buf);
    int length = buf.getInt(null);
    int compressedLength = buf.getInt(null);
    Preconditions.checkState(length == data.length,
            "Size of serialized sketch does not match expected value. Expected %s, actual %s.", data.length, length);

    if (length == compressedLength) {
        deserializeDataArray(data, length, buf);
    } else {
        LZ4FastDecompressor c = LZ4Factory.safeInstance().fastDecompressor();
        byte[] compressedData = buf.getBytes(null, compressedLength);
        c.decompress(compressedData, data);
    }
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:17,代码来源:NormalSketch.java

示例4: print

import net.jpountz.lz4.LZ4FastDecompressor; //导入依赖的package包/类
private void print(Request request) {
    Values ret = request.returnValues();
    CompressionType type = CompressionType.valueOf(ret.get(0).asInt8());
    int uncompressedSize = ret.get(1).asInt32();
    byte [] blob = ret.get(2).asData();
    if (type == CompressionType.LZ4) {
        LZ4Factory factory = LZ4Factory.fastestInstance();
        LZ4FastDecompressor decompressor = factory.fastDecompressor();
        byte [] uncompressed = new byte [uncompressedSize];
        int compressedLength = decompressor.decompress(blob, 0, uncompressed, 0, uncompressedSize);
        if (compressedLength != blob.length) {
            throw new DeserializationException("LZ4 decompression failed. compressed size does not match. Expected " + blob.length + ". Got " + compressedLength);
        }
        blob = uncompressed;
    }
    Slime slime = BinaryFormat.decode(blob);
    try {
        new JsonFormat(true).encode(System.out, slime);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:23,代码来源:VespaSummaryBenchmark.java

示例5: unlz4

import net.jpountz.lz4.LZ4FastDecompressor; //导入依赖的package包/类
/**
 * lz4 解壓縮
 *
 * @param value
 * @return
 */
public static byte[] unlz4(byte[] value) {
	byte[] result = new byte[0];
	try {
		LZ4Factory factory = LZ4Factory.fastestInstance();
		LZ4FastDecompressor decompressor = factory.fastDecompressor();
		//
		final int INTEGER_BYTES = 4;
		// 取原始長度
		int uncompressedLength = ((value[0] & 0xFF) << 24) | ((value[1] & 0xFF) << 16) | ((value[2] & 0xFF) << 8)
				| ((value[3] & 0xFF));
		result = new byte[uncompressedLength];
		int read = decompressor.decompress(value, INTEGER_BYTES, result, 0, uncompressedLength);
		if (read != (value.length - INTEGER_BYTES)) {
			result = new byte[0];
		}
	} catch (Exception ex) {
		ex.printStackTrace();
	}
	return result;
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:27,代码来源:CompressHelperWithoutPool.java

示例6: decompressFast

import net.jpountz.lz4.LZ4FastDecompressor; //导入依赖的package包/类
/**
 * When the exact decompressed size is known, use this method to decompress. It's faster.
 *
 * @see net.jpountz.lz4.LZ4FastDecompressor
 */
public static byte[] decompressFast(byte[] src, int srcOffset, int exactDecompressedSize) {
    if (src == null) {
        throw new IllegalArgumentException("src must not be null.");
    }

    if (srcOffset < 0) {
        throw new IllegalArgumentException("srcOffset must equal to or larger than 0 but " + srcOffset);
    }

    if (exactDecompressedSize < 0) {
        throw new IllegalArgumentException("exactDecompressedSize must equal to or larger than 0 but " + exactDecompressedSize);
    }

    LZ4FastDecompressor decompressor = factory.fastDecompressor();

    return decompressor.decompress(src, srcOffset, exactDecompressedSize);
}
 
开发者ID:kwon37xi,项目名称:hibernate4-memcached,代码行数:23,代码来源:Lz4CompressUtils.java

示例7: get

import net.jpountz.lz4.LZ4FastDecompressor; //导入依赖的package包/类
public Image get() {
	switch (type) {
	case PNG:
		return ImageUtils.fromPNG(data);

	case LZ4:
		LZ4FastDecompressor lz4Decompressor = LZ4Factory.unsafeInstance().fastDecompressor();
		byte[] uncompressed = new byte[uncompressedLength];
		lz4Decompressor.decompress(data, uncompressed);
		return uncompressImage(width, height, uncompressed);
		// byte[]decompressed = lz4Decompressor.d
		// case LZ4:
		// return LZ4Factory.unsafeInstance().fastCompressor().compress(getUncompressedBytes(img));
		//
	default:
		throw new IllegalArgumentException();
	}
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:19,代码来源:CompressedImage.java

示例8: uncompress

import net.jpountz.lz4.LZ4FastDecompressor; //导入依赖的package包/类
public static byte[] uncompress(byte[] bytes) throws IOException {
    LZ4Factory factory = LZ4Factory.fastestInstance();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    LZ4FastDecompressor decompresser = factory.fastDecompressor();

    LZ4BlockInputStream lzis = new LZ4BlockInputStream(
            new ByteArrayInputStream(bytes), decompresser);
    int count;
    byte[] buffer = new byte[2048 * 256];
    while ((count = lzis.read(buffer)) != -1) {
        baos.write(buffer, 0, count);
    }
    lzis.close();
    return baos.toByteArray();
}
 
开发者ID:Lazyeraser,项目名称:DereHelper,代码行数:16,代码来源:LZ4Helper.java

示例9: uncompressCGSS

import net.jpountz.lz4.LZ4FastDecompressor; //导入依赖的package包/类
public static byte[] uncompressCGSS(byte[] src) throws IOException {
    byte[] buf = new byte[4];
    System.arraycopy(src, 4, buf, 0, 4);
    int destL = getInt(buf, 0);


    byte[] source = new byte[src.length - 16];
    byte[] dest = new byte[destL];
    System.arraycopy(src, 16, source, 0, src.length - 16);

    LZ4Factory factory = LZ4Factory.fastestInstance();
    LZ4FastDecompressor decompresser = factory.fastDecompressor();
    decompresser.decompress(source, dest, destL);
    return dest;
}
 
开发者ID:Lazyeraser,项目名称:DereHelper,代码行数:16,代码来源:LZ4Helper.java

示例10: decompress

import net.jpountz.lz4.LZ4FastDecompressor; //导入依赖的package包/类
public byte[] decompress(byte[] value, int offset, int length, int uncompressedLength) throws IOException {
    LZ4FastDecompressor decompressor;
    byte[]              restored;
    
    decompressor = factory.fastDecompressor();
    restored = new byte[uncompressedLength];
    decompressor.decompress(value, offset, restored, 0, uncompressedLength);    
    return restored;
}
 
开发者ID:Morgan-Stanley,项目名称:SilverKing,代码行数:10,代码来源:LZ4.java

示例11: uncompress

import net.jpountz.lz4.LZ4FastDecompressor; //导入依赖的package包/类
public static byte[] uncompress(byte[] result) {
	byte[] length = new byte[4];
	System.arraycopy(result, 0, length, 0, length.length);
	int size = byteArrayToInt(length);
	byte[] restored = new byte[size];
	LZ4FastDecompressor decompressor = factory.fastDecompressor();
	decompressor.decompress(result, 4, restored, 0, size);
	return restored;
}
 
开发者ID:bdceo,项目名称:bd-codes,代码行数:10,代码来源:Lz4Compress.java

示例12: decompress

import net.jpountz.lz4.LZ4FastDecompressor; //导入依赖的package包/类
@Override
protected byte[] decompress(byte[] in) {
	byte[] out = null;
	if (in != null) {
		LZ4FastDecompressor decompressor = lz4Factory.fastDecompressor();

		int size = ByteBuffer.wrap(in).getInt();
		out = new byte[size];
		decompressor.decompress(in, Ints.BYTES, out, 0, out.length);
	}
	return out == null ? null : out;
}
 
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:13,代码来源:LZ4Transcoder.java

示例13: readBody

import net.jpountz.lz4.LZ4FastDecompressor; //导入依赖的package包/类
private static ByteBuf readBody(LZ4FastDecompressor decompressor, StreamingXXHash32 checksum, Header header,
                                byte[] bytes, int off) throws ParseException {
	ByteBuf outputBuf = ByteBufPool.allocate(header.originalLen);
	outputBuf.writePosition(header.originalLen);
	switch (header.compressionMethod) {
		case COMPRESSION_METHOD_RAW:
			System.arraycopy(bytes, off, outputBuf.array(), 0, header.originalLen);
			break;
		case COMPRESSION_METHOD_LZ4:
			try {
				int compressedLen2 = decompressor.decompress(bytes, off, outputBuf.array(), 0, header.originalLen);
				if (header.compressedLen != compressedLen2) {
					throw new ParseException("Stream is corrupted");
				}
			} catch (LZ4Exception e) {
				throw new ParseException("Stream is corrupted", e);
			}
			break;
		default:
			throw new AssertionError();
	}
	checksum.reset();
	checksum.update(outputBuf.array(), 0, header.originalLen);
	if (checksum.getValue() != header.check) {
		throw new ParseException("Stream is corrupted");
	}
	return outputBuf;
}
 
开发者ID:softindex,项目名称:datakernel,代码行数:29,代码来源:StreamLZ4Decompressor.java

示例14: getDataTypePriv

import net.jpountz.lz4.LZ4FastDecompressor; //导入依赖的package包/类
public String getDataTypePriv() throws IOException {
	RandomAccessFile fin = new RandomAccessFile(sinfile,"r");
	byte[] res=null;
	byte[] rescomp=null;
	if (dataHeader.mmcfLen>0) {
		Object block = dataBlocks.firstElement();
		if (block instanceof AddrBlock) {
			res = new byte[(int)((AddrBlock)block).dataLen];
			fin.seek(getDataOffset()+((AddrBlock)block).dataOffset);
			fin.read(res);
			fin.close();
		}
		else {
			rescomp = new byte[(int)((LZ4ABlock)block).compDataLen];
			fin.seek(getDataOffset()+((LZ4ABlock)block).dataOffset);
			fin.read(rescomp);
			fin.close();
			LZ4Factory factory = LZ4Factory.fastestInstance();
			LZ4FastDecompressor decomp = factory.fastDecompressor();
			res = decomp.decompress(rescomp, (int)((LZ4ABlock)block).uncompDataLen);
		}
	}
	else {
		res = new byte[blocks.blocks[0].length];
		fin.seek(getDataOffset());
		fin.read(res);
		fin.close();
	}
	return getDataTypePriv(res);
}
 
开发者ID:Androxyde,项目名称:Flashtool,代码行数:31,代码来源:SinParser.java

示例15: decompressLZ4

import net.jpountz.lz4.LZ4FastDecompressor; //导入依赖的package包/类
public byte[] decompressLZ4(byte[] compressed, int decompressedLength) {
	LZ4FastDecompressor decompressor = lz4.get().fastDecompressor();
	byte[] restored = new byte[decompressedLength];
	decompressor.decompress(compressed, 0, restored, 0, decompressedLength);
	return restored;
}
 
开发者ID:ramusa2,项目名称:CandCNFPerceptronParser,代码行数:7,代码来源:FSTSerializerAndCompressor.java


注:本文中的net.jpountz.lz4.LZ4FastDecompressor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。