public class Distribution
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
partitionCount |
private long |
partitionMask |
private long |
partitionSize |
private int |
shiftLength |
private int |
verticalPartitionExponent |
Constructor and Description |
---|
Distribution(int verticalPartitionExponent) |
Modifier and Type | Method and Description |
---|---|
static long |
horizontalDHTDistance(byte[] from,
byte[] to)
the horizontal DHT distance is the cardinal number between the cardinal position of the hashes of two objects in the DHT
Since the DHT is closed at the end, a cardinal at the high-end of 0..Long.MAX_VALUE can be very close to a low cardinal number.
|
static long |
horizontalDHTDistance(long fromPos,
long toPos)
the horizontalDHTDistance computes the closed-at-the-end ordering of two cardinal DHT positions
|
static long |
horizontalDHTPosition(byte[] wordHash)
the horizontal DHT position uses simply the ordering on hashes, the base 64 order to assign a cardinal
in the range of 0..Long.MAX_VALUE to the word.
|
static void |
main(java.lang.String[] args) |
static byte[] |
positionToHash(long l)
the reverse function to horizontalDHTPosition
This is a bit fuzzy since the horizontalDHTPosition cannot represent all 72 bits of the word hash (Yes, its a HASH!)
|
int |
verticalDHTPosition(byte[] urlHash)
compute the vertical position of a url hash.
|
long |
verticalDHTPosition(byte[] wordHash,
int verticalPosition)
compute a vertical DHT position for a given word
This is used when a word is searched and the peers holding the word must be computed
|
long |
verticalDHTPosition(byte[] wordHash,
java.lang.String urlHash)
the partition size is (Long.MAX + 1) / 2 ** e == 2 ** (63 - e)
compute the position using a specific fragment of the word hash and the url hash:
- from the word hash take the 63 -
|
int |
verticalPartitions() |
private final int verticalPartitionExponent
private final int shiftLength
private final int partitionCount
private final long partitionSize
private final long partitionMask
public Distribution(int verticalPartitionExponent)
verticalPartitionExponent,
- the number of partitions should be computed with partitions = 2**n, n = scaling factorpublic int verticalPartitions()
public static final long horizontalDHTPosition(byte[] wordHash)
wordHash
- public static final long horizontalDHTDistance(byte[] from, byte[] to)
from
- the start DHT position as word hashto
- the end DHT position as word hashpublic static final long horizontalDHTDistance(long fromPos, long toPos)
fromPos
- the start DHT position as cardinal of the word hashtoPos
- the end DHT position as cardinal of the word hashpublic static final byte[] positionToHash(long l)
l
- the cardinal position in the DHTpublic final long verticalDHTPosition(byte[] wordHash, java.lang.String urlHash)
wordHash
- urlHash
- public final long verticalDHTPosition(byte[] wordHash, int verticalPosition)
wordHash,
- the hash of the wordverticalPosition
- (0 <= verticalPosition < verticalPartitions())public final int verticalDHTPosition(byte[] urlHash)
urlHash
- public static void main(java.lang.String[] args)