Package org.apache.cassandra.db.marshal
Class UUIDType
- All Implemented Interfaces:
Comparator<ByteBuffer>,AssignmentTestable
Compares UUIDs using the following criteria:
- if count of supplied bytes is less than 16, compare counts
- compare UUID version fields
- nil UUID is always lesser
- compare timestamps if both are time-based
- compare lexically, unsigned msb-to-lsb comparison
- if count of supplied bytes is less than 16, compare counts
- compare UUID version fields
- nil UUID is always lesser
- compare timestamps if both are time-based
- compare lexically, unsigned msb-to-lsb comparison
- See Also:
-
- "com.fasterxml.uuid.UUIDComparator"
-
Nested Class Summary
Nested 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 TypeMethodDescriptionbooleanDefines if the type allows an empty set of bytes (new byte[0]) as valid input.<V> ByteSourceasComparableBytes(ValueAccessor<V> accessor, V data, ByteComparable.Version v) Produce a byte-comparable representation of the given value, i.e.<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 semantics<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).fromJSONObject(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.booleanbooleanisValueCompatibleWithInternal(AbstractType<?> otherType) Needed to handle ReversedType in value-compatibility checks.intThe length of values for this type if all values are of fixed length, -1 otherwise.Methods inherited from class org.apache.cassandra.db.marshal.AbstractType
asComparableBytes, asCQLTypeStringList, checkComparable, compare, compare, compareCollectionMembers, compareForCQL, compose, compose, decompose, decomposeUntyped, expandUserTypes, freeze, freezeNestedMulticellTypes, fromComparableBytes, getCompatibleTypeIfKnown, getComponents, getString, getString, getString, isCollection, isCompatibleWith, isCounter, isFreezable, isFrozenCollection, isMultiCell, isNull, isNull, isReversed, isSerializationCompatibleWith, isTuple, isUDT, isValueCompatibleWith, isValueLengthFixed, isVector, parseDefaultParameters, read, readArray, readBuffer, readBuffer, referencesDuration, referencesUserType, referencesUserType, skipValue, subTypes, testAssignment, testAssignment, toCQLString, toJSONString, toJSONString, toString, toString, udfType, unfreeze, unwrap, validate, validate, validateCellValue, validateCollectionMember, 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
-
Field Details
-
instance
-
-
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<UUID>
-
isEmptyValueMeaningless
public boolean isEmptyValueMeaningless()Description copied from class:AbstractType- Overrides:
isEmptyValueMeaninglessin classAbstractType<UUID>
-
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<UUID>
-
asComparableBytes
public <V> ByteSource asComparableBytes(ValueAccessor<V> accessor, V data, ByteComparable.Version v) 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<UUID>
-
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<UUID>- 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:
-
isValueCompatibleWithInternal
Description copied from class:AbstractTypeNeeded to handle ReversedType in value-compatibility checks. Subclasses should implement this instead of isValueCompatibleWith().- Overrides:
isValueCompatibleWithInternalin classAbstractType<UUID>
-
fromString
Description copied from class:AbstractTypeget a byte representation of the given string.- Specified by:
fromStringin classAbstractType<UUID>- Throws:
MarshalException
-
asCQL3Type
- Overrides:
asCQL3Typein classAbstractType<UUID>
-
getSerializer
- Specified by:
getSerializerin classAbstractType<UUID>
-
getArgumentDeserializer
- Overrides:
getArgumentDeserializerin classAbstractType<UUID>- Returns:
- the deserializer used to deserialize the function arguments of this type.
-
fromJSONObject
Description copied from class:AbstractTypeGiven a parsed JSON string, return a byte representation of the object.- Specified by:
fromJSONObjectin classAbstractType<UUID>- Parameters:
parsed- the result of parsing a json string- Throws:
MarshalException
-
valueLengthIfFixed
public int valueLengthIfFixed()Description copied from class:AbstractTypeThe length of values for this type if all values are of fixed length, -1 otherwise. This has an impact on serialization.- see
AbstractType.writeValue(java.nio.ByteBuffer, org.apache.cassandra.io.util.DataOutputPlus)- see
AbstractType.read(org.apache.cassandra.db.marshal.ValueAccessor<V>, org.apache.cassandra.io.util.DataInputPlus, int)- see
AbstractType.writtenLength(java.nio.ByteBuffer)- see
AbstractType.skipValue(org.apache.cassandra.io.util.DataInputPlus)- Overrides:
valueLengthIfFixedin classAbstractType<UUID>
- see
-
getMaskedValue
- Overrides:
getMaskedValuein classAbstractType<UUID>- Returns:
- A fixed, serialized value to be used when the column is masked, to be returned instead of the real value.
-