Class CassandraUInt

java.lang.Object
org.apache.cassandra.utils.CassandraUInt

public class CassandraUInt extends 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 final long
    Returns the long representation of the maximum value we can hold
    static final int
    Returns the UInt representation of the maximum value we can hold
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    compare(int x, int y)
    Compare 2 Uints
    static int
    fromLong(long value)
    Converts a long to it's unsigned integer representation
    static int[]
    fromLong(long[] values)
    The same but works on an array on longs
    static long
    toLong(int value)
    Returns the long resulting from parsing the int as an unsigned integer

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_VALUE_LONG

      public static final long MAX_VALUE_LONG
      Returns the long representation of the maximum value we can hold
    • MAX_VALUE_UINT

      public static final int MAX_VALUE_UINT
      Returns 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