Examples of Adler32


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

Examples of com.sleepycat.je.utilint.Adler32

        /* 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

Examples of com.sleepycat.je.utilint.Adler32

     * 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

Examples of java.util.zip.Adler32

      prop.put("filewatcher.lockExtention", "*.lck");
      doPublish(prop, deliverDat, deliverGif, absSubPath);
   }
  
   long getChecksum(InputStream is) throws IOException {
      CheckedInputStream cis = new CheckedInputStream(is, new Adler32());
      byte[] tempBuf = new byte[128];
      while (cis.read(tempBuf) >= 0) {
      }
      return cis.getChecksum().getValue();
   }
View Full Code Here

Examples of java.util.zip.Adler32

         throw new IOException(Messages.getString("ApplicationLauncher.tunnelRequiredButNoEventHandler")); //$NON-NLS-1$
    }

    private long generateChecksum(File f) throws IOException {

        Adler32 alder = new Adler32();
        CheckedInputStream in = new CheckedInputStream(new FileInputStream(f), alder);
        try {
            byte[] buf = new byte[4096];
            int read = 0;
            while ((read = in.read(buf)) > -1)
                ;

            alder = (Adler32) in.getChecksum();

            return alder.getValue();
        } finally {
            in.close();
        }
    }
View Full Code Here

Examples of java.util.zip.Adler32

     * @param f
     * @return long
     * @throws IOException
     */
    public static long generateChecksum(File f) throws IOException {
        Adler32 alder = new Adler32();
        FileInputStream fin = new FileInputStream(f);
        CheckedInputStream in = new CheckedInputStream(fin, alder);
        byte[] buf = new byte[32768];
        Util.readFullyIntoBuffer(in, buf);
        alder = (Adler32) in.getChecksum();
        try {
            in.close();
        } catch (IOException ex) {
        }
        try {
            fin.close();
        } catch (IOException ex1) {
        }
        return alder.getValue();
    }
View Full Code Here

Examples of java.util.zip.Adler32

    {
      inStream = new FileInputStream(file);
      long size = file.length();
      CRC32 crc32 = null;
      MessageDigest md = null;
      Adler32 adler32 = null;
      if (algo.equalsIgnoreCase("CRC32"))
        crc32 = new CRC32();
      else if (algo.equalsIgnoreCase("Adler32"))
        adler32 = new Adler32();
      else md = MessageDigest.getInstance(algo);
      byte [] buf = new byte[BUF_SIZE];
      int readed = -1;
      if (listener != null) listener.notify(new ProgNotify(ProgNotify.START, 0, new Long(size).toString()));
      long total = size;
      boolean bAbort = false;
      while(size != 0)
      {
        if ((readed = inStream.read(buf)) >= 0)
        {
          if (crc32 != null) crc32.update(buf, 0, readed);
          else if (adler32 != nulladler32.update(buf, 0, readed);
          else md.update(buf, 0, readed);
         
          assert size <= readed;
          size -= readed;
          if (listener != null)
          {
            if (bAbort = listener.notify(new ProgNotify(ProgNotify.RUN, (int)(1000L - (size*1000L)/total), null)))
              break;
          }
        }
        else break;
      }
      if (bAbort)
      {
        if (listener != null) listener.notify(new ProgNotify(ProgNotify.ABORT, 0, null));
      }
      else
      {
        if (crc32 != null) m_byteArray = longToByteArray4(crc32.getValue());
        else if (adler32 != null) m_byteArray = longToByteArray4(adler32.getValue());
        else m_byteArray = md.digest();
     
        int index = 0;
        StringBuilder str = new StringBuilder();
        String temp = null;
View Full Code Here

Examples of java.util.zip.Adler32

     * @param adler the number to use as starting point for the Adler-32 algorithm
     */
    public Adler32Ext(final int adler) {
        super();
        this.adler=adler;
        this.intern = new Adler32();
        setAdlerRef(this.adler);
    }
View Full Code Here

Examples of java.util.zip.Adler32

        ? LZ4Factory.fastestInstance().fastCompressor()
        : LZ4Factory.fastestInstance().highCompressor();
    final Checksum checksum;
    switch (randomInt(2)) {
    case 0:
      checksum = new Adler32();
      break;
    case 1:
      checksum = new CRC32();
      break;
    default:
View Full Code Here

Examples of java.util.zip.Adler32

          System.out.println("EOF reached after " + count + " txns.");
        }

        return;
      }
      Checksum crc = new Adler32();
      crc.update(bytes, 0, bytes.length);
      if (crcValue != crc.getValue())
      {
        throw new IOException("CRC doesn't match " + crcValue + " vs "
            + crc.getValue());
      }
      InputArchive iab = BinaryInputArchive
          .getArchive(new ByteArrayInputStream(bytes));
      TxnHeader hdr = new TxnHeader();
      Record txn = SerializeUtils.deserializeTxn(iab, hdr);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.