Class AbstractIncrementalLongHash

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      long calculate​(byte[] input)
      Evaluates this hash function for the entire given input array.
      long calculate​(byte[] input, int index, int length)
      Evaluates this hash function for the given range of the given input array.
      long calculate​(long address, long length)
      Evaluates this hash function for the memory with the given address and length.
      long calculate​(java.nio.ByteBuffer input)
      Evaluates this hash function with the remaining contents of the given input buffer.
      StatefulLongHash createStateful()
      Returns a new instance of stateful version of this hash function.
      protected abstract long initial()
      The initial state of the hash function, which is the same as the output value for an empty input sequence.
      long resume​(long current, byte[] input)
      Evaluates this hash function as if the entire given input array were appended to the previously hashed input.
      long resume​(long current, byte[] input, int index, int length)
      Evaluates this hash function as if the given range of the given input array were appended to the previously hashed input.
      long resume​(long current, long address, long length)
      Evaluates this hash function as if the memory with the given address and length were appended to the previously hashed input.
      long resume​(long current, java.nio.ByteBuffer input)
      Evaluates this hash function as if the remaining contents of the given input buffer were appended to the previously hashed input.
      protected abstract long resumeUnchecked​(long current, byte[] input, int index, int length)
      Evaluates this hash function as if the given range of the given input array were appended to the previously hashed input.
      boolean supportsUnsafe()
      Returns whether this hash function supports unsafe access to arbitrary memory addresses using methods such as StatefulHash.update(long, long), StatelessIntHash.calculate(long, long), or IncrementalIntHash.resume(int, long, long).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractIncrementalLongHash

        public AbstractIncrementalLongHash()
    • Method Detail

      • calculate

        public long calculate​(byte[] input)
        Description copied from interface: StatelessLongHash
        Evaluates this hash function for the entire given input array.
        Specified by:
        calculate in interface StatelessLongHash
        Parameters:
        input - the input array
        Returns:
        the output of the hash function
      • calculate

        public long calculate​(byte[] input,
                              int index,
                              int length)
        Description copied from interface: StatelessLongHash
        Evaluates this hash function for the given range of the given input array.
        Specified by:
        calculate in interface StatelessLongHash
        Parameters:
        input - the input array
        index - the starting index of the first input byte
        length - the length of the input range
        Returns:
        the output of the hash function
      • calculate

        public long calculate​(java.nio.ByteBuffer input)
        Description copied from interface: StatelessLongHash
        Evaluates this hash function with the remaining contents of the given input buffer. This method leaves the buffer position at the limit.
        Specified by:
        calculate in interface StatelessLongHash
        Parameters:
        input - the input buffer
        Returns:
        the output of the hash function
      • calculate

        public long calculate​(long address,
                              long length)
        Description copied from interface: StatelessLongHash
        Evaluates this hash function for the memory with the given address and length. The arguments are generally not checked in any way and will likely lead to a VM crash or undefined results if invalid.
        Specified by:
        calculate in interface StatelessLongHash
        Parameters:
        address - the base address of the input
        length - the length of the input
        Returns:
        the output of the hash function
        See Also:
        Hash.supportsUnsafe()
      • resume

        public long resume​(long current,
                           byte[] input)
        Description copied from interface: IncrementalLongHash
        Evaluates this hash function as if the entire given input array were appended to the previously hashed input.
        Specified by:
        resume in interface IncrementalLongHash
        Parameters:
        current - the hash output for input hashed so far
        input - the input array
        Returns:
        the output of the hash function for the concatenated input
      • resume

        public long resume​(long current,
                           byte[] input,
                           int index,
                           int length)
        Description copied from interface: IncrementalLongHash
        Evaluates this hash function as if the given range of the given input array were appended to the previously hashed input.
        Specified by:
        resume in interface IncrementalLongHash
        Parameters:
        current - the hash output for input hashed so far
        input - the input array
        index - the starting index of the first input byte
        length - the length of the input range
        Returns:
        the output of the hash function for the concatenated input
      • resume

        public long resume​(long current,
                           java.nio.ByteBuffer input)
        Description copied from interface: IncrementalLongHash
        Evaluates this hash function as if the remaining contents of the given input buffer were appended to the previously hashed input. This method leaves the buffer position at the limit.
        Specified by:
        resume in interface IncrementalLongHash
        Parameters:
        current - the hash output for input hashed so far
        input - the input buffer
        Returns:
        the output of the hash function for the concatenated input
      • resume

        public long resume​(long current,
                           long address,
                           long length)
        Description copied from interface: IncrementalLongHash
        Evaluates this hash function as if the memory with the given address and length were appended to the previously hashed input. The arguments are generally not checked in any way and will likely lead to a VM crash or undefined results if invalid.
        Specified by:
        resume in interface IncrementalLongHash
        Parameters:
        current - the hash output for input hashed so far
        address - the base address of the input
        length - the length of the input
        Returns:
        the output of the hash function for the concatenated input
        See Also:
        Hash.supportsUnsafe()
      • initial

        protected abstract long initial()
        The initial state of the hash function, which is the same as the output value for an empty input sequence.
        Returns:
        the initial hash state/output
      • resumeUnchecked

        protected abstract long resumeUnchecked​(long current,
                                                byte[] input,
                                                int index,
                                                int length)
        Evaluates this hash function as if the given range of the given input array were appended to the previously hashed input. The index and length parameters have already been validated.
        Parameters:
        current - the hash output for input hashed so far
        input - the input array
        index - the starting index of the first input byte
        length - the length of the input range
        Returns:
        the output of the hash function for the concatenated input