Package com.sleepycat.je.utilint

Examples of com.sleepycat.je.utilint.Adler32


     * of the bytes representing the concatenation of the key/value pair.
     *
     * @return the checksum
     */
    public static int getXi(byte[] keyValue) {
        Adler32 adler32 = new Adler32();
        adler32.update(keyValue, 0, keyValue.length);
        return (int) adler32.getValue();
    }
View Full Code Here


        /* DatabaseEntry represents the key and data of each record. */
        DatabaseEntry key = new DatabaseEntry();
        DatabaseEntry data = new DatabaseEntry();
        /* Adler32 to compute the rolling checksum of key/data pair. */
        Adler32 adler32 = new Adler32();
        int i = 0;
        int a = 0, b = 0;
        md.reset();
        Block block = new Block(blockId);

        /* Please pay attention to the check order in while loop. */
        while ((i < numKeys) &&
               (cursor.getNext(key, data, LockMode.DEFAULT) ==
                OperationStatus.SUCCESS)) {
            /* Indicates having a new block. */
            if (i == 0) {
                block.setBeginKey(key.getData());
                block.setBeginData(data.getData());
            }

            /* Calculate rollingChksum on "key|data" bytes. */
            adler32.reset();
            adler32.update(key.getData(), 0, key.getData().length);
            adler32.update(data.getData(), 0, data.getData().length);
            final int xi = (int) adler32.getValue();
            a += xi;
            b += a;
            /* Update MessageDigest with "key|data" bytes. */
            md.update(key.getData());
            md.update(data.getData());
View Full Code Here

     * algorithm to logically use 32 bit bytes.
     */
    private void setChecksum() {

        /* Adler32 to compute the rolling checksum of key/data pair. */
        Adler32 adler32 = new Adler32();

        int a = 0, b = 0;
        for (int i = 0; i < size(); i++) {
            byte[] element = window.get(i);
            adler32.reset();
            adler32.update(element, 0, element.length);
            final int xi = (int) adler32.getValue(); /* It's really 32 bits */
            a += xi;
            b += (xi * (size() - i));
        }
        chksum = (a & LDiffUtil.MASK_32BIT) | ((long) b << 32);
    }
View Full Code Here

    private static final boolean DEBUG = false;

    private Checksum cksum;

    ChecksumValidator() {
        cksum = new Adler32();
    }
View Full Code Here

    private ByteBuffer addPrevOffsetAndChecksum(ByteBuffer destBuffer,
                                                long lastOffset,
                                                int entrySize) {

        Checksum checksum = new Adler32();
           
        /* Add the prev pointer */
        destBuffer.position(HEADER_PREV_OFFSET);
        LogUtils.writeUnsignedInt(destBuffer, lastOffset);

        /* Now calculate the checksum and write it into the buffer. */
        checksum.update(destBuffer.array(), CHECKSUM_BYTES,
                        (entrySize - CHECKSUM_BYTES));
        destBuffer.position(0);
        LogUtils.putUnsignedInt(destBuffer, checksum.getValue());

        /* Leave this buffer ready for copying into another buffer. */
        destBuffer.position(0);

        return destBuffer;
View Full Code Here

TOP

Related Classes of com.sleepycat.je.utilint.Adler32

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.