Package org.apache.cassandra.db.marshal
Class DynamicCompositeType
java.lang.Object
org.apache.cassandra.db.marshal.AbstractType<ByteBuffer>
org.apache.cassandra.db.marshal.AbstractCompositeType
org.apache.cassandra.db.marshal.DynamicCompositeType
- All Implemented Interfaces:
Comparator<ByteBuffer>,AssignmentTestable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classNested classes/interfaces inherited from class org.apache.cassandra.db.marshal.AbstractCompositeType
AbstractCompositeType.ParsedComparatorNested 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 -
Method Summary
Modifier and TypeMethodDescription<V> ByteSourceasComparableBytes(ValueAccessor<V> accessor, V data, ByteComparable.Version version) Produce a byte-comparable representation of the given value, i.e.static ByteBufferbuild(List<String> types, List<ByteBuffer> values) static <V> Vbuild(ValueAccessor<V> accessor, List<AbstractType<?>> types, Map<AbstractType<?>, Byte> inverseMapping, List<V> values, byte lastEoc) booleanAbstractType<?>Replace any instances of UserType with equivalent TupleType-s.<V> VfromComparableBytes(ValueAccessor<V> 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).protected <V> AbstractType<?>getAndAppendComparator(int i, V value, ValueAccessor<V> accessor, StringBuilder sb, int offset) Adds type information from @param bb to @param sb.protected <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 <V> AbstractType<?>getComparator(int i, V value, ValueAccessor<V> accessor, int offset) protected <V> intgetComparatorSize(int i, V value, ValueAccessor<V> accessor, int offset) static DynamicCompositeTypegetInstance(Map<Byte, AbstractType<?>> aliases) static DynamicCompositeTypegetInstance(TypeParser parser) inthashCode()booleanisCompatibleWith(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 AbstractCompositeType.ParsedComparatorparseComparator(int i, String part) Used by fromStringprotected <V> booleanreadIsStatic(V value, ValueAccessor<V> accessor) <V> booleanreferencesUserType(V name, ValueAccessor<V> accessor) intsize()protected intstartingOffset(boolean isStatic) List<AbstractType<?>>subTypes()toString()This must be overriden by subclasses if necessary so that for any AbstractType, this == TypeParser.parse(toString()).protected <V> AbstractType<?>validateComparator(int i, V input, ValueAccessor<V> accessor, int offset) Like getComparator, but validates that @param i does not exceed the defined rangeReturns 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.AbstractCompositeType
allowsEmpty, compareCustom, escape, fromJSONObject, fromString, getString, split, toJSONString, validate, validateMethods inherited from class org.apache.cassandra.db.marshal.AbstractType
asComparableBytes, asCQL3Type, asCQLTypeStringList, checkComparable, compare, compare, compareCollectionMembers, compareForCQL, compose, compose, decompose, decomposeUntyped, freeze, freezeNestedMulticellTypes, fromComparableBytes, getArgumentDeserializer, getCompatibleTypeIfKnown, getComponents, getMaskedValue, getString, getString, isCollection, isCounter, isEmptyValueMeaningless, isFreezable, isFrozenCollection, isMultiCell, isNull, isNull, isReversed, isSerializationCompatibleWith, isTuple, isUDT, isValueCompatibleWith, isValueCompatibleWithInternal, isValueLengthFixed, isVector, parseDefaultParameters, read, readArray, readBuffer, readBuffer, referencesDuration, referencesUserType, skipValue, testAssignment, testAssignment, toCQLString, toJSONString, toString, udfType, unfreeze, unwrap, validateCellValue, 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
-
Field Details
-
aliases
-
-
Method Details
-
getInstance
-
getInstance
-
size
public int size() -
subTypes
- Overrides:
subTypesin classAbstractType<ByteBuffer>
-
getSerializer
- Specified by:
getSerializerin classAbstractType<ByteBuffer>
-
readIsStatic
- Specified by:
readIsStaticin classAbstractCompositeType
-
startingOffset
protected int startingOffset(boolean isStatic) - Specified by:
startingOffsetin classAbstractCompositeType
-
getComparatorSize
- Specified by:
getComparatorSizein classAbstractCompositeType
-
getComparator
- Specified by:
getComparatorin classAbstractCompositeType- 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 <VL,VR> AbstractType<?> getComparator(int i, VL left, ValueAccessor<VL> accessorL, VR right, ValueAccessor<VR> accessorR, int offsetL, int offsetR) Description copied from class:AbstractCompositeTypeAdds DynamicCompositeType type information from @param bb1 to @param bb2.- Specified by:
getComparatorin classAbstractCompositeType- Parameters:
i- is ignored.
-
getAndAppendComparator
protected <V> AbstractType<?> getAndAppendComparator(int i, V value, ValueAccessor<V> accessor, StringBuilder sb, int offset) Description copied from class:AbstractCompositeTypeAdds type information from @param bb to @param sb. @param i is ignored.- Specified by:
getAndAppendComparatorin classAbstractCompositeType
-
asComparableBytes
public <V> ByteSource asComparableBytes(ValueAccessor<V> accessor, V 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<ByteBuffer>
-
fromComparableBytes
public <V> V fromComparableBytes(ValueAccessor<V> 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<ByteBuffer>- 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:
-
build
-
build
-
build
public static <V> V build(ValueAccessor<V> accessor, List<AbstractType<?>> types, Map<AbstractType<?>, Byte> inverseMapping, List<V> values, byte lastEoc) -
parseComparator
Description copied from class:AbstractCompositeTypeUsed by fromString- Specified by:
parseComparatorin classAbstractCompositeType
-
validateComparator
protected <V> AbstractType<?> validateComparator(int i, V input, ValueAccessor<V> accessor, int offset) throws MarshalException Description copied from class:AbstractCompositeTypeLike getComparator, but validates that @param i does not exceed the defined range- Specified by:
validateComparatorin classAbstractCompositeType- Throws:
MarshalException
-
decompose
- Specified by:
decomposein classAbstractCompositeType
-
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<ByteBuffer>
-
referencesUserType
- Overrides:
referencesUserTypein classAbstractType<ByteBuffer>
-
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<ByteBuffer>
-
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<ByteBuffer>
-
equals
- Specified by:
equalsin interfaceComparator<ByteBuffer>- 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<ByteBuffer>
-