Package com.scurrilous.circe.crc
Class Sse42Crc32C
- java.lang.Object
-
- com.scurrilous.circe.impl.AbstractIncrementalIntHash
-
- com.scurrilous.circe.crc.Sse42Crc32C
-
- All Implemented Interfaces:
Hash
,IncrementalIntHash
,StatelessHash
,StatelessIntHash
public final class Sse42Crc32C extends AbstractIncrementalIntHash implements IncrementalIntHash
Implementation of CRC-32C using the SSE 4.2 CRC instruction.
-
-
Constructor Summary
Constructors Constructor Description Sse42Crc32C()
Sse42Crc32C(int[] chunkWords)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
algorithm()
Returns the canonical name of this hash algorithm.int
calculate(long address, long length)
Evaluates this hash function for the memory with the given address and length.protected void
finalize()
protected int
initial()
The initial state of the hash function, which is the same as the output value for an empty input sequence.static boolean
isSupported()
Returns whether SSE 4.2 CRC-32C is supported on this system.int
length()
Returns the length in bytes of the output of this hash function.int
resume(int 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.int
resume(int 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 int
resumeUnchecked(int 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 asStatefulHash.update(long, long)
,StatelessIntHash.calculate(long, long)
, orIncrementalIntHash.resume(int, long, long)
.-
Methods inherited from class com.scurrilous.circe.impl.AbstractIncrementalIntHash
calculate, calculate, calculate, createStateful, resume, resume
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.scurrilous.circe.IncrementalIntHash
resume, resume
-
Methods inherited from interface com.scurrilous.circe.StatelessIntHash
calculate, calculate, calculate, createStateful
-
-
-
-
Method Detail
-
isSupported
public static boolean isSupported()
Returns whether SSE 4.2 CRC-32C is supported on this system.- Returns:
- true if this class is supported, false if not
-
finalize
protected void finalize()
- Overrides:
finalize
in classjava.lang.Object
-
algorithm
public java.lang.String algorithm()
Description copied from interface:Hash
Returns the canonical name of this hash algorithm.
-
length
public int length()
Description copied from interface:Hash
Returns the length in bytes of the output of this hash function.
-
supportsUnsafe
public boolean supportsUnsafe()
Description copied from interface:Hash
Returns whether this hash function supports unsafe access to arbitrary memory addresses using methods such asStatefulHash.update(long, long)
,StatelessIntHash.calculate(long, long)
, orIncrementalIntHash.resume(int, long, long)
. Such functions are generally implemented in native code.- Specified by:
supportsUnsafe
in interfaceHash
- Overrides:
supportsUnsafe
in classAbstractIncrementalIntHash
- Returns:
- true if unsafe access is supported, false if not
-
calculate
public int calculate(long address, long length)
Description copied from interface:StatelessIntHash
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 interfaceStatelessIntHash
- Overrides:
calculate
in classAbstractIncrementalIntHash
- Parameters:
address
- the base address of the inputlength
- the length of the input- Returns:
- the output of the hash function
- See Also:
Hash.supportsUnsafe()
-
resume
public int resume(int current, java.nio.ByteBuffer input)
Description copied from interface:IncrementalIntHash
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 interfaceIncrementalIntHash
- Overrides:
resume
in classAbstractIncrementalIntHash
- Parameters:
current
- the hash output for input hashed so farinput
- the input buffer- Returns:
- the output of the hash function for the concatenated input
-
resume
public int resume(int current, long address, long length)
Description copied from interface:IncrementalIntHash
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 interfaceIncrementalIntHash
- Overrides:
resume
in classAbstractIncrementalIntHash
- Parameters:
current
- the hash output for input hashed so faraddress
- the base address of the inputlength
- the length of the input- Returns:
- the output of the hash function for the concatenated input
- See Also:
Hash.supportsUnsafe()
-
initial
protected int initial()
Description copied from class:AbstractIncrementalIntHash
The initial state of the hash function, which is the same as the output value for an empty input sequence.- Specified by:
initial
in classAbstractIncrementalIntHash
- Returns:
- the initial hash state/output
-
resumeUnchecked
protected int resumeUnchecked(int current, byte[] input, int index, int length)
Description copied from class:AbstractIncrementalIntHash
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.- Specified by:
resumeUnchecked
in classAbstractIncrementalIntHash
- Parameters:
current
- the hash output for input hashed so farinput
- the input arrayindex
- the starting index of the first input bytelength
- the length of the input range- Returns:
- the output of the hash function for the concatenated input
-
-