當前位置: 首頁>>代碼示例>>Java>>正文


Java LZ4Factory.fastDecompressor方法代碼示例

如果您正苦於以下問題:Java LZ4Factory.fastDecompressor方法的具體用法?Java LZ4Factory.fastDecompressor怎麽用?Java LZ4Factory.fastDecompressor使用的例子?那麽, 這裏精選的代碼示例或許能為您提供幫助。

以下是net.jpountz.lz4.LZ4FactoryLZ4Factory.fastDecompressor方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為感覺有用的代碼點讚,您的評價將有助於係統推薦出更好的Java代碼示例。


示例1: LZ4Compressor

import net.jpountz.lz4.LZ4Factory; //導入方法依賴的package包/類
private LZ4Compressor(String type, Integer compressionLevel)
{
    this.compressorType = type;
    this.compressionLevel = compressionLevel;
    final LZ4Factory lz4Factory = LZ4Factory.fastestInstance();
    switch (type)
    {
        case LZ4_HIGH_COMPRESSOR:
        {
            compressor = lz4Factory.highCompressor(compressionLevel);
            break;
        }
        case LZ4_FAST_COMPRESSOR:
        default:
        {
            compressor = lz4Factory.fastCompressor();
        }
    }

    decompressor = lz4Factory.fastDecompressor();
}
 
開發者ID:Netflix,項目名稱:sstable-adaptor,代碼行數:22,代碼來源:LZ4Compressor.java

示例2: uncompress

import net.jpountz.lz4.LZ4Factory; //導入方法依賴的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

示例3: readFieldsC

import net.jpountz.lz4.LZ4Factory; //導入方法依賴的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

示例4: print

import net.jpountz.lz4.LZ4Factory; //導入方法依賴的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.LZ4Factory; //導入方法依賴的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: LZ4CompressionCodec

import net.jpountz.lz4.LZ4Factory; //導入方法依賴的package包/類
LZ4CompressionCodec(@Nonnegative final int bodyLength) {
    if (bodyLength < 1 || bodyLength > MAX_BODY_LENGTH) {
        throw new IllegalArgumentException("bodyLength < 1 || bodyLength > 0xFEEC: " + bodyLength);
    }
    final LZ4Factory factory = LZ4Factory.fastestInstance();
    this.compressor = factory.fastCompressor();
    this.decompressor = factory.fastDecompressor();

    this.bodyLength = bodyLength;
    this.headerLength = HEADER_LENGTH;
    this.compressedLength = compressor.maxCompressedLength(bodyLength);
    this.footerLength = FOOTER_LENGTH;
    this.frameLength = headerLength + compressedLength + footerLength;

    this.compressInput = new byte[this.bodyLength];
    this.compressOutput = new byte[compressedLength];
    this.decompressInput = new byte[compressedLength];
    this.decompressOutput = new byte[this.bodyLength];
}
 
開發者ID:ricardopadilha,項目名稱:dsys-snio,代碼行數:20,代碼來源:LZ4CompressionCodec.java

示例7: uncompress

import net.jpountz.lz4.LZ4Factory; //導入方法依賴的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

示例8: uncompressCGSS

import net.jpountz.lz4.LZ4Factory; //導入方法依賴的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

示例9: getDataTypePriv

import net.jpountz.lz4.LZ4Factory; //導入方法依賴的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

示例10: main

import net.jpountz.lz4.LZ4Factory; //導入方法依賴的package包/類
public static void main(String[] args)
{
    if (!Util.setTheme())
        return;

    // choose input file
    File inFile = Util.getOpenFile("Select file to decompress");
    if (inFile == null)
        return;

    // choose output file
    File outFile = Util.getSaveFile("Select output file");
    if (outFile == null)
        return;

    try
    {
        LZ4Factory factory = LZ4Factory.fastestJavaInstance();
        GpqLog.LOGGER.log("Loading data from file");
        byte[] data = FileUtils.readFileToByteArray(inFile);
        ByteBuffer inBuf = ByteBuffer.wrap(data);
        int decompressedLength = inBuf.getInt();
        GpqLog.LOGGER.log("Preparing to decompress " + decompressedLength + " bytes");
        LZ4FastDecompressor decompressor = factory.fastDecompressor();
        ByteBuffer outBuf = ByteBuffer.allocateDirect(decompressedLength);
        long preTime = System.currentTimeMillis();
        decompressor.decompress(inBuf, 4, outBuf, 0, decompressedLength);
        long postTime = System.currentTimeMillis();
        long timeTaken = postTime - preTime;
        GpqLog.LOGGER.log("Before decompression, data was " + (data.length - 4) + " bytes. It is now " + decompressedLength + ". Decompression took " + timeTaken + "ms");
        GpqLog.LOGGER.log("Writing data to file");
        byte[] outarray = new byte[decompressedLength];
        outBuf.rewind();
        outBuf.get(outarray);
        FileUtils.writeByteArrayToFile(outFile, outarray);
        GpqLog.LOGGER.log("Done");
    }
    catch (Throwable e)
    {
        e.printStackTrace();
        Util.showMessage("Exception " + e.getLocalizedMessage());
        return;
    }
}
 
開發者ID:Ginever,項目名稱:GineverPaQ,代碼行數:45,代碼來源:Lz4DecompressionTest.java

示例11: LZ4Compressor

import net.jpountz.lz4.LZ4Factory; //導入方法依賴的package包/類
private LZ4Compressor()
{
    final LZ4Factory lz4Factory = LZ4Factory.fastestInstance();
    compressor = lz4Factory.fastCompressor();
    decompressor = lz4Factory.fastDecompressor();
}
 
開發者ID:scylladb,項目名稱:scylla-tools-java,代碼行數:7,代碼來源:LZ4Compressor.java

示例12: main

import net.jpountz.lz4.LZ4Factory; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {


        LZ4Factory factory = LZ4Factory.fastestInstance();
        byte[] data = "Compressors and decompressors are interchangeable: it is perfectly correct to compress with the JNI bindings and to decompress with a Java port, or the other way around.Compressors might not generate the same compressed streams on all platforms, especially if CPU endianness differs, but the compressed streams can be safely decompressed by any decompressor implementation on any platform.Compressors and decompressors are interchangeable: it is perfectly correct to compress with the JNI bindings and to decompress with a Java port, or the other way around.Compressors might not generate the same compressed streams on all platforms, especially if CPU endianness differs, but the compressed streams can be safely decompressed by any decompressor implementation on any platform.".getBytes("UTF-8");


        final int decompressedLength = data.length;
        System.out.println("dataLength:" + decompressedLength);

        // compress data
        LZ4Compressor compressor = factory.fastCompressor();
        int maxCompressedLength = compressor.maxCompressedLength(decompressedLength);
        byte[] compressed = new byte[maxCompressedLength];
        int compressedLength = compressor.compress(data, 0, decompressedLength, compressed, 0, maxCompressedLength);
        System.out.println("compressedLength:" + compressedLength);

     // decompress data
        // - method 1: when the decompressed length is known
        LZ4FastDecompressor decompressor = factory.fastDecompressor();
        byte[] restored = new byte[decompressedLength];
        int compressedLength2 = decompressor.decompress(compressed, 0, restored, 0, decompressedLength);
        // compressedLength == compressedLength2
        System.out.println("compressedLength2:" + compressedLength2);

        // - method 2: when the compressed length is known (a little slower)
        // the destination buffer needs to be over-sized
        LZ4SafeDecompressor decompressor2 = factory.safeDecompressor();
        int decompressedLength2 = decompressor2.decompress(compressed, 0, compressedLength, restored, 0);
        // decompressedLength == decompressedLength2
        System.out.println("decompressedLength2:" + compressedLength);



        XXHashFactory factory1 = XXHashFactory.fastestInstance();
        ByteArrayInputStream in = new ByteArrayInputStream(data);

        int seed = 0x9747b28c; // used to initialize the hash value, use whatever
        // value you want, but always the same
        StreamingXXHash32 hash32 = factory1.newStreamingHash32(seed);
        byte[] buf = new byte[8]; // for real-world usage, use a larger buffer, like 8192 bytes
        for (;;) {
            int read = in.read(buf);
            if (read == -1) {
                break;
            }
            hash32.update(buf, 0, read);
        }
        int hash = hash32.getValue();

        System.out.println(hash);
    }
 
開發者ID:Jakegogo,項目名稱:concurrent,代碼行數:53,代碼來源:TestLz4.java

示例13: uncompress

import net.jpountz.lz4.LZ4Factory; //導入方法依賴的package包/類
@Override
public void uncompress(byte[] output, byte[] b, int offset, int limit) throws IOException {
    LZ4Factory factory = LZ4Factory.fastestInstance();
    LZ4FastDecompressor decompressor = factory.fastDecompressor();
    decompressor.decompress(b, offset, output, 0, output.length);
}
 
開發者ID:araqne,項目名稱:logdb,代碼行數:7,代碼來源:Lz4HcCompression.java


注:本文中的net.jpountz.lz4.LZ4Factory.fastDecompressor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。