|
Rice Pastry API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--rice.pastry.Id
Represents a Pastry identifier for a node, object or key. A single identifier and the bit length for Ids is stored in this class. Ids are stored little endian.
Nested Class Summary | |
static class |
Id.Distance
A class for representing and manipulating the distance between two Ids on the circle. |
Field Summary | |
static int[] |
Half
|
static int |
IdBitLength
This is the bit length of the node ids. |
static int[] |
NegOne
|
static int[] |
Null
|
static int[] |
One
|
Constructor Summary | |
Id()
Constructor. |
|
Id(byte[] material)
Constructor. |
|
Id(int[] material)
Constructor. |
Method Summary | |
rice.pastry.Id |
add(Id.Distance offset)
Returns an Id corresponding to this Id plus a given distance |
rice.p2p.commonapi.Id |
addToId(Id.Distance offset)
Returns an Id corresponding to this Id plus a given distance |
void |
blit(byte[] target)
Blits the Id into a target array. |
boolean |
checkBit(int i)
Checks if the ith bit is flipped. |
boolean |
clockwise(rice.pastry.Id nid)
Checks to see if the Id nid is clockwise or counterclockwise from this, on the ring. |
boolean |
clockwise(rice.p2p.commonapi.Id nid)
Checks to see if the Id nid is clockwise or counterclockwise from this, on the ring. |
int |
compareTo(java.lang.Object obj)
Comparison operator for Ids. |
byte[] |
copy()
Copy the Id into a freshly generated array. |
Id.Distance |
distance(rice.pastry.Id nid)
Returns the shorter numerical distance on the ring between a pair of Ids. |
Id.Distance |
distanceFromId(rice.p2p.commonapi.Id nid)
Returns the shorter numerical distance on the ring between a pair of Ids. |
boolean |
equals(rice.pastry.Id nid)
Equivalence relation for Ids. |
boolean |
equals(java.lang.Object obj)
Equality operator for Ids. |
rice.pastry.Id |
getAlternateId(int num,
int b,
int i)
produces a set of ids (keys) that are evenly distributed around the id ring. |
rice.pastry.Id |
getCCW()
gets the Id just counterclockwise from this |
rice.pastry.Id |
getCW()
gets the Id just clockwise from this |
int |
getDigit(int i,
int b)
Gets the ith digit in base 2^b. |
rice.pastry.Id |
getDomainPrefix(int row,
int column,
int suffixDigit,
int b)
produces a Id whose prefix up to row is identical to this, followed by a digit with value column, followed by a suffix of digits with value suffixDigits. |
int |
hashCode()
Hash codes for Ids. |
int |
indexOfMSDB(rice.pastry.Id nid)
Returns the index of the most significant differing bit (MSDB). |
int |
indexOfMSDD(rice.pastry.Id nid,
int base)
Returns the index of the most significant different digit (MSDD) in a given base. |
boolean |
isBetween(rice.pastry.Id ccw,
rice.pastry.Id cw)
Checks if this Id is between two given ids ccw (inclusive) and cw (exclusive) on the circle |
boolean |
isBetween(rice.p2p.commonapi.Id ccw,
rice.p2p.commonapi.Id cw)
Checks if this Id is between two given ids ccw (inclusive) and cw (exclusive) on the circle |
Id.Distance |
longDistance(rice.pastry.Id nid)
Returns the longer numerical distance on the ring between a pair of Ids. |
Id.Distance |
longDistanceFromId(rice.p2p.commonapi.Id nid)
Returns the longer numerical distance on the ring between a pair of Ids. |
static rice.pastry.Id |
makeRandomId(java.util.Random rng)
Creates a random Id. |
static int |
numDigits(int base)
return the number of digits in a given base |
void |
setBit(int i,
int v)
Sets the ith bit to a given value i = 0 is the least significant bit. |
void |
setDigit(int i,
int v,
int b)
Sets the ith digit in base 2^b. |
byte[] |
toByteArray()
Returns the byte array representation of this Id |
java.lang.String |
toString()
Returns a string representation of the Id in base 16. |
java.lang.String |
toStringFull()
Returns the complete represntation of this Id, in hex. |
void |
xor(rice.pastry.Id otherId)
Xor operator for Ids. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int[] Null
public static final int[] One
public static final int[] NegOne
public static final int[] Half
public static final int IdBitLength
Constructor Detail |
public Id(byte[] material)
material
- an array of length at least IdBitLength/8 containing raw Id material.public Id(int[] material)
material
- an array of length at least IdBitLength/32 containing raw Id material.public Id()
Method Detail |
public static int numDigits(int base)
base
- the number of bits in the base
public static rice.pastry.Id makeRandomId(java.util.Random rng)
rng
- random number generator
public rice.pastry.Id getCW()
public rice.pastry.Id getCCW()
public boolean isBetween(rice.pastry.Id ccw, rice.pastry.Id cw)
ccw
- the counterclockwise idcw
- the clockwise id
public int getDigit(int i, int b)
i
- which digit to get.b
- which power of 2 is the base to get it in.
public rice.pastry.Id getDomainPrefix(int row, int column, int suffixDigit, int b)
row
- the length of the prefixcolumn
- the value of the following digitsuffixDigit
- the value of the suffix digitsb
- power of 2 of the base
public rice.pastry.Id getAlternateId(int num, int b, int i)
num
- the number of Ids in the set (must be <= 2^b)b
- the routing base (as a power of 2)i
- the index of the requested member of the set (0<=ipublic boolean isBetween(rice.p2p.commonapi.Id ccw, rice.p2p.commonapi.Id cw)
isBetween
in interface Id
ccw
- the counterclockwise idcw
- the clockwise id
public void setBit(int i, int v)
i
- which bit to set.v
- new value of bitpublic void setDigit(int i, int v, int b)
i
- which digit to get.v
- the new value of the digitb
- which power of 2 is the base to get it in.public void blit(byte[] target)
target
- an array of length at least IdBitLength/8 for the Id to be stored in.public byte[] copy()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- a Id object
public int compareTo(java.lang.Object obj)
compareTo
in interface java.lang.Comparable
obj
- the Id to compare with.
public byte[] toByteArray()
toByteArray
in interface Id
public int hashCode()
hashCode
in class java.lang.Object
public rice.pastry.Id add(Id.Distance offset)
offset
- the distance to add
public Id.Distance distance(rice.pastry.Id nid)
nid
- the other node id.
public Id.Distance longDistance(rice.pastry.Id nid)
nid
- the other node id.
public void xor(rice.pastry.Id otherId)
otherId
- a Id objectpublic boolean equals(rice.pastry.Id nid)
nid
- the other node id.
public boolean clockwise(rice.pastry.Id nid)
nid
- The Id we are comparing to
public boolean checkBit(int i)
i
- which bit to check.
public int indexOfMSDB(rice.pastry.Id nid)
nid
- another node id to compare with.
public int indexOfMSDD(rice.pastry.Id nid, int base)
nid
- another node id to compare with.base
- the base (as a power of two) to compare in.
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toStringFull()
toStringFull
in interface Id
public boolean clockwise(rice.p2p.commonapi.Id nid)
clockwise
in interface Id
nid
- DESCRIBE THE PARAMETER
public rice.p2p.commonapi.Id addToId(Id.Distance offset)
addToId
in interface Id
offset
- the distance to add
public Id.Distance distanceFromId(rice.p2p.commonapi.Id nid)
distanceFromId
in interface Id
nid
- the other node id.
public Id.Distance longDistanceFromId(rice.p2p.commonapi.Id nid)
longDistanceFromId
in interface Id
nid
- the other node id.
|
Rice Pastry API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |