Package org.apache.cassandra.db.marshal
Class AbstractCompositeType
- java.lang.Object
-
- org.apache.cassandra.db.marshal.AbstractType<java.nio.ByteBuffer>
-
- org.apache.cassandra.db.marshal.AbstractCompositeType
-
- All Implemented Interfaces:
java.util.Comparator<java.nio.ByteBuffer>
,AssignmentTestable
- Direct Known Subclasses:
CompositeType
,DynamicCompositeType
public abstract class AbstractCompositeType extends AbstractType<java.nio.ByteBuffer>
A class avoiding class duplication between CompositeType and DynamicCompositeType. Those two differs only in that for DynamicCompositeType, the comparators are in the encoded column name at the front of each component.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
AbstractCompositeType.ParsedComparator
-
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 inherited from class org.apache.cassandra.db.marshal.AbstractType
comparatorSet, comparisonType, isByteOrderComparable, reverseComparator
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractCompositeType()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <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 semanticsabstract java.nio.ByteBuffer
decompose(java.lang.Object... objects)
static java.lang.String
escape(java.lang.String input)
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.protected abstract <V> AbstractType<?>
getAndAppendComparator(int i, V value, ValueAccessor<V> accessor, java.lang.StringBuilder sb, int offset)
Adds type information from @param bb to @param sb.protected abstract <VL,VR>
AbstractType<?>getComparator(int i, VL left, ValueAccessor<VL> accessorL, VR right, ValueAccessor<VR> accessorR, int offsetL, int offsetR)
Adds DynamicCompositeType type information from @param bb1 to @param bb2.protected abstract <V> AbstractType<?>
getComparator(int i, V value, ValueAccessor<V> accessor, int offset)
protected abstract <V> int
getComparatorSize(int i, V value, ValueAccessor<V> accessor, int offset)
TypeSerializer<java.nio.ByteBuffer>
getSerializer()
<V> java.lang.String
getString(V input, ValueAccessor<V> accessor)
get a string representation of the bytes used for various identifier (NOT just for log messages)protected abstract AbstractCompositeType.ParsedComparator
parseComparator(int i, java.lang.String part)
Used by fromStringprotected abstract <V> boolean
readIsStatic(V value, ValueAccessor<V> accessor)
java.nio.ByteBuffer[]
split(java.nio.ByteBuffer bb)
Split a composite column names into it's components.protected abstract int
startingOffset(boolean isStatic)
java.lang.String
toJSONString(java.nio.ByteBuffer buffer, ProtocolVersion protocolVersion)
Converts the specified value into its JSON representation.void
validate(java.nio.ByteBuffer bb)
<V> void
validate(V input, ValueAccessor<V> accessor)
protected abstract <V> AbstractType<?>
validateComparator(int i, V value, ValueAccessor<V> accessor, int offset)
Like getComparator, but validates that @param i does not exceed the defined range-
Methods inherited from class org.apache.cassandra.db.marshal.AbstractType
asCQL3Type, asCQLTypeStringList, checkComparable, compare, compare, compareCollectionMembers, compareForCQL, compose, compose, decompose, expandUserTypes, freeze, freezeNestedMulticellTypes, getComponents, getString, getString, isCollection, isCompatibleWith, isCounter, isEmptyValueMeaningless, isFreezable, isFrozenCollection, isMultiCell, isReversed, isTuple, isUDT, isValueCompatibleWith, isValueCompatibleWithInternal, parseDefaultParameters, read, readArray, readBuffer, readBuffer, referencesDuration, referencesUserType, referencesUserType, skipValue, subTypes, testAssignment, testAssignment, toJSONString, toString, toString, validateCellValue, validateCollectionMember, valueLengthIfFixed, withUpdatedUserType, writeValue, writeValue, writtenLength, writtenLength
-
-
-
-
Method Detail
-
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.nio.ByteBuffer>
-
readIsStatic
protected abstract <V> boolean readIsStatic(V value, ValueAccessor<V> accessor)
-
startingOffset
protected abstract int startingOffset(boolean isStatic)
-
split
public java.nio.ByteBuffer[] split(java.nio.ByteBuffer bb)
Split a composite column names into it's components.
-
escape
public static java.lang.String escape(java.lang.String input)
-
getString
public <V> java.lang.String getString(V input, ValueAccessor<V> accessor)
Description copied from class:AbstractType
get a string representation of the bytes used for various identifier (NOT just for log messages)- Overrides:
getString
in classAbstractType<java.nio.ByteBuffer>
-
fromString
public java.nio.ByteBuffer fromString(java.lang.String source)
Description copied from class:AbstractType
get a byte representation of the given string.- Specified by:
fromString
in classAbstractType<java.nio.ByteBuffer>
-
fromJSONObject
public Term fromJSONObject(java.lang.Object parsed)
Description copied from class:AbstractType
Given a parsed JSON string, return a byte representation of the object.- Specified by:
fromJSONObject
in classAbstractType<java.nio.ByteBuffer>
- Parameters:
parsed
- the result of parsing a json string
-
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.nio.ByteBuffer>
- Parameters:
buffer
- the value to convertprotocolVersion
- the protocol version to use for the conversion- Returns:
- a JSON string representing the specified value
-
validate
public void validate(java.nio.ByteBuffer bb) throws MarshalException
- Overrides:
validate
in classAbstractType<java.nio.ByteBuffer>
- Throws:
MarshalException
-
validate
public <V> void validate(V input, ValueAccessor<V> accessor)
- Overrides:
validate
in classAbstractType<java.nio.ByteBuffer>
-
decompose
public abstract java.nio.ByteBuffer decompose(java.lang.Object... objects)
-
getSerializer
public TypeSerializer<java.nio.ByteBuffer> getSerializer()
- Specified by:
getSerializer
in classAbstractType<java.nio.ByteBuffer>
-
getComparatorSize
protected abstract <V> int getComparatorSize(int i, V value, ValueAccessor<V> accessor, int offset)
-
getComparator
protected abstract <V> AbstractType<?> getComparator(int i, V value, ValueAccessor<V> accessor, int offset)
- Parameters:
i
- DynamicCompositeType will read the type information from @param bbvalue
- name of type definition- Returns:
- the comparator for the given component. static CompositeType will consult
-
getComparator
protected abstract <VL,VR> AbstractType<?> getComparator(int i, VL left, ValueAccessor<VL> accessorL, VR right, ValueAccessor<VR> accessorR, int offsetL, int offsetR)
Adds DynamicCompositeType type information from @param bb1 to @param bb2.- Parameters:
i
- is ignored.
-
getAndAppendComparator
protected abstract <V> AbstractType<?> getAndAppendComparator(int i, V value, ValueAccessor<V> accessor, java.lang.StringBuilder sb, int offset)
Adds type information from @param bb to @param sb. @param i is ignored.
-
validateComparator
protected abstract <V> AbstractType<?> validateComparator(int i, V value, ValueAccessor<V> accessor, int offset) throws MarshalException
Like getComparator, but validates that @param i does not exceed the defined range- Throws:
MarshalException
-
parseComparator
protected abstract AbstractCompositeType.ParsedComparator parseComparator(int i, java.lang.String part)
Used by fromString
-
-