Example usage for io.netty.handler.codec.compression Snappy calculateChecksum

List of usage examples for io.netty.handler.codec.compression Snappy calculateChecksum

Introduction

In this page you can find the example usage for io.netty.handler.codec.compression Snappy calculateChecksum.

Prototype

static int calculateChecksum(ByteBuf data) 

Source Link

Document

Computes the CRC32C checksum of the supplied data and performs the "mask" operation on the computed checksum

Usage

From source file:com.seagate.kinetic.common.lib.Crc32cTagCalc.java

License:Open Source License

@Override
public ByteString calculateTag(byte[] value) {

    try {/*from  w  w  w  .  j  a  v a  2 s  .co  m*/

        // netty io bytebuf
        ByteBuf bb = Unpooled.wrappedBuffer(value);

        // calculate crc32c checksum
        int cval = Snappy.calculateChecksum(bb);

        logger.info("****** cval = " + cval);

        // convert to byte[]
        byte[] checkSum = ByteBuffer.allocate(4).putInt(cval).array();

        // convert to bytestring and return
        return ByteString.copyFrom(checkSum);

    } finally {
        ;
    }
}