Class TupleType
- java.lang.Object
-
- org.apache.cassandra.cql3.functions.types.DataType
-
- org.apache.cassandra.cql3.functions.types.TupleType
-
public class TupleType extends DataType
A tuple type.A tuple type is a essentially a list of types.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.cassandra.cql3.functions.types.DataType
DataType.CollectionType, DataType.CustomType, DataType.Name, DataType.NativeType
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringasFunctionParameterString()Returns a String representation of this data type suitable for inclusion as a parameter type in a function or aggregate signature.booleancontains(TupleType other)Returntrueif this tuple type contains the given tuple type, andfalseotherwise.booleanequals(java.lang.Object o)inthashCode()booleanisFrozen()Returns whether this data type is frozen.TupleValuenewValue()Returns a new empty value for this tuple type.TupleValuenewValue(java.lang.Object... values)Returns a new value for this tuple type that uses the provided values for the components.static TupleTypeof(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, DataType... types)Creates a "disconnected" tuple type (you should preferMetadata#newTupleType(DataType...) cluster.getMetadata().newTupleType(...)whenever possible).java.lang.StringtoString()-
Methods inherited from class org.apache.cassandra.cql3.functions.types.DataType
ascii, bigint, blob, cboolean, cdouble, cfloat, cint, counter, custom, date, decimal, duration, getName, getTypeArguments, inet, isCollection, list, list, map, map, set, set, smallint, text, time, timestamp, timeuuid, tinyint, uuid, varchar, varint
-
-
-
-
Method Detail
-
of
public static TupleType of(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, DataType... types)
Creates a "disconnected" tuple type (you should preferMetadata#newTupleType(DataType...) cluster.getMetadata().newTupleType(...)whenever possible).This method is only exposed for situations where you don't have a
Clusterinstance available. If you create a type with this method and use it with aClusterlater, you won't be able to set tuple fields with custom codecs registered against the cluster, or you might get errors if the protocol versions don't match.- Parameters:
protocolVersion- the protocol version to use.codecRegistry- the codec registry to use.types- the types for the tuple type.- Returns:
- the newly created tuple type.
-
newValue
public TupleValue newValue()
Returns a new empty value for this tuple type.- Returns:
- an empty (with all component to
null) value for this user type definition.
-
newValue
public TupleValue newValue(java.lang.Object... values)
Returns a new value for this tuple type that uses the provided values for the components.The numbers of values passed to this method must correspond to the number of components in this tuple type. The
ith parameter value will then be assigned to theith component of the resulting tuple value.- Parameters:
values- the values to use for the component of the resulting tuple.- Returns:
- a new tuple values based on the provided values.
- Throws:
java.lang.IllegalArgumentException- if the number ofvaluesprovided does not correspond to the number of components in this tuple type.InvalidTypeException- if any of the provided value is not of the correct type for the component.
-
isFrozen
public boolean isFrozen()
Description copied from class:DataTypeReturns whether this data type is frozen.This applies to User Defined Types, tuples and nested collections. Frozen types are serialized as a single value in Cassandra's storage engine, whereas non-frozen types are stored in a form that allows updates to individual subfields.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
contains
public boolean contains(TupleType other)
Returntrueif this tuple type contains the given tuple type, andfalseotherwise.A tuple type is said to contain another one if the latter has fewer components than the former, but all of them are of the same type. E.g. the type
tuple<int, text>is contained by the typetuple<int, text, double>.A contained type can be seen as a "partial" view of a containing type, where the missing components are supposed to be
null.- Parameters:
other- the tuple type to compare against the current one- Returns:
trueif this tuple type contains the given tuple type, andfalseotherwise.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
asFunctionParameterString
public java.lang.String asFunctionParameterString()
Description copied from class:DataTypeReturns a String representation of this data type suitable for inclusion as a parameter type in a function or aggregate signature.In such places, the String representation might vary from the canonical one as returned by
Object.toString(); e.g. thefrozenkeyword is not accepted.- Overrides:
asFunctionParameterStringin classDataType- Returns:
- a String representation of this data type suitable for inclusion as a parameter type in a function or aggregate signature.
-
-