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.String
asFunctionParameterString()
Returns a String representation of this data type suitable for inclusion as a parameter type in a function or aggregate signature.boolean
contains(TupleType other)
Returntrue
if this tuple type contains the given tuple type, andfalse
otherwise.boolean
equals(java.lang.Object o)
int
hashCode()
boolean
isFrozen()
Returns whether this data type is frozen.TupleValue
newValue()
Returns a new empty value for this tuple type.TupleValue
newValue(java.lang.Object... values)
Returns a new value for this tuple type that uses the provided values for the components.static TupleType
of(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, DataType... types)
Creates a "disconnected" tuple type (you should preferMetadata#newTupleType(DataType...) cluster.getMetadata().newTupleType(...)
whenever possible).java.lang.String
toString()
-
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
Cluster
instance available. If you create a type with this method and use it with aCluster
later, 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
i
th parameter value will then be assigned to thei
th 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 ofvalues
provided 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:DataType
Returns 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:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
contains
public boolean contains(TupleType other)
Returntrue
if this tuple type contains the given tuple type, andfalse
otherwise.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:
true
if this tuple type contains the given tuple type, andfalse
otherwise.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
asFunctionParameterString
public java.lang.String asFunctionParameterString()
Description copied from class:DataType
Returns 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. thefrozen
keyword is not accepted.- Overrides:
asFunctionParameterString
in classDataType
- Returns:
- a String representation of this data type suitable for inclusion as a parameter type in a function or aggregate signature.
-
-