Package org.apache.cassandra.utils
Class CassandraUInt
java.lang.Object
org.apache.cassandra.utils.CassandraUInt
This class packages several UInt utility methods so we can easily change it's implementation when needed.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longReturns the long representation of the maximum value we can holdstatic final intReturns the UInt representation of the maximum value we can hold -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcompare(int x, int y) Compare 2 Uintsstatic intfromLong(long value) Converts a long to it's unsigned integer representationstatic int[]fromLong(long[] values) The same but works on an array on longsstatic longtoLong(int value) Returns the long resulting from parsing the int as an unsigned integer
-
Field Details
-
MAX_VALUE_LONG
public static final long MAX_VALUE_LONGReturns the long representation of the maximum value we can hold -
MAX_VALUE_UINT
public static final int MAX_VALUE_UINTReturns the UInt representation of the maximum value we can hold
-
-
Constructor Details
-
CassandraUInt
public CassandraUInt()
-
-
Method Details
-
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:
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
-