Package org.apache.cassandra.utils
Class CassandraUInt
- java.lang.Object
-
- org.apache.cassandra.utils.CassandraUInt
-
public class CassandraUInt extends java.lang.Object
This class packages several UInt utility methods so we can easily change it's implementation when needed.
-
-
Field Summary
Fields Modifier and Type Field Description static long
MAX_VALUE_LONG
Returns the long representation of the maximum value we can holdstatic int
MAX_VALUE_UINT
Returns the UInt representation of the maximum value we can hold
-
Constructor Summary
Constructors Constructor Description CassandraUInt()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
compare(int x, int y)
Compare 2 Uintsstatic int
fromLong(long value)
Converts a long to it's unsigned integer representationstatic int[]
fromLong(long[] values)
The same but works on an array on longsstatic long
toLong(int value)
Returns the long resulting from parsing the int as an unsigned integer
-
-
-
Method Detail
-
fromLong
public static int fromLong(long value)
Converts a long to it's unsigned integer representation- Parameters:
value
- A long between 0 and 232-1 inclusive- Returns:
- an unsigned integer representation of the long
- Throws:
java.lang.IllegalArgumentException
- if value '< 0' or '>= 232'
-
fromLong
public static int[] fromLong(long[] values)
The same but works on an array on longs
-
toLong
public static long toLong(int value)
Returns the long resulting from parsing the int as an unsigned integer- Parameters:
value
- Unsigned integer representation of the long- Returns:
- The long resulting from parsing the int as an unsigned integer
-
compare
public static int compare(int x, int y)
Compare 2 Uints- Returns:
- < 0 if x is less than y. > 0 if x is greater than y. Zero if they are equal
-
-