Package gw.util.fingerprint
Class FP64
- java.lang.Object
-
- gw.util.fingerprint.FP64
-
public final class FP64 extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private long_fpprivate static long[]ByteModTableprivate static longIrredPolyprivate static java.lang.StringLEADING_ZEROSprivate static longOneprivate static longX63private static longZero
-
Constructor Summary
Constructors Constructor Description FP64()Initializes this object to the fingerprint of the empty string.FP64(byte[] bytes)Initializes this object to the fingerprint of the byte arraybytes, which must be non-null.FP64(byte[] bytes, int start, int length)Initializes this object to the fingerprint of the bytesbytes[start]..bytes[start+length-1].FP64(char[] chars)Initializes this object to the fingerprint of the character arraychars, which must be non-null.FP64(char[] chars, int start, int length)Initializes this object to the fingerprint of the characterschars[start]..chars[start+length-1].FP64(FP64 fp)Initializes this fingerprint to a copy offp, which must be non-null.FP64(java.io.InputStream stream)Initializes this object to the fingerprint of the bytes instream, which must be non-null.FP64(java.lang.String s)Initializes this object to the fingerprint of the Strings, which must be non-null.FP64(java.nio.ByteBuffer buffer)Initializes this object to the fingerprint of the bytes inbuffer, which must be non-null.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)FP64extend(byte b)Extends this fingerprint by the byteb.FP64extend(byte[] bytes)Extends this fingerprint by the bytesFP64extend(byte[] bytes, int start, int len)Extends this fingerprint by the bytesbytes[offset]..bytes[offset+length-1].FP64extend(char c)Extends this fingerprint by the characterc.FP64extend(char[] chars)Extends this fingerprint by the characterschars[start]..chars[start+length-1].FP64extend(char[] chars, int start, int len)Extends this fingerprint by the characterschars[start]..chars[start+length-1].FP64extend(int i)Extends this fingerprint by the integeri.FP64extend(long i)Extends this fingerprint by the integeri.FP64extend(java.io.InputStream stream)Extends this fingerprint by the bytes of the streamstream, which must be non-null.FP64extend(java.lang.String s)Extends this fingerprint by the characters of the Strings, which must be non-null.FP64extend(java.nio.ByteBuffer buffer)longgetRawFingerprint()inthashCode()byte[]toBytes()Returns the value of this fingerprint as a newly-allocated array of 8 bytes.byte[]toBytes(byte[] buff)Returns the value of this fingerprint as an 8-byte array.java.lang.StringtoHexString()Returns the value of this fingerprint as an unsigned integer encoded in base 16 (hexideicmal), padded with leading zeros to a total length of 16 characters.java.lang.StringtoString()
-
-
-
Field Detail
-
_fp
private long _fp
-
LEADING_ZEROS
private static final java.lang.String LEADING_ZEROS
- See Also:
- Constant Field Values
-
Zero
private static final long Zero
- See Also:
- Constant Field Values
-
One
private static final long One
- See Also:
- Constant Field Values
-
IrredPoly
private static final long IrredPoly
- See Also:
- Constant Field Values
-
X63
private static final long X63
- See Also:
- Constant Field Values
-
ByteModTable
private static long[] ByteModTable
-
-
Constructor Detail
-
FP64
public FP64()
Initializes this object to the fingerprint of the empty string.
-
FP64
public FP64(FP64 fp)
Initializes this fingerprint to a copy offp, which must be non-null.
-
FP64
public FP64(java.lang.String s)
Initializes this object to the fingerprint of the Strings, which must be non-null.
-
FP64
public FP64(char[] chars)
Initializes this object to the fingerprint of the character arraychars, which must be non-null.
-
FP64
public FP64(char[] chars, int start, int length)Initializes this object to the fingerprint of the characterschars[start]..chars[start+length-1].
-
FP64
public FP64(byte[] bytes)
Initializes this object to the fingerprint of the byte arraybytes, which must be non-null.
-
FP64
public FP64(byte[] bytes, int start, int length)Initializes this object to the fingerprint of the bytesbytes[start]..bytes[start+length-1].
-
FP64
public FP64(java.io.InputStream stream) throws java.io.IOExceptionInitializes this object to the fingerprint of the bytes instream, which must be non-null.- Throws:
java.io.IOException- if an error is encountered readingstream.
-
FP64
public FP64(java.nio.ByteBuffer buffer) throws java.io.IOExceptionInitializes this object to the fingerprint of the bytes inbuffer, which must be non-null.- Throws:
java.io.IOException- if an error is encountered readingstream.
-
-
Method Detail
-
toBytes
public byte[] toBytes()
Returns the value of this fingerprint as a newly-allocated array of 8 bytes.Important: If the output of this function is subsequently fingerprinted, the probabilistic guarantee is lost. That is, there is a much higher liklihood of fingerprint collisions if fingerprint values are themselves fingerprinted in any way.
-
toBytes
public byte[] toBytes(byte[] buff)
Returns the value of this fingerprint as an 8-byte array. UnliketoBytes(), this variant does not perform an allocation. Instead, the client passes in a buffer into which the fingerprint value is written. This can be used to get the values of a set of fingerprints without having to perform an allocation for each one.- Parameters:
buff- The buffer into which the bytes will be written. This array is required to be non-null and exactly 8 bytes in length. This buffer is returned.
-
toHexString
public java.lang.String toHexString()
Returns the value of this fingerprint as an unsigned integer encoded in base 16 (hexideicmal), padded with leading zeros to a total length of 16 characters.Important: If the output of this function is subsequently fingerprinted, the probabilistic guarantee is lost. That is, there is a much higher liklihood of fingerprint collisions if fingerprint values are themselves fingerprinted in any way.
-
extend
public FP64 extend(java.lang.String s)
Extends this fingerprint by the characters of the Strings, which must be non-null.- Returns:
- the resulting fingerprint.
-
extend
public FP64 extend(char[] chars)
Extends this fingerprint by the characterschars[start]..chars[start+length-1].- Returns:
- the resulting fingerprint.
-
extend
public FP64 extend(char[] chars, int start, int len)
Extends this fingerprint by the characterschars[start]..chars[start+length-1].- Returns:
- the resulting fingerprint.
-
extend
public FP64 extend(byte[] bytes, int start, int len)
Extends this fingerprint by the bytesbytes[offset]..bytes[offset+length-1].- Returns:
- the resulting fingerprint.
-
extend
public FP64 extend(byte[] bytes)
Extends this fingerprint by the bytes- Returns:
- the resulting fingerprint.
-
extend
public FP64 extend(int i)
Extends this fingerprint by the integeri.- Returns:
- the resulting fingerprint.
-
extend
public FP64 extend(long i)
Extends this fingerprint by the integeri.- Returns:
- the resulting fingerprint.
-
extend
public FP64 extend(char c)
Extends this fingerprint by the characterc.- Returns:
- the resulting fingerprint.
-
extend
public FP64 extend(byte b)
Extends this fingerprint by the byteb.- Returns:
- the resulting fingerprint.
-
extend
public FP64 extend(java.io.InputStream stream) throws java.io.IOException
Extends this fingerprint by the bytes of the streamstream, which must be non-null.- Returns:
- the resulting fingerprint.
- Throws:
java.io.IOException- if an error is encountered readingstream.
-
extend
public FP64 extend(java.nio.ByteBuffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
getRawFingerprint
public long getRawFingerprint()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-