Package org.apache.cassandra.db.marshal
Class AbstractCompositeType
java.lang.Object
org.apache.cassandra.db.marshal.AbstractType<ByteBuffer>
org.apache.cassandra.db.marshal.AbstractCompositeType
- All Implemented Interfaces:
Comparator<ByteBuffer>,AssignmentTestable
- Direct Known Subclasses:
CompositeType,DynamicCompositeType
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 ClassesModifier and TypeClassDescriptionprotected static interfaceNested 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 TypeMethodDescriptionbooleanDefines if the type allows an empty set of bytes (new byte[0]) as valid input.<VL,VR> int compareCustom(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 ByteBufferstatic StringfromJSONObject(Object parsed) Given a parsed JSON string, return a byte representation of the object.fromString(String source) get a byte representation of the given string.protected abstract <V> AbstractType<?>getAndAppendComparator(int i, V value, ValueAccessor<V> accessor, 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> intgetComparatorSize(int i, V value, ValueAccessor<V> accessor, int offset) <V> StringgetString(V input, ValueAccessor<V> accessor) get a string representation of the bytes used for various identifier (NOT just for log messages)protected abstract AbstractCompositeType.ParsedComparatorparseComparator(int i, String part) Used by fromStringprotected abstract <V> booleanreadIsStatic(V value, ValueAccessor<V> accessor) split(ByteBuffer bb) Split a composite column names into it's components.protected abstract intstartingOffset(boolean isStatic) toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion) Converts the specified value into its JSON representation.voidvalidate(ByteBuffer bb) <V> voidvalidate(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 rangeMethods inherited from class org.apache.cassandra.db.marshal.AbstractType
asComparableBytes, asComparableBytes, asCQL3Type, asCQLTypeStringList, checkComparable, compare, compare, compareCollectionMembers, compareForCQL, compose, compose, decompose, decomposeUntyped, expandUserTypes, freeze, freezeNestedMulticellTypes, fromComparableBytes, fromComparableBytes, getArgumentDeserializer, getCompatibleTypeIfKnown, getComponents, getMaskedValue, getSerializer, 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, toString, toString, udfType, unfreeze, unwrap, 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
-
AbstractCompositeType
protected AbstractCompositeType()
-
-
Method Details
-
allowsEmpty
public boolean allowsEmpty()Description copied from class:AbstractTypeDefines if the type allows an empty set of bytes (new byte[0]) as valid input. TheAbstractType.validate(Object, ValueAccessor)andAbstractType.compose(Object, ValueAccessor)methods must allow empty bytes when this returns true, and must reject empty bytes when this is false. As of this writing, the main user of this API is for testing to know what types allow empty values and what types don't, so that the data that gets generated understands whenByteBufferUtil.EMPTY_BYTE_BUFFERis allowed as valid data.- Overrides:
allowsEmptyin classAbstractType<ByteBuffer>
-
compareCustom
public <VL,VR> int compareCustom(VL left, ValueAccessor<VL> accessorL, VR right, ValueAccessor<VR> accessorR) Description copied from class:AbstractTypeImplement 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:
compareCustomin classAbstractType<ByteBuffer>
-
readIsStatic
-
startingOffset
protected abstract int startingOffset(boolean isStatic) -
split
Split a composite column names into it's components. -
escape
-
getString
Description copied from class:AbstractTypeget a string representation of the bytes used for various identifier (NOT just for log messages)- Overrides:
getStringin classAbstractType<ByteBuffer>
-
fromString
Description copied from class:AbstractTypeget a byte representation of the given string.- Specified by:
fromStringin classAbstractType<ByteBuffer>
-
fromJSONObject
Description copied from class:AbstractTypeGiven a parsed JSON string, return a byte representation of the object.- Specified by:
fromJSONObjectin classAbstractType<ByteBuffer>- Parameters:
parsed- the result of parsing a json string
-
toJSONString
Description copied from class:AbstractTypeConverts the specified value into its JSON representation.The buffer position will stay the same.
- Overrides:
toJSONStringin classAbstractType<ByteBuffer>- Parameters:
buffer- the value to convertprotocolVersion- the protocol version to use for the conversion- Returns:
- a JSON string representing the specified value
-
validate
- Overrides:
validatein classAbstractType<ByteBuffer>- Throws:
MarshalException
-
validate
- Overrides:
validatein classAbstractType<ByteBuffer>
-
decompose
-
getComparatorSize
-
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, 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
Used by fromString
-