Package org.apache.cassandra.db.marshal
Class BytesType
- All Implemented Interfaces:
Comparator<ByteBuffer>,AssignmentTestable
-
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.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.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.booleanisSerializationCompatibleWith(AbstractType<?> previous) Similar toAbstractType.isValueCompatibleWith(AbstractType), but takes into accountCellencoding.booleanisValueCompatibleWithInternal(AbstractType<?> otherType) Needed to handle ReversedType in value-compatibility checks.toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion) Converts the specified value into its JSON representation.Methods inherited from class org.apache.cassandra.db.marshal.AbstractType
asComparableBytes, asComparableBytes, asCQLTypeStringList, checkComparable, compare, compare, compareCollectionMembers, compareCustom, compareForCQL, compose, compose, decompose, decomposeUntyped, expandUserTypes, freeze, freezeNestedMulticellTypes, fromComparableBytes, fromComparableBytes, getCompatibleTypeIfKnown, getComponents, getString, getString, getString, isCollection, isCounter, isEmptyValueMeaningless, isFreezable, isFrozenCollection, isMultiCell, isNull, isNull, isReversed, isTuple, isUDT, isValueCompatibleWith, isValueLengthFixed, isVector, parseDefaultParameters, read, readArray, readBuffer, readBuffer, referencesDuration, referencesUserType, referencesUserType, skipValue, subTypes, testAssignment, testAssignment, toCQLString, toJSONString, toString, toString, udfType, unfreeze, unwrap, validate, validate, validateCellValue, validateCollectionMember, valueLengthIfFixed, 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<ByteBuffer>
-
fromString
Description copied from class:AbstractTypeget a byte representation of the given string.- Specified by:
fromStringin classAbstractType<ByteBuffer>
-
fromJSONObject
Description copied from class:AbstractTypeGiven a parsed JSON string, return a byte representation of the object.- Specified by:
fromJSONObjectin classAbstractType<ByteBuffer>- 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<ByteBuffer>- Parameters:
buffer- the value to convertprotocolVersion- the protocol version to use for the conversion- Returns:
- a JSON string representing the specified value
-
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>
-
isValueCompatibleWithInternal
Description copied from class:AbstractTypeNeeded to handle ReversedType in value-compatibility checks. Subclasses should implement this instead of isValueCompatibleWith().- Overrides:
isValueCompatibleWithInternalin classAbstractType<ByteBuffer>
-
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<ByteBuffer>
-
asCQL3Type
- Overrides:
asCQL3Typein classAbstractType<ByteBuffer>
-
getSerializer
- Specified by:
getSerializerin classAbstractType<ByteBuffer>
-
getArgumentDeserializer
- Overrides:
getArgumentDeserializerin classAbstractType<ByteBuffer>- Returns:
- the deserializer used to deserialize the function arguments of this type.
-
getMaskedValue
- Overrides:
getMaskedValuein classAbstractType<ByteBuffer>- Returns:
- A fixed, serialized value to be used when the column is masked, to be returned instead of the real value.
-