Package org.apache.cassandra.db.marshal
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
Base type for the numeric types.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classNumberType.NumberArgumentDeserializer<M extends org.apache.commons.lang3.mutable.Mutable<Number>>Base class for numeric typeArgumentDeserializer.Nested classes/interfaces inherited from class org.apache.cassandra.db.marshal.AbstractType
AbstractType.ComparisonType, AbstractType.DefaultArgumentDeserializerNested classes/interfaces inherited from interface org.apache.cassandra.cql3.AssignmentTestable
AssignmentTestable.TestResult -
Field Summary
Fields inherited from class org.apache.cassandra.db.marshal.AbstractType
comparatorSet, comparisonType, isByteOrderComparable, reverseComparator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ByteBufferTakes the absolute value of the argument.abstract ByteBufferAdds the left argument to the right one.abstract ByteBufferDivides the left argument by the right one.abstract ByteBufferRaises e to the power of the argument.booleanChecks if this type support floating point numbers.abstract ByteBufferTakes the natural logrithm of the argument.abstract ByteBufferTakes the log base 10 of the arguement.abstract ByteBufferReturn the remainder.abstract ByteBufferMultiplies the left argument with the right one.abstract ByteBufferNegates the argument.abstract ByteBufferRounds the argument to the nearest whole number.abstract ByteBufferSubstracts the left argument from the right one.Methods inherited from class org.apache.cassandra.db.marshal.AbstractType
allowsEmpty, asComparableBytes, asComparableBytes, asCQL3Type, asCQLTypeStringList, checkComparable, compare, compare, compareCollectionMembers, compareCustom, compareForCQL, compose, compose, decompose, decomposeUntyped, expandUserTypes, freeze, freezeNestedMulticellTypes, fromComparableBytes, fromComparableBytes, fromJSONObject, fromString, getArgumentDeserializer, getCompatibleTypeIfKnown, getComponents, getMaskedValue, getSerializer, getString, getString, getString, isCollection, isCompatibleWith, isCounter, isEmptyValueMeaningless, isFreezable, isFrozenCollection, isMultiCell, isNull, isNull, isReversed, isSerializationCompatibleWith, isTuple, isUDT, isValueCompatibleWith, isValueCompatibleWithInternal, isValueLengthFixed, isVector, parseDefaultParameters, read, readArray, readBuffer, readBuffer, referencesDuration, referencesUserType, referencesUserType, skipValue, subTypes, testAssignment, testAssignment, toCQLString, toJSONString, toJSONString, toString, toString, udfType, unfreeze, unwrap, validate, validate, validateCellValue, validateCollectionMember, valueLengthIfFixed, withUpdatedUserType, writeValue, writeValue, writtenLength, writtenLengthMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
NumberType
-
-
Method Details
-
isFloatingPoint
public boolean isFloatingPoint()Checks if this type support floating point numbers.- Returns:
trueif this type support floating point numbers,falseotherwise.
-
add
Adds the left argument to the right one.- Parameters:
left- the left argumentright- the right argument- Returns:
- the addition result
-
substract
Substracts the left argument from the right one.- Parameters:
left- the left argumentright- the right argument- Returns:
- the substraction result
-
multiply
Multiplies the left argument with the right one.- Parameters:
left- the left argumentright- the right argument- Returns:
- the multiplication result
-
divide
Divides the left argument by the right one.- Parameters:
left- the left argumentright- the right argument- Returns:
- the division result
-
mod
Return the remainder.- Parameters:
left- the left argumentright- the right argument- Returns:
- the remainder
-
negate
Negates the argument.- Parameters:
input- the argument to negate- Returns:
- the negated argument
-
abs
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
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
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
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
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.
-