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:
java.util.Comparator<java.nio.ByteBuffer>
,AssignmentTestable
public abstract class CollectionType<T> extends AbstractType<T>
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 Classes Modifier and Type Class Description static class
CollectionType.Kind
-
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 CellPath.Serializer
cellPathSerializer
CollectionType.Kind
kind
-
Fields inherited from class org.apache.cassandra.db.marshal.AbstractType
comparatorSet, comparisonType, isByteOrderComparable, reverseComparator
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CollectionType(AbstractType.ComparisonType comparisonType, CollectionType.Kind kind)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description CQL3Type
asCQL3Type()
protected int
collectionSize(java.util.List<java.nio.ByteBuffer> values)
boolean
equals(java.lang.Object o)
java.nio.ByteBuffer
fromString(java.lang.String source)
get a byte representation of the given string.abstract CollectionSerializer<T>
getSerializer()
<V> java.lang.String
getString(V value, ValueAccessor<V> accessor)
get a string representation of the bytes used for various identifier (NOT just for log messages)boolean
isCollection()
boolean
isCompatibleWith(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 boolean
isCompatibleWithFrozen(CollectionType<?> previous)
A version of isCompatibleWith() to deal with non-multicell (frozen) collectionsboolean
isFreezable()
boolean
isMap()
Checks if this collection is Map.protected abstract boolean
isValueCompatibleWithFrozen(CollectionType<?> previous)
A version of isValueCompatibleWith() to deal with non-multicell (frozen) collectionsboolean
isValueCompatibleWithInternal(AbstractType<?> previous)
Needed to handle ReversedType in value-compatibility checks.ColumnSpecification
makeCollectionReceiver(ColumnSpecification collection, boolean isKey)
abstract AbstractType<?>
nameComparator()
protected abstract java.util.List<java.nio.ByteBuffer>
serializedValues(java.util.Iterator<Cell<?>> cells)
java.nio.ByteBuffer
serializeForNativeProtocol(java.util.Iterator<Cell<?>> cells, ProtocolVersion version)
java.lang.String
toString()
This must be overriden by subclasses if necessary so that for any AbstractType, this == TypeParser.parse(toString()).<V> void
validateCellValue(V cellValue, ValueAccessor<V> accessor)
Validate cell value.abstract AbstractType<?>
valueComparator()
-
Methods inherited from class org.apache.cassandra.db.marshal.AbstractType
asCQLTypeStringList, checkComparable, compare, compare, compareCollectionMembers, compareCustom, compareForCQL, compose, compose, decompose, expandUserTypes, freeze, freezeNestedMulticellTypes, fromJSONObject, getComponents, getString, getString, isCounter, isEmptyValueMeaningless, isFrozenCollection, isMultiCell, isReversed, isTuple, isUDT, isValueCompatibleWith, parseDefaultParameters, read, readArray, readBuffer, readBuffer, referencesDuration, referencesUserType, referencesUserType, skipValue, subTypes, testAssignment, testAssignment, toJSONString, toJSONString, toString, validate, validate, validateCollectionMember, valueLengthIfFixed, withUpdatedUserType, writeValue, writeValue, writtenLength, writtenLength
-
-
-
-
Field Detail
-
cellPathSerializer
public static CellPath.Serializer cellPathSerializer
-
kind
public final CollectionType.Kind kind
-
-
Constructor Detail
-
CollectionType
protected CollectionType(AbstractType.ComparisonType comparisonType, CollectionType.Kind kind)
-
-
Method Detail
-
nameComparator
public abstract AbstractType<?> nameComparator()
-
valueComparator
public abstract AbstractType<?> valueComparator()
-
serializedValues
protected abstract java.util.List<java.nio.ByteBuffer> serializedValues(java.util.Iterator<Cell<?>> cells)
-
getSerializer
public abstract CollectionSerializer<T> getSerializer()
- Specified by:
getSerializer
in classAbstractType<T>
-
makeCollectionReceiver
public ColumnSpecification makeCollectionReceiver(ColumnSpecification collection, boolean isKey)
-
getString
public <V> java.lang.String getString(V value, 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<T>
-
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<T>
-
isCollection
public boolean isCollection()
- Overrides:
isCollection
in classAbstractType<T>
-
validateCellValue
public <V> void validateCellValue(V cellValue, ValueAccessor<V> accessor) throws MarshalException
Description copied from class:AbstractType
Validate 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:
validateCellValue
in classAbstractType<T>
- Parameters:
cellValue
- ByteBuffer representing cell value- Throws:
MarshalException
-
isMap
public boolean isMap()
Checks if this collection is Map.- Returns:
true
if this collection is a Map,false
otherwise.
-
isFreezable
public boolean isFreezable()
- Overrides:
isFreezable
in classAbstractType<T>
-
collectionSize
protected int collectionSize(java.util.List<java.nio.ByteBuffer> values)
-
serializeForNativeProtocol
public java.nio.ByteBuffer serializeForNativeProtocol(java.util.Iterator<Cell<?>> cells, ProtocolVersion version)
-
isCompatibleWith
public boolean isCompatibleWith(AbstractType<?> previous)
Description copied from class:AbstractType
Returns 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:
isCompatibleWith
in classAbstractType<T>
-
isValueCompatibleWithInternal
public boolean isValueCompatibleWithInternal(AbstractType<?> previous)
Description copied from class:AbstractType
Needed to handle ReversedType in value-compatibility checks. Subclasses should implement this instead of isValueCompatibleWith().- Overrides:
isValueCompatibleWithInternal
in classAbstractType<T>
-
isCompatibleWithFrozen
protected abstract boolean isCompatibleWithFrozen(CollectionType<?> previous)
A version of isCompatibleWith() to deal with non-multicell (frozen) collections
-
isValueCompatibleWithFrozen
protected abstract boolean isValueCompatibleWithFrozen(CollectionType<?> previous)
A version of isValueCompatibleWith() to deal with non-multicell (frozen) collections
-
asCQL3Type
public CQL3Type asCQL3Type()
- Overrides:
asCQL3Type
in classAbstractType<T>
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equals
in interfacejava.util.Comparator<T>
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
Description copied from class:AbstractType
This 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:
toString
in classAbstractType<T>
-
-