Package org.apache.cassandra.db.marshal
Class MapType<K,V>
java.lang.Object
org.apache.cassandra.db.marshal.AbstractType<T>
org.apache.cassandra.db.marshal.CollectionType<Map<K,V>>
org.apache.cassandra.db.marshal.MapType<K,V>
- All Implemented Interfaces:
Comparator<ByteBuffer>,AssignmentTestable
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.cassandra.db.marshal.CollectionType
CollectionType.KindNested 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.CollectionType
cellPathSerializer, kindFields inherited from class org.apache.cassandra.db.marshal.AbstractType
comparatorSet, comparisonType, isByteOrderComparable, reverseComparator -
Method Summary
Modifier and TypeMethodDescription<T> ByteSourceasComparableBytes(ValueAccessor<T> accessor, T data, ByteComparable.Version version) Produce a byte-comparable representation of the given value, i.e.protected intcollectionSize(List<ByteBuffer> values) <RL,TR> int compareCustom(RL left, ValueAccessor<RL> accessorL, TR right, ValueAccessor<TR> 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 semanticsstatic <TL,TR> int compareMaps(AbstractType<?> keysComparator, AbstractType<?> valuesComparator, TL left, ValueAccessor<TL> accessorL, TR right, ValueAccessor<TR> accessorR) AbstractType<?>Replace any instances of UserType with equivalent TupleType-s.voidforEach(ByteBuffer input, Consumer<ByteBuffer> action) AbstractType<?>freeze()AbstractType<?>Returns an AbstractType instance that is equivalent to this one, but with all nested UDTs and collections explicitly frozen.<T> TfromComparableBytes(ValueAccessor<T> accessor, ByteSource.Peekable comparableBytes, ByteComparable.Version version) Translates the given byte-ordered representation to the common, non-byte-ordered binary representation of a payload for this abstract type (the latter, common binary representation is what we mostly work with in the storage engine internals).fromJSONObject(Object parsed) Given a parsed JSON string, return a byte representation of the object.static <K,V> MapType<K, V> getInstance(AbstractType<K> keys, AbstractType<V> values, boolean isMultiCell) static MapType<?,?> getInstance(TypeParser parser) booleanisCompatibleWithFrozen(CollectionType<?> previous) A version of isCompatibleWith() to deal with non-multicell (frozen) collectionsbooleanbooleanisValueCompatibleWithFrozen(CollectionType<?> previous) A version of isValueCompatibleWith() to deal with non-multicell (frozen) collectionsboolean<T> booleanreferencesUserType(T name, ValueAccessor<T> accessor) serializedValues(Iterator<Cell<?>> cells) List<AbstractType<?>>subTypes()toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion) Converts the specified value into its JSON representation.toString(boolean ignoreFreezing) AbstractType<?>unfreeze()MapType<?,?> Returns an instance of this type with all references to the provided user type recursively replaced with its new definition.Methods inherited from class org.apache.cassandra.db.marshal.CollectionType
asCQL3Type, equals, fromString, getString, hashCode, isCollection, isCompatibleWith, isFreezable, isMap, isSerializationCompatibleWith, isValueCompatibleWithInternal, makeCollectionReceiver, serializeForNativeProtocol, setOrListToJsonString, size, toString, validate, validateCellValueMethods inherited from class org.apache.cassandra.db.marshal.AbstractType
allowsEmpty, asComparableBytes, asCQLTypeStringList, checkComparable, compare, compare, compareCollectionMembers, compareForCQL, compose, compose, decompose, decomposeUntyped, fromComparableBytes, getArgumentDeserializer, getCompatibleTypeIfKnown, getComponents, getString, getString, isCounter, isEmptyValueMeaningless, isFrozenCollection, isNull, isNull, isReversed, isTuple, isUDT, isValueCompatibleWith, isValueLengthFixed, isVector, parseDefaultParameters, read, readArray, readBuffer, readBuffer, referencesUserType, skipValue, testAssignment, testAssignment, toCQLString, toJSONString, udfType, unwrap, validate, validateCollectionMember, valueLengthIfFixed, 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
-
Method Details
-
getInstance
public static MapType<?,?> getInstance(TypeParser parser) throws ConfigurationException, SyntaxException -
getInstance
public static <K,V> MapType<K,V> getInstance(AbstractType<K> keys, AbstractType<V> values, boolean isMultiCell) -
referencesUserType
- Overrides:
referencesUserTypein classAbstractType<Map<K,V>>
-
withUpdatedUserType
Description copied from class:AbstractTypeReturns an instance of this type with all references to the provided user type recursively replaced with its new definition.- Overrides:
withUpdatedUserTypein classAbstractType<Map<K,V>>
-
expandUserTypes
Description copied from class:AbstractTypeReplace any instances of UserType with equivalent TupleType-s. We need it for dropped_columns, to allow safely dropping unused user types later without retaining any references to them in system_schema.dropped_columns.- Overrides:
expandUserTypesin classAbstractType<Map<K,V>>
-
referencesDuration
public boolean referencesDuration()- Overrides:
referencesDurationin classAbstractType<Map<K,V>>
-
getKeysType
-
getValuesType
-
nameComparator
- Specified by:
nameComparatorin classCollectionType<Map<K,V>>
-
valueComparator
- Specified by:
valueComparatorin classCollectionType<Map<K,V>>
-
isMultiCell
public boolean isMultiCell()- Overrides:
isMultiCellin classAbstractType<Map<K,V>>
-
subTypes
- Overrides:
subTypesin classAbstractType<Map<K,V>>
-
freeze
- Overrides:
freezein classAbstractType<Map<K,V>>
-
unfreeze
- Overrides:
unfreezein classAbstractType<Map<K,V>>
-
freezeNestedMulticellTypes
Description copied from class:AbstractTypeReturns an AbstractType instance that is equivalent to this one, but with all nested UDTs and collections explicitly frozen. This is only necessary for2.x -> 3.xschema migrations, and can be removed in Cassandra 4.0. See CASSANDRA-11609 and CASSANDRA-11613.- Overrides:
freezeNestedMulticellTypesin classAbstractType<Map<K,V>>
-
isCompatibleWithFrozen
Description copied from class:CollectionTypeA version of isCompatibleWith() to deal with non-multicell (frozen) collections- Specified by:
isCompatibleWithFrozenin classCollectionType<Map<K,V>>
-
isValueCompatibleWithFrozen
Description copied from class:CollectionTypeA version of isValueCompatibleWith() to deal with non-multicell (frozen) collections- Specified by:
isValueCompatibleWithFrozenin classCollectionType<Map<K,V>>
-
compareCustom
public <RL,TR> int compareCustom(RL left, ValueAccessor<RL> accessorL, TR right, ValueAccessor<TR> 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<Map<K,V>>
-
compareMaps
public static <TL,TR> int compareMaps(AbstractType<?> keysComparator, AbstractType<?> valuesComparator, TL left, ValueAccessor<TL> accessorL, TR right, ValueAccessor<TR> accessorR) -
asComparableBytes
public <T> ByteSource asComparableBytes(ValueAccessor<T> accessor, T data, ByteComparable.Version version) Description copied from class:AbstractTypeProduce a byte-comparable representation of the given value, i.e. a sequence of bytes that compares the same way using lexicographical unsigned byte comparison as the original value using the type's comparator. We use a slightly stronger requirement to be able to use the types in tuples. Precisely, for any pair x, y of non-equal valid values of this type and any bytes b1, b2 between 0x10 and 0xEF, (+ stands for concatenation) compare(x, y) == compareLexicographicallyUnsigned(asByteComparable(x)+b1, asByteComparable(y)+b2) (i.e. the values compare like the original type, and an added 0x10-0xEF byte at the end does not change that) and: asByteComparable(x)+b1 is not a prefix of asByteComparable(y) (weakly prefix free) (i.e. a valid representation of a value may be a prefix of another valid representation of a value only if the following byte in the latter is smaller than 0x10 or larger than 0xEF). These properties are trivially true if the encoding compares correctly and is prefix free, but also permits a little more freedom that enables somewhat more efficient encoding of arbitrary-length byte-comparable blobs. Depending on the type, this method can be called for null or empty input, in which case the output is allowed to be null (the clustering/tuple encoding will accept and handle it).- Overrides:
asComparableBytesin classAbstractType<Map<K,V>>
-
fromComparableBytes
public <T> T fromComparableBytes(ValueAccessor<T> accessor, ByteSource.Peekable comparableBytes, ByteComparable.Version version) Description copied from class:AbstractTypeTranslates the given byte-ordered representation to the common, non-byte-ordered binary representation of a payload for this abstract type (the latter, common binary representation is what we mostly work with in the storage engine internals). If the given bytes don't correspond to the encoding of some payload value for this abstract type, anIllegalArgumentExceptionmay be thrown.- Overrides:
fromComparableBytesin classAbstractType<Map<K,V>> - Parameters:
accessor- value accessor used to construct the value.comparableBytes- A byte-ordered representation (presumably of a payload for this abstract type).version- The byte-comparable version used to construct the representation.- Returns:
- A of a payload for this abstract type, corresponding to the given byte-ordered representation, constructed using the supplied value accessor.
- See Also:
-
getSerializer
- Specified by:
getSerializerin classCollectionType<Map<K,V>>
-
collectionSize
- Overrides:
collectionSizein classCollectionType<Map<K,V>>
-
toString
- Overrides:
toStringin classAbstractType<Map<K,V>> - Parameters:
ignoreFreezing- if true, the type string will not be wrapped with FrozenType(...), even if this type is frozen.
-
serializedValues
- Specified by:
serializedValuesin classCollectionType<Map<K,V>>
-
fromJSONObject
Description copied from class:AbstractTypeGiven a parsed JSON string, return a byte representation of the object.- Specified by:
fromJSONObjectin classAbstractType<Map<K,V>> - Parameters:
parsed- the result of parsing a json string- Throws:
MarshalException
-
toJSONString
Description copied from class:AbstractTypeConverts the specified value into its JSON representation.The buffer position will stay the same.
- Overrides:
toJSONStringin classAbstractType<Map<K,V>> - Parameters:
buffer- the value to convertprotocolVersion- the protocol version to use for the conversion- Returns:
- a JSON string representing the specified value
-
forEach
- Specified by:
forEachin classCollectionType<Map<K,V>>
-
getMaskedValue
- Overrides:
getMaskedValuein classAbstractType<Map<K,V>> - Returns:
- A fixed, serialized value to be used when the column is masked, to be returned instead of the real value.
-