com.unister.semweb.drums.bucket.hashfunction
Class AbstractHashFunction
java.lang.Object
com.unister.semweb.drums.bucket.hashfunction.AbstractHashFunction
- All Implemented Interfaces:
- java.io.Serializable
- Direct Known Subclasses:
- RangeHashFunction
public abstract class AbstractHashFunction
- extends java.lang.Object
- implements java.io.Serializable
This abstract class reflects the usage of a consistent hash-function. To work properly, the number of buckets (
getNumberOfBuckets()
) and a mapping of a key to a bucket-id ( getBucketId(byte[])
) is needed.
- Author:
- Martin Nettling
- See Also:
- Serialized Form
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractHashFunction
public AbstractHashFunction()
getNumberOfBuckets
public int getNumberOfBuckets()
- Returns:
- the number of buckets, addressed by this hash-function
getBucketId
public abstract int getBucketId(byte[] key)
- Parameters:
key
- the key to map to a bucket-id
- Returns:
- the bucket-id belonging to the given key
getBucketId
public abstract int getBucketId(AbstractKVStorable key)
- Parameters:
key
- the element containing the key to map a bucket-id
- Returns:
- the bucket-id belonging to the given
AbstractKVStorable
getFilename
public abstract java.lang.String getFilename(int bucketId)
- Parameters:
bucketId
-
- Returns:
- the filename of the bucket for the given bucket-id.
getBucketId
public abstract int getBucketId(java.lang.String dbFilename)
- Parameters:
dbFilename
-
- Returns:
- the bucket-id of the bucket belonging to the given filename.
store
public abstract void store(java.io.OutputStream os)
throws java.io.IOException
- Writes this hashfunction to the given
OutputStream
- Parameters:
os
-
- Throws:
java.io.IOException
load
public abstract void load(java.io.InputStream in)
throws java.io.IOException
- Loads the hashfunction from the given
InputStream
- Parameters:
in
-
- Throws:
java.io.IOException