Class Fingerprinter

  • Direct Known Subclasses:
    Adler32Fingerprinter

    public abstract class Fingerprinter
    extends java.lang.Object
    A fingerprinter is used in content based Chunkers to determine at which byte to break a file into Chunks.

    Implementations should make sure that the underlying algorithm is fast, because the roll()-method is called for each byte of a file. It should rely on a rolling checksum algorithm (also: rolling hash) to reach optimal performance.

    See Also:
    http://en.wikipedia.org/wiki/Rolling_hash
    • Constructor Summary

      Constructors 
      Constructor Description
      Fingerprinter()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void check​(byte[] buf, int off, int len)
      Update the checksum with an entirely different block, and potentially a different block length.
      static Fingerprinter getInstance​(java.lang.String name)  
      abstract int getValue()
      Return the value of the currently computed checksum.
      abstract void reset()
      Reset the checksum.
      abstract void roll​(byte bt)
      "Roll" the checksum, i.e.
      abstract java.lang.String toString()
      Returns a string representation of the fingerprinter implementation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • getInstance

        public static Fingerprinter getInstance​(java.lang.String name)
                                         throws java.security.NoSuchAlgorithmException
        Throws:
        java.security.NoSuchAlgorithmException
      • getValue

        public abstract int getValue()
        Return the value of the currently computed checksum.
        Returns:
        The currently computed checksum.
      • reset

        public abstract void reset()
        Reset the checksum.
      • roll

        public abstract void roll​(byte bt)
        "Roll" the checksum, i.e. update the underlying rolling checksum by the given content byte.
        Parameters:
        bt - The next byte.
      • check

        public abstract void check​(byte[] buf,
                                   int off,
                                   int len)
        Update the checksum with an entirely different block, and potentially a different block length.
        Parameters:
        buf - The byte array that holds the new block.
        off - From whence to begin reading.
        len - The length of the block to read.
      • toString

        public abstract java.lang.String toString()
        Returns a string representation of the fingerprinter implementation.
        Overrides:
        toString in class java.lang.Object