Package org.apache.cassandra.db.marshal
Class UserType
java.lang.Object
org.apache.cassandra.db.marshal.AbstractType<ByteBuffer>
org.apache.cassandra.db.marshal.TupleType
org.apache.cassandra.db.marshal.UserType
- All Implemented Interfaces:
Comparator<ByteBuffer>,AssignmentTestable,SchemaElement
A user defined type.
A user type is really just a tuple type on steroids.
-
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.TestResultNested classes/interfaces inherited from interface org.apache.cassandra.cql3.SchemaElement
SchemaElement.SchemaElementType -
Field Summary
FieldsFields inherited from class org.apache.cassandra.db.marshal.AbstractType
comparatorSet, comparisonType, isByteOrderComparable, reverseComparatorFields inherited from interface org.apache.cassandra.cql3.SchemaElement
NAME_COMPARATOR -
Constructor Summary
ConstructorsConstructorDescriptionUserType(String keyspace, ByteBuffer name, List<FieldIdentifier> fieldNames, List<AbstractType<?>> fieldTypes, boolean isMultiCell) -
Method Summary
Modifier and TypeMethodDescriptioncellPathForField(FieldIdentifier fieldName) Returns the CQL name of the keyspace to which this schema element belong.Returns the CQL name of this schema element.Return the schema element typebooleanfieldName(int i) fieldNameAsString(int i) intfieldPosition(FieldIdentifier fieldName) AbstractType<?>fieldType(int i) List<AbstractType<?>>freeze()AbstractType<?>Returns an AbstractType instance that is equivalent to this one, but with all nested UDTs and collections explicitly frozen.fromJSONObject(Object parsed) Given a parsed JSON string, return a byte representation of the object.static UserTypegetInstance(TypeParser parser) inthashCode()booleanbooleanbooleanisTuple()booleanisUDT()booleanisValueCompatibleWith(AbstractType<?> previous) Returns true if values of the other AbstractType can be read and "reasonably" interpreted by the this AbstractType.boolean<V> booleanreferencesUserType(V name, ValueAccessor<V> accessor) serializeForNativeProtocol(Iterator<Cell<?>> cells, ProtocolVersion protocolVersion) toCqlString(boolean withInternals, boolean ifNotExists) Returns a CQL representation of this elementtoJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion) Converts the specified value into its JSON representation.toString()This must be overriden by subclasses if necessary so that for any AbstractType, this == TypeParser.parse(toString()).toString(boolean ignoreFreezing) unfreeze()<V> voidvalidateCell(Cell<V> cell) 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.TupleType
allowsEmpty, allTypes, asComparableBytes, buildValue, buildValue, compareCustom, expandUserTypes, fromComparableBytes, fromString, getMaskedValue, getString, isCompatibleWith, isValueCompatibleWithInternal, size, split, split, subTypes, typeMethods inherited from class org.apache.cassandra.db.marshal.AbstractType
asComparableBytes, asCQLTypeStringList, checkComparable, compare, compare, compareCollectionMembers, compareForCQL, compose, compose, decompose, decomposeUntyped, fromComparableBytes, getArgumentDeserializer, getCompatibleTypeIfKnown, getComponents, getString, getString, isCollection, isCounter, isEmptyValueMeaningless, isFrozenCollection, isNull, isNull, isReversed, isSerializationCompatibleWith, isValueLengthFixed, isVector, parseDefaultParameters, read, readArray, readBuffer, readBuffer, referencesUserType, skipValue, testAssignment, testAssignment, toCQLString, toJSONString, udfType, unwrap, validate, validate, 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, thenComparingLongMethods inherited from interface org.apache.cassandra.cql3.SchemaElement
elementKeyspaceQuotedIfNeeded, elementNameQuotedIfNeeded
-
Field Details
-
keyspace
-
name
-
-
Constructor Details
-
UserType
public UserType(String keyspace, ByteBuffer name, List<FieldIdentifier> fieldNames, List<AbstractType<?>> fieldTypes, boolean isMultiCell)
-
-
Method Details
-
getInstance
-
isUDT
public boolean isUDT()- Overrides:
isUDTin classAbstractType<ByteBuffer>
-
isTuple
public boolean isTuple() -
isMultiCell
public boolean isMultiCell()- Overrides:
isMultiCellin classAbstractType<ByteBuffer>
-
isFreezable
public boolean isFreezable()- Overrides:
isFreezablein classAbstractType<ByteBuffer>
-
fieldType
-
fieldTypes
-
fieldName
-
fieldNameAsString
-
fieldNames
-
getNameAsString
-
fieldPosition
-
cellPathForField
-
nameComparator
-
serializeForNativeProtocol
public ByteBuffer serializeForNativeProtocol(Iterator<Cell<?>> cells, ProtocolVersion protocolVersion) -
validateCell
- Throws:
MarshalException
-
fromJSONObject
Description copied from class:AbstractTypeGiven a parsed JSON string, return a byte representation of the object.- Overrides:
fromJSONObjectin classTupleType- 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 classTupleType- Parameters:
buffer- the value to convertprotocolVersion- the protocol version to use for the conversion- Returns:
- a JSON string representing the specified value
-
freeze
- Overrides:
freezein classAbstractType<ByteBuffer>
-
unfreeze
- Overrides:
unfreezein classAbstractType<ByteBuffer>
-
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<ByteBuffer>
-
hashCode
public int hashCode() -
isValueCompatibleWith
Description copied from class:AbstractTypeReturns true if values of the other AbstractType can be read and "reasonably" interpreted by the this AbstractType. Note that this is a weaker version of isCompatibleWith, as it does not require that both type compare values the same way. The restriction on the other type being "reasonably" interpreted is to prevent, for example, IntegerType from being compatible with all other types. Even though any byte string is a valid IntegerType value, it doesn't necessarily make sense to interpret a UUID or a UTF8 string as an integer. Note that a type should be compatible with at least itself.- Overrides:
isValueCompatibleWithin classAbstractType<ByteBuffer>
-
equals
- Specified by:
equalsin interfaceComparator<ByteBuffer>- Overrides:
equalsin classTupleType
-
compare
-
asCQL3Type
- Overrides:
asCQL3Typein classTupleType
-
referencesUserType
- Overrides:
referencesUserTypein classTupleType
-
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 classTupleType
-
referencesDuration
public boolean referencesDuration()- Overrides:
referencesDurationin classTupleType
-
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. -
toString
- Overrides:
toStringin classAbstractType<ByteBuffer>- Parameters:
ignoreFreezing- if true, the type string will not be wrapped with FrozenType(...), even if this type is frozen.
-
getCqlTypeName
-
getSerializer
- Overrides:
getSerializerin classTupleType
-
elementType
Description copied from interface:SchemaElementReturn the schema element type- Specified by:
elementTypein interfaceSchemaElement- Returns:
- the schema element type
-
elementKeyspace
Description copied from interface:SchemaElementReturns the CQL name of the keyspace to which this schema element belong.- Specified by:
elementKeyspacein interfaceSchemaElement- Returns:
- the keyspace name.
-
elementName
Description copied from interface:SchemaElementReturns the CQL name of this schema element.- Specified by:
elementNamein interfaceSchemaElement- Returns:
- the name of this schema element.
-
toCqlString
Description copied from interface:SchemaElementReturns a CQL representation of this element- Specified by:
toCqlStringin interfaceSchemaElement- Parameters:
withInternals- if the internals part of the CQL should be exposed.ifNotExists- if "IF NOT EXISTS" should be included.- Returns:
- a CQL representation of this element
-