Package org.apache.cassandra.db.marshal
Class Int32Type
- java.lang.Object
-
- org.apache.cassandra.db.marshal.AbstractType<T>
-
- org.apache.cassandra.db.marshal.NumberType<java.lang.Integer>
-
- org.apache.cassandra.db.marshal.Int32Type
-
- All Implemented Interfaces:
java.util.Comparator<java.nio.ByteBuffer>
,AssignmentTestable
public class Int32Type extends NumberType<java.lang.Integer>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.cassandra.db.marshal.AbstractType
AbstractType.ComparisonType
-
Nested classes/interfaces inherited from interface org.apache.cassandra.cql3.AssignmentTestable
AssignmentTestable.TestResult
-
-
Field Summary
Fields Modifier and Type Field Description static Int32Type
instance
-
Fields inherited from class org.apache.cassandra.db.marshal.AbstractType
comparatorSet, comparisonType, isByteOrderComparable, reverseComparator
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.ByteBuffer
add(NumberType<?> leftType, java.nio.ByteBuffer left, NumberType<?> rightType, java.nio.ByteBuffer right)
Adds the left argument to the right one.CQL3Type
asCQL3Type()
<VL,VR>
intcompareCustom(VL left, ValueAccessor<VL> accessorL, VR right, ValueAccessor<VR> accessorR)
Implement IFF ComparisonType is CUSTOM Compares the byte representation of two instances of this class, for types where this cannot be done by simple in-order comparison of the unsigned bytes Standard Java compare semanticsjava.nio.ByteBuffer
divide(NumberType<?> leftType, java.nio.ByteBuffer left, NumberType<?> rightType, java.nio.ByteBuffer right)
Divides the left argument by the right one.Term
fromJSONObject(java.lang.Object parsed)
Given a parsed JSON string, return a byte representation of the object.java.nio.ByteBuffer
fromString(java.lang.String source)
get a byte representation of the given string.TypeSerializer<java.lang.Integer>
getSerializer()
boolean
isEmptyValueMeaningless()
java.nio.ByteBuffer
mod(NumberType<?> leftType, java.nio.ByteBuffer left, NumberType<?> rightType, java.nio.ByteBuffer right)
Return the remainder.java.nio.ByteBuffer
multiply(NumberType<?> leftType, java.nio.ByteBuffer left, NumberType<?> rightType, java.nio.ByteBuffer right)
Multiplies the left argument with the right one.java.nio.ByteBuffer
negate(java.nio.ByteBuffer input)
Negates the argument.java.nio.ByteBuffer
substract(NumberType<?> leftType, java.nio.ByteBuffer left, NumberType<?> rightType, java.nio.ByteBuffer right)
Substracts the left argument from the right one.protected float
toFloat(java.nio.ByteBuffer value)
Converts the specified value into afloat
if allowed.protected int
toInt(java.nio.ByteBuffer value)
Converts the specified value into anint
if allowed.java.lang.String
toJSONString(java.nio.ByteBuffer buffer, ProtocolVersion protocolVersion)
Converts the specified value into its JSON representation.int
valueLengthIfFixed()
The length of values for this type if all values are of fixed length, -1 otherwise.-
Methods inherited from class org.apache.cassandra.db.marshal.NumberType
isFloatingPoint, toBigDecimal, toBigInteger, toByte, toDouble, toLong, toShort
-
Methods inherited from class org.apache.cassandra.db.marshal.AbstractType
asCQLTypeStringList, checkComparable, compare, compare, compareCollectionMembers, compareForCQL, compose, compose, decompose, expandUserTypes, freeze, freezeNestedMulticellTypes, getComponents, getString, getString, getString, isCollection, isCompatibleWith, isCounter, isFreezable, isFrozenCollection, isMultiCell, isReversed, isTuple, isUDT, isValueCompatibleWith, isValueCompatibleWithInternal, parseDefaultParameters, read, readArray, readBuffer, readBuffer, referencesDuration, referencesUserType, referencesUserType, skipValue, subTypes, testAssignment, testAssignment, toJSONString, toString, toString, validate, validate, validateCellValue, validateCollectionMember, withUpdatedUserType, writeValue, writeValue, writtenLength, writtenLength
-
-
-
-
Field Detail
-
instance
public static final Int32Type instance
-
-
Method Detail
-
isEmptyValueMeaningless
public boolean isEmptyValueMeaningless()
Description copied from class:AbstractType
- Overrides:
isEmptyValueMeaningless
in classAbstractType<java.lang.Integer>
-
compareCustom
public <VL,VR> int compareCustom(VL left, ValueAccessor<VL> accessorL, VR right, ValueAccessor<VR> accessorR)
Description copied from class:AbstractType
Implement IFF ComparisonType is CUSTOM Compares the byte representation of two instances of this class, for types where this cannot be done by simple in-order comparison of the unsigned bytes Standard Java compare semantics- Overrides:
compareCustom
in classAbstractType<java.lang.Integer>
-
fromString
public java.nio.ByteBuffer fromString(java.lang.String source) throws MarshalException
Description copied from class:AbstractType
get a byte representation of the given string.- Specified by:
fromString
in classAbstractType<java.lang.Integer>
- Throws:
MarshalException
-
fromJSONObject
public Term fromJSONObject(java.lang.Object parsed) throws MarshalException
Description copied from class:AbstractType
Given a parsed JSON string, return a byte representation of the object.- Specified by:
fromJSONObject
in classAbstractType<java.lang.Integer>
- Parameters:
parsed
- the result of parsing a json string- Throws:
MarshalException
-
toJSONString
public java.lang.String toJSONString(java.nio.ByteBuffer buffer, ProtocolVersion protocolVersion)
Description copied from class:AbstractType
Converts the specified value into its JSON representation.The buffer position will stay the same.
- Overrides:
toJSONString
in classAbstractType<java.lang.Integer>
- Parameters:
buffer
- the value to convertprotocolVersion
- the protocol version to use for the conversion- Returns:
- a JSON string representing the specified value
-
asCQL3Type
public CQL3Type asCQL3Type()
- Overrides:
asCQL3Type
in classAbstractType<java.lang.Integer>
-
getSerializer
public TypeSerializer<java.lang.Integer> getSerializer()
- Specified by:
getSerializer
in classAbstractType<java.lang.Integer>
-
valueLengthIfFixed
public int valueLengthIfFixed()
Description copied from class:AbstractType
The length of values for this type if all values are of fixed length, -1 otherwise.- Overrides:
valueLengthIfFixed
in classAbstractType<java.lang.Integer>
-
toInt
protected int toInt(java.nio.ByteBuffer value)
Description copied from class:NumberType
Converts the specified value into anint
if allowed.- Overrides:
toInt
in classNumberType<java.lang.Integer>
- Parameters:
value
- the value to convert- Returns:
- the converted value
-
toFloat
protected float toFloat(java.nio.ByteBuffer value)
Description copied from class:NumberType
Converts the specified value into afloat
if allowed.- Overrides:
toFloat
in classNumberType<java.lang.Integer>
- Parameters:
value
- the value to convert- Returns:
- the converted value
-
add
public java.nio.ByteBuffer add(NumberType<?> leftType, java.nio.ByteBuffer left, NumberType<?> rightType, java.nio.ByteBuffer right)
Description copied from class:NumberType
Adds the left argument to the right one.- Specified by:
add
in classNumberType<java.lang.Integer>
- Parameters:
leftType
- the type associated to the left argumentleft
- the left argumentrightType
- the type associated to the right argumentright
- the right argument- Returns:
- the addition result
-
substract
public java.nio.ByteBuffer substract(NumberType<?> leftType, java.nio.ByteBuffer left, NumberType<?> rightType, java.nio.ByteBuffer right)
Description copied from class:NumberType
Substracts the left argument from the right one.- Specified by:
substract
in classNumberType<java.lang.Integer>
- Parameters:
leftType
- the type associated to the left argumentleft
- the left argumentrightType
- the type associated to the right argumentright
- the right argument- Returns:
- the substraction result
-
multiply
public java.nio.ByteBuffer multiply(NumberType<?> leftType, java.nio.ByteBuffer left, NumberType<?> rightType, java.nio.ByteBuffer right)
Description copied from class:NumberType
Multiplies the left argument with the right one.- Specified by:
multiply
in classNumberType<java.lang.Integer>
- Parameters:
leftType
- the type associated to the left argumentleft
- the left argumentrightType
- the type associated to the right argumentright
- the right argument- Returns:
- the multiplication result
-
divide
public java.nio.ByteBuffer divide(NumberType<?> leftType, java.nio.ByteBuffer left, NumberType<?> rightType, java.nio.ByteBuffer right)
Description copied from class:NumberType
Divides the left argument by the right one.- Specified by:
divide
in classNumberType<java.lang.Integer>
- Parameters:
leftType
- the type associated to the left argumentleft
- the left argumentrightType
- the type associated to the right argumentright
- the right argument- Returns:
- the division result
-
mod
public java.nio.ByteBuffer mod(NumberType<?> leftType, java.nio.ByteBuffer left, NumberType<?> rightType, java.nio.ByteBuffer right)
Description copied from class:NumberType
Return the remainder.- Specified by:
mod
in classNumberType<java.lang.Integer>
- Parameters:
leftType
- the type associated to the left argumentleft
- the left argumentrightType
- the type associated to the right argumentright
- the right argument- Returns:
- the remainder
-
negate
public java.nio.ByteBuffer negate(java.nio.ByteBuffer input)
Description copied from class:NumberType
Negates the argument.- Specified by:
negate
in classNumberType<java.lang.Integer>
- Parameters:
input
- the argument to negate- Returns:
- the negated argument
-
-