public final class XXHashFactory
extends java.lang.Object
XXHash32 and StreamingXXHash32 instances.
This class has 3 instances
native instance which is a JNI binding to
the original LZ4 C implementation.
safe Java instance which is a pure Java port
of the original C library,unsafe Java instance which is a Java port
using the unofficial Unsafe API.
Only the safe instance is guaranteed to work on your
JVM, as a consequence it is advised to use the fastestInstance() or
fastestJavaInstance() to pull a XXHashFactory instance.
All methods from this class are very costly, so you should get an instance
once, and then reuse it whenever possible. This is typically done by storing
a XXHashFactory instance in a static field.
| Modifier and Type | Method and Description |
|---|---|
static XXHashFactory |
fastestInstance()
Returns the fastest available
XXHashFactory instance. |
static XXHashFactory |
fastestJavaInstance()
Returns the fastest available
XXHashFactory instance which does not
rely on JNI bindings. |
XXHash32 |
hash32()
Returns a
XXHash32 instance. |
XXHash64 |
hash64()
Returns a
XXHash64 instance. |
static void |
main(java.lang.String[] args)
Prints the fastest instance.
|
static XXHashFactory |
nativeInstance()
Returns a
XXHashFactory that returns XXHash32 instances that
are native bindings to the original C API. |
StreamingXXHash32 |
newStreamingHash32(int seed)
Return a new
StreamingXXHash32 instance. |
StreamingXXHash64 |
newStreamingHash64(long seed)
Return a new
StreamingXXHash64 instance. |
static XXHashFactory |
safeInstance()
Returns a
XXHashFactory that returns XXHash32 instances that
are written with Java's official API. |
java.lang.String |
toString() |
static XXHashFactory |
unsafeInstance()
|
public static XXHashFactory nativeInstance()
XXHashFactory that returns XXHash32 instances that
are native bindings to the original C API.
Please note that this instance has some traps you should be aware of:
XXHashFactory that returns XXHash32 instances that
are native bindings to the original C API.public static XXHashFactory safeInstance()
XXHashFactory that returns XXHash32 instances that
are written with Java's official API.XXHashFactory that returns XXHash32 instances that
are written with Java's official API.public static XXHashFactory unsafeInstance()
XXHashFactory that returns XXHash32 instances that
may use Unsafe to speed up hashing.public static XXHashFactory fastestJavaInstance()
XXHashFactory instance which does not
rely on JNI bindings. It first tries to load the
unsafe instance, and then the
safe Java instance if the JVM doesn't have a
working Unsafe.XXHashFactory instance which does not
rely on JNI bindings.public static XXHashFactory fastestInstance()
XXHashFactory instance. If the class
loader is the system class loader and if the
native instance loads successfully, then the
native instance is returned, otherwise the
fastest Java instance is returned.
Please read javadocs of nativeInstance() before
using this method.
XXHashFactory instance.public StreamingXXHash32 newStreamingHash32(int seed)
StreamingXXHash32 instance.seed - the seed to useStreamingXXHash32 instancepublic StreamingXXHash64 newStreamingHash64(long seed)
StreamingXXHash64 instance.seed - the seed to useStreamingXXHash64 instancepublic static void main(java.lang.String[] args)
args - no argument requiredpublic java.lang.String toString()
toString in class java.lang.Object