Class NumberType<T extends Number>

java.lang.Object
org.apache.cassandra.db.marshal.AbstractType<T>
org.apache.cassandra.db.marshal.NumberType<T>
All Implemented Interfaces:
Comparator<ByteBuffer>, AssignmentTestable
Direct Known Subclasses:
ByteType, CounterColumnType, DecimalType, DoubleType, FloatType, Int32Type, IntegerType, LongType, ShortType

public abstract class NumberType<T extends Number> extends AbstractType<T>
Base type for the numeric types.
  • Constructor Details

  • Method Details

    • isFloatingPoint

      public boolean isFloatingPoint()
      Checks if this type support floating point numbers.
      Returns:
      true if this type support floating point numbers, false otherwise.
    • add

      public abstract ByteBuffer add(Number left, Number right)
      Adds the left argument to the right one.
      Parameters:
      left - the left argument
      right - the right argument
      Returns:
      the addition result
    • substract

      public abstract ByteBuffer substract(Number left, Number right)
      Substracts the left argument from the right one.
      Parameters:
      left - the left argument
      right - the right argument
      Returns:
      the substraction result
    • multiply

      public abstract ByteBuffer multiply(Number left, Number right)
      Multiplies the left argument with the right one.
      Parameters:
      left - the left argument
      right - the right argument
      Returns:
      the multiplication result
    • divide

      public abstract ByteBuffer divide(Number left, Number right)
      Divides the left argument by the right one.
      Parameters:
      left - the left argument
      right - the right argument
      Returns:
      the division result
    • mod

      public abstract ByteBuffer mod(Number left, Number right)
      Return the remainder.
      Parameters:
      left - the left argument
      right - the right argument
      Returns:
      the remainder
    • negate

      public abstract ByteBuffer negate(Number input)
      Negates the argument.
      Parameters:
      input - the argument to negate
      Returns:
      the negated argument
    • abs

      public abstract ByteBuffer abs(Number input)
      Takes the absolute value of the argument.
      Parameters:
      input - the argument to take the absolute value of
      Returns:
      a ByteBuffer containing the absolute value of the argument. The type of the contents of the ByteBuffer will match that of the input.
    • exp

      public abstract ByteBuffer exp(Number input)
      Raises e to the power of the argument.
      Parameters:
      input - the argument to raise e to
      Returns:
      a ByteBuffer containg the value of e (the base of natural logarithms) raised to the power of the argument. The type of the contents of the ByteBuffer will be a double, unless the input is a DecimalType or IntegerType, in which the ByteBuffer will contain a DecimalType.
    • log

      public abstract ByteBuffer log(Number input)
      Takes the natural logrithm of the argument.
      Parameters:
      input - the argument to take the natural log (ln) of
      Returns:
      a ByteBuffer containg the log base e (ln) of the argument. The type of the contents of the ByteBuffer will be a double, unless the input is a DecimalType or IntegerType, in which the ByteBuffer will contain a DecimalType.
    • log10

      public abstract ByteBuffer log10(Number input)
      Takes the log base 10 of the arguement.
      Parameters:
      input - the argument to take the log base ten of
      Returns:
      a ByteBuffer containg the log base 10 of the argument. The type of the contents of the ByteBuffer will be a double, unless the input is a DecimalType or IntegerType, in which the ByteBuffer will contain a DecimalType.
    • round

      public abstract ByteBuffer round(Number input)
      Rounds the argument to the nearest whole number.
      Parameters:
      input - the argument to round
      Returns:
      a ByteBuffer containg the rounded argument. If the input is an integral type, the ByteBuffer will contain a copy of the input. If the input is a float, the ByteBuffer will contain an int32. If the input is a double, the output will contain a long. If the input is a DecimalType, the output will contain an IntegerType.