|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.unister.semweb.drums.bucket.hashfunction.AbstractHashFunction
com.unister.semweb.drums.bucket.hashfunction.RangeHashFunction
public class RangeHashFunction
This hashFunction maps an element to a specific range. The ranges are not overlapping. It is not needed, that the ranges are consecutive.
| Constructor Summary | |
|---|---|
RangeHashFunction(byte[][] rangeValues,
java.lang.String[] filenames,
java.lang.String hashFunctionFilename)
This method instantiates a new RangeHashFunction by the given rangeValues. |
|
RangeHashFunction(byte[] minKey,
byte[] maxKey,
int ranges,
java.lang.String hashFunctionFilename)
This constructor instantiates a new RangeHashFunction with the given number of ranges. |
|
RangeHashFunction(java.io.File file)
This method instantiates a new RangeHashFunction by the given File. |
|
RangeHashFunction(int ranges,
int keySize,
java.lang.String hashFunctionFilename)
This constructor instantiates a new RangeHashFunction with the given number of ranges. |
|
| Method Summary | |
|---|---|
RangeHashFunction |
copy()
Makes a copy of the current RangeHashFunction. |
int |
getBucketId(AbstractKVStorable key)
Gets the bucket id from the given date. |
int |
getBucketId(byte[] key)
Determines the bucket id to the given key. |
int |
getBucketId(java.lang.String dbFilename)
|
java.lang.String |
getFilename(int bucketId)
Get the file name of the given bucket. |
java.lang.String |
getHashFunctionFile()
Returns the File, where the HashFunction is stored human-readable |
byte[][] |
getRanges()
|
byte[] |
getUpperBound(int bucketId)
|
void |
load(java.io.InputStream in)
Loads the hashfunction from the given InputStream |
void |
replace(int bucketId,
byte[][] keysToInsert)
Replaces one bucket line within the RangeHashFunction with the lines given. |
void |
store(java.io.OutputStream os)
Writes this hashfunction to the given OutputStream |
static int |
stringToByteCount(java.lang.String code)
The header of could contain characters which are not numbers. |
java.lang.String |
toString()
|
void |
writeToFile()
Writes the hash function, represented as tuples (range, filename) into the file that is linked with the HashFunction. |
| Methods inherited from class com.unister.semweb.drums.bucket.hashfunction.AbstractHashFunction |
|---|
getNumberOfBuckets |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public RangeHashFunction(byte[] minKey,
byte[] maxKey,
int ranges,
java.lang.String hashFunctionFilename)
RangeHashFunction with the given number of ranges. It tries to size
all ranges equally between the smallest and the largest key.
minKey - the smallest expected keymaxKey - the largest expected keyranges - the number of rangeshashFunctionFilename - the filename of the file, where to store the hash-function
public RangeHashFunction(int ranges,
int keySize,
java.lang.String hashFunctionFilename)
RangeHashFunction with the given number of ranges. It tries to size
all ranges equally within the complete available space of numbers.
ranges - the number of rangeskeySize - the size in bytes of the keyhashFunctionFilename - the filename of the file, where to store the hash-function
public RangeHashFunction(byte[][] rangeValues,
java.lang.String[] filenames,
java.lang.String hashFunctionFilename)
RangeHashFunction by the given rangeValues. The given array should contain
only the maximal allowed value per bucket. The minimal value will be the direct successor of the previous maximal
value. Remember: the array will be handled circular.
rangeValues - the maximum keys for all bucketsfilenames - the filenames for all bucketshashFunctionFilename - the file name of the range hash function
public RangeHashFunction(java.io.File file)
throws java.io.IOException
RangeHashFunction by the given File. The File contains some long
values, which describe the maximal allowed values for the buckets. The minimal value will be the direct successor
of the previous maximal value. Remember: the array will be handled circular.
file - the file, which contains the maximal keys
java.io.IOException| Method Detail |
|---|
public java.lang.String getHashFunctionFile()
public byte[] getUpperBound(int bucketId)
bucketId -
public int getBucketId(byte[] key)
key.
getBucketId in class AbstractHashFunctionkey - the key to map to a bucket-id
public int getBucketId(AbstractKVStorable key)
getBucketId in class AbstractHashFunctionkey - the element containing the key to map a bucket-id
AbstractKVStorablepublic java.lang.String getFilename(int bucketId)
getFilename in class AbstractHashFunctionpublic java.lang.String toString()
toString in class java.lang.Objectpublic int getBucketId(java.lang.String dbFilename)
getBucketId in class AbstractHashFunction
public void replace(int bucketId,
byte[][] keysToInsert)
RangeHashFunction with the lines given. All added buckets are set to
the specified bucket size. If the bucketId that is to replaced is invalid a
IllegalArgumentException is thrown.
keysToInsert - bucketId - public byte[][] getRanges()
public RangeHashFunction copy()
RangeHashFunction. Note: the file name is also copied. Make sure that you
don't overwrite the file if you change one of the functions.
RangeHashFunctionpublic static int stringToByteCount(java.lang.String code)
code - the code to look for
public void writeToFile()
throws java.io.IOException
java.io.IOException
public void store(java.io.OutputStream os)
throws java.io.IOException
AbstractHashFunctionOutputStream
store in class AbstractHashFunctionjava.io.IOException
public void load(java.io.InputStream in)
throws java.io.IOException
AbstractHashFunctionInputStream
load in class AbstractHashFunctionjava.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||