Package org.apache.cassandra.db.marshal
Class CollectionType<T>
java.lang.Object
org.apache.cassandra.db.marshal.AbstractType<T>
org.apache.cassandra.db.marshal.CollectionType<T>
- All Implemented Interfaces:
Comparator<ByteBuffer>,AssignmentTestable
The abstract validator that is the base for maps, sets and lists (both frozen and non-frozen).
Please note that this comparator shouldn't be used "manually" (as a custom
type for instance).
-
Nested Class Summary
Nested ClassesNested 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
FieldsFields inherited from class org.apache.cassandra.db.marshal.AbstractType
comparatorSet, comparisonType, isByteOrderComparable, reverseComparator -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCollectionType(AbstractType.ComparisonType comparisonType, CollectionType.Kind kind) -
Method Summary
Modifier and TypeMethodDescriptionprotected intcollectionSize(List<ByteBuffer> values) booleanabstract voidforEach(ByteBuffer input, Consumer<ByteBuffer> action) fromString(String source) get a byte representation of the given string.abstract CollectionSerializer<T><V> StringgetString(V value, ValueAccessor<V> accessor) get a string representation of the bytes used for various identifier (NOT just for log messages)inthashCode()booleanbooleanisCompatibleWith(AbstractType<?> previous) Returns true if this comparator is compatible with the provided previous comparator, that is if previous can safely be replaced by this.protected abstract booleanisCompatibleWithFrozen(CollectionType<?> previous) A version of isCompatibleWith() to deal with non-multicell (frozen) collectionsbooleanbooleanisMap()Checks if this collection is Map.booleanisSerializationCompatibleWith(AbstractType<?> previous) Similar toAbstractType.isValueCompatibleWith(AbstractType), but takes into accountCellencoding.protected abstract booleanisValueCompatibleWithFrozen(CollectionType<?> previous) A version of isValueCompatibleWith() to deal with non-multicell (frozen) collectionsbooleanisValueCompatibleWithInternal(AbstractType<?> previous) Needed to handle ReversedType in value-compatibility checks.makeCollectionReceiver(ColumnSpecification collection, boolean isKey) abstract AbstractType<?>protected abstract List<ByteBuffer>serializedValues(Iterator<Cell<?>> cells) serializeForNativeProtocol(Iterator<Cell<?>> cells) static StringsetOrListToJsonString(ByteBuffer buffer, AbstractType<?> elementsType, ProtocolVersion protocolVersion) intsize(ByteBuffer buffer) toString()This must be overriden by subclasses if necessary so that for any AbstractType, this == TypeParser.parse(toString()).<V> voidvalidate(V value, ValueAccessor<V> accessor) <V> voidvalidateCellValue(V cellValue, ValueAccessor<V> accessor) Validate cell value.abstract AbstractType<?>Methods inherited from class org.apache.cassandra.db.marshal.AbstractType
allowsEmpty, asComparableBytes, asComparableBytes, asCQLTypeStringList, checkComparable, compare, compare, compareCollectionMembers, compareCustom, compareForCQL, compose, compose, decompose, decomposeUntyped, expandUserTypes, freeze, freezeNestedMulticellTypes, fromComparableBytes, fromComparableBytes, fromJSONObject, getArgumentDeserializer, getCompatibleTypeIfKnown, getComponents, getMaskedValue, getString, getString, isCounter, isEmptyValueMeaningless, isFrozenCollection, isMultiCell, isNull, isNull, isReversed, isTuple, isUDT, isValueCompatibleWith, isValueLengthFixed, isVector, parseDefaultParameters, read, readArray, readBuffer, readBuffer, referencesDuration, referencesUserType, referencesUserType, skipValue, subTypes, testAssignment, testAssignment, toCQLString, toJSONString, toJSONString, toString, udfType, unfreeze, unwrap, validate, validateCollectionMember, valueLengthIfFixed, withUpdatedUserType, writeValue, writeValue, writtenLength, writtenLengthMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
cellPathSerializer
-
kind
-
-
Constructor Details
-
CollectionType
-
-
Method Details
-
nameComparator
-
valueComparator
-
serializedValues
-
getSerializer
- Specified by:
getSerializerin classAbstractType<T>
-
makeCollectionReceiver
-
getString
Description copied from class:AbstractTypeget a string representation of the bytes used for various identifier (NOT just for log messages)- Overrides:
getStringin classAbstractType<T>
-
fromString
Description copied from class:AbstractTypeget a byte representation of the given string.- Specified by:
fromStringin classAbstractType<T>
-
isCollection
public boolean isCollection()- Overrides:
isCollectionin classAbstractType<T>
-
validate
- Overrides:
validatein classAbstractType<T>- Throws:
MarshalException
-
validateCellValue
Description copied from class:AbstractTypeValidate cell value. Unlike AbstractType.validate(java.nio.ByteBuffer), cell value is passed to validate its content. Usually, this is the same as validate except collection.- Overrides:
validateCellValuein classAbstractType<T>- Parameters:
cellValue- ByteBuffer representing cell value- Throws:
MarshalException
-
isMap
public boolean isMap()Checks if this collection is Map.- Returns:
trueif this collection is a Map,falseotherwise.
-
isFreezable
public boolean isFreezable()- Overrides:
isFreezablein classAbstractType<T>
-
collectionSize
-
serializeForNativeProtocol
-
isCompatibleWith
Description copied from class:AbstractTypeReturns true if this comparator is compatible with the provided previous comparator, that is if previous can safely be replaced by this. A comparator cn should be compatible with a previous one cp if forall columns c1 and c2, if cn.validate(c1) and cn.validate(c2) and cn.compare(c1, c2) == v, then cp.validate(c1) and cp.validate(c2) and cp.compare(c1, c2) == v. Note that a type should be compatible with at least itself and when in doubt, keep the default behavior of not being compatible with any other comparator!- Overrides:
isCompatibleWithin classAbstractType<T>
-
isValueCompatibleWithInternal
Description copied from class:AbstractTypeNeeded to handle ReversedType in value-compatibility checks. Subclasses should implement this instead of isValueCompatibleWith().- Overrides:
isValueCompatibleWithInternalin classAbstractType<T>
-
isSerializationCompatibleWith
Description copied from class:AbstractTypeSimilar toAbstractType.isValueCompatibleWith(AbstractType), but takes into accountCellencoding. In particular, this method doesn't consider two types serialization compatible if one of them has fixed length (overridesAbstractType.valueLengthIfFixed(), and the other one doesn't.- Overrides:
isSerializationCompatibleWithin classAbstractType<T>
-
isCompatibleWithFrozen
A version of isCompatibleWith() to deal with non-multicell (frozen) collections -
isValueCompatibleWithFrozen
A version of isValueCompatibleWith() to deal with non-multicell (frozen) collections -
asCQL3Type
- Overrides:
asCQL3Typein classAbstractType<T>
-
equals
- Specified by:
equalsin interfaceComparator<T>- Overrides:
equalsin classObject
-
hashCode
public int hashCode() -
toString
Description copied from class:AbstractTypeThis must be overriden by subclasses if necessary so that for any AbstractType, this == TypeParser.parse(toString()). Note that for backwards compatibility this includes the full classname. For CQL purposes the short name is fine.- Overrides:
toStringin classAbstractType<T>
-
setOrListToJsonString
public static String setOrListToJsonString(ByteBuffer buffer, AbstractType<?> elementsType, ProtocolVersion protocolVersion) -
size
-
forEach
-