public class Hasher extends Object implements UIDProducer
UIDProducer
.
The UIDs are produced by hash function. The implementation is not perfect,
in the sense that the provided mapping from tokens to UIDs is not surjective
nor it does avoid collisions.
For the collisions let's say that as we do not know the whole set of possible tokens,
construction of perfect hash function is not possible.
For the non-surjectivity of the mapping, I believe it is not a problem.
Currently there are implementations of DJB and SDBM algorithms. The type of algorithm
to be used must be declared on creating of the object of this class.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT
Constant for default hash algorith.
|
static int |
DJB
Constant for DJB hash algorith.
|
static int |
SDBM
Constant for SDBM hash algorith.
|
Constructor and Description |
---|
Hasher(int type)
Constructor sets the type of hash function to be used.
|
public static final int DJB
public static final int SDBM
public static final int DEFAULT
public Hasher(int type)
type
- constant of the class Hasherpublic int getType()
public long getUID(String str)
getUID
in interface UIDProducer
str
- Copyright © 2016 Egothor. All Rights Reserved.