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


Java LZ4Decompressor類代碼示例

本文整理匯總了Java中net.jpountz.lz4.LZ4Decompressor的典型用法代碼示例。如果您正苦於以下問題:Java LZ4Decompressor類的具體用法?Java LZ4Decompressor怎麽用?Java LZ4Decompressor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LZ4Decompressor類屬於net.jpountz.lz4包,在下文中一共展示了LZ4Decompressor類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleModernVersion

import net.jpountz.lz4.LZ4Decompressor; //導入依賴的package包/類
private void handleModernVersion() throws IOException
{
    DataOutputStream out = new DataOutputStream(socket.getOutputStream());
    out.writeInt(MessagingService.current_version);
    out.flush();

    DataInputStream in = new DataInputStream(socket.getInputStream());
    int maxVersion = in.readInt();
    from = CompactEndpointSerializationHelper.deserialize(in);

    if (compressed)
    {
        logger.debug("Upgrading incoming connection to be compressed");
        if (version < MessagingService.VERSION_21)
            in = new DataInputStream(new SnappyInputStream(socket.getInputStream()));
        else
        {
            LZ4Decompressor decompressor = LZ4Factory.fastestInstance().decompressor();
            Checksum checksum = XXHashFactory.fastestInstance().newStreamingHash32(OutboundTcpConnection.LZ4_HASH_SEED).asChecksum();
            in = new DataInputStream(new LZ4BlockInputStream(socket.getInputStream(),
                                                             decompressor,
                                                             checksum));
        }
    }
    else
    {
        in = new DataInputStream(new BufferedInputStream(socket.getInputStream(), 4096));
    }

    logger.debug("Max version for {} is {}", from, maxVersion);
    if (version > MessagingService.current_version)
    {
        // save the endpoint so gossip will reconnect to it
        Gossiper.instance.addSavedEndpoint(from);
        logger.info("Received messages from newer protocol version {}. Ignoring", version);
        return;
    }
    MessagingService.instance().setVersion(from, Math.min(MessagingService.current_version, maxVersion));
    logger.debug("set version for {} to {}", from, Math.min(MessagingService.current_version, maxVersion));
    // outbound side will reconnect if necessary to upgrade version

    while (true)
    {
        MessagingService.validateMagic(in.readInt());
        receiveMessage(in, version);
    }
}
 
開發者ID:pgaref,項目名稱:ACaZoo,代碼行數:48,代碼來源:IncomingTcpConnection.java


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