Class DataType
- java.lang.Object
-
- org.apache.cassandra.cql3.functions.types.DataType
-
- Direct Known Subclasses:
DataType.CollectionType,DataType.CustomType,DataType.NativeType,TupleType,UserType
public abstract class DataType extends java.lang.ObjectData types supported by cassandra.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDataType.CollectionTypeInstances of this class represent collection types, that is, lists, sets or maps.static classDataType.CustomTypeA "custom" type is a type that cannot be expressed as a CQL type.static classDataType.NameThe CQL type name.static classDataType.NativeTypeInstances of this class represent CQL native types, also known as CQL primitive types.
-
Field Summary
Fields Modifier and Type Field Description protected DataType.Namename
-
Constructor Summary
Constructors Modifier Constructor Description protectedDataType(DataType.Name name)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static DataTypeascii()Returns the ASCII type.java.lang.StringasFunctionParameterString()Returns a String representation of this data type suitable for inclusion as a parameter type in a function or aggregate signature.static DataTypebigint()Returns the BIGINT type.static DataTypeblob()Returns the BLOB type.static DataTypecboolean()Returns the BOOLEAN type.static DataTypecdouble()Returns the DOUBLE type.static DataTypecfloat()Returns the FLOAT type.static DataTypecint()Returns the INT type.static DataTypecounter()Returns the COUNTER type.static DataType.CustomTypecustom(java.lang.String typeClassName)Returns a Custom type.static DataTypedate()Returns the DATE type.static DataTypedecimal()Returns the DECIMAL type.static DataTypeduration()Returns the Duration type, introduced in Cassandra 3.10.DataType.NamegetName()Returns the name of that type.java.util.List<DataType>getTypeArguments()Returns the type arguments of this type.static DataTypeinet()Returns the INET type.booleanisCollection()Returns whether this data type represent a CQLcollection type, that is, a list, set or map.abstract booleanisFrozen()Returns whether this data type is frozen.static DataType.CollectionTypelist(DataType elementType)Returns the type of "not frozen" lists ofelementTypeelements.static DataType.CollectionTypelist(DataType elementType, boolean frozen)Returns the type of lists ofelementTypeelements.static DataType.CollectionTypemap(DataType keyType, DataType valueType)Returns the type of "not frozen" maps ofkeyTypetovalueTypeelements.static DataType.CollectionTypemap(DataType keyType, DataType valueType, boolean frozen)Returns the type of maps ofkeyTypetovalueTypeelements.static DataType.CollectionTypeset(DataType elementType)Returns the type of "not frozen" sets ofelementTypeelements.static DataType.CollectionTypeset(DataType elementType, boolean frozen)Returns the type of sets ofelementTypeelements.static DataTypesmallint()Returns the SMALLINT type.static DataTypetext()Returns the TEXT type.static DataTypetime()Returns the TIME type.static DataTypetimestamp()Returns the TIMESTAMP type.static DataTypetimeuuid()Returns the TIMEUUID type.static DataTypetinyint()Returns the TINYINT type.static DataTypeuuid()Returns the UUID type.static DataTypevarchar()Returns the VARCHAR type.static DataTypevarint()Returns the VARINT type.
-
-
-
Field Detail
-
name
protected final DataType.Name name
-
-
Constructor Detail
-
DataType
protected DataType(DataType.Name name)
-
-
Method Detail
-
ascii
public static DataType ascii()
Returns the ASCII type.- Returns:
- The ASCII type.
-
bigint
public static DataType bigint()
Returns the BIGINT type.- Returns:
- The BIGINT type.
-
blob
public static DataType blob()
Returns the BLOB type.- Returns:
- The BLOB type.
-
cboolean
public static DataType cboolean()
Returns the BOOLEAN type.- Returns:
- The BOOLEAN type.
-
counter
public static DataType counter()
Returns the COUNTER type.- Returns:
- The COUNTER type.
-
decimal
public static DataType decimal()
Returns the DECIMAL type.- Returns:
- The DECIMAL type.
-
cdouble
public static DataType cdouble()
Returns the DOUBLE type.- Returns:
- The DOUBLE type.
-
cfloat
public static DataType cfloat()
Returns the FLOAT type.- Returns:
- The FLOAT type.
-
inet
public static DataType inet()
Returns the INET type.- Returns:
- The INET type.
-
tinyint
public static DataType tinyint()
Returns the TINYINT type.- Returns:
- The TINYINT type.
-
smallint
public static DataType smallint()
Returns the SMALLINT type.- Returns:
- The SMALLINT type.
-
cint
public static DataType cint()
Returns the INT type.- Returns:
- The INT type.
-
text
public static DataType text()
Returns the TEXT type.- Returns:
- The TEXT type.
-
timestamp
public static DataType timestamp()
Returns the TIMESTAMP type.- Returns:
- The TIMESTAMP type.
-
date
public static DataType date()
Returns the DATE type.- Returns:
- The DATE type.
-
time
public static DataType time()
Returns the TIME type.- Returns:
- The TIME type.
-
uuid
public static DataType uuid()
Returns the UUID type.- Returns:
- The UUID type.
-
varchar
public static DataType varchar()
Returns the VARCHAR type.- Returns:
- The VARCHAR type.
-
varint
public static DataType varint()
Returns the VARINT type.- Returns:
- The VARINT type.
-
timeuuid
public static DataType timeuuid()
Returns the TIMEUUID type.- Returns:
- The TIMEUUID type.
-
list
public static DataType.CollectionType list(DataType elementType, boolean frozen)
Returns the type of lists ofelementTypeelements.- Parameters:
elementType- the type of the list elements.frozen- whether the list is frozen.- Returns:
- the type of lists of
elementTypeelements.
-
list
public static DataType.CollectionType list(DataType elementType)
Returns the type of "not frozen" lists ofelementTypeelements.This is a shorthand for
list(elementType, false);.- Parameters:
elementType- the type of the list elements.- Returns:
- the type of "not frozen" lists of
elementTypeelements.
-
set
public static DataType.CollectionType set(DataType elementType, boolean frozen)
Returns the type of sets ofelementTypeelements.- Parameters:
elementType- the type of the set elements.frozen- whether the set is frozen.- Returns:
- the type of sets of
elementTypeelements.
-
set
public static DataType.CollectionType set(DataType elementType)
Returns the type of "not frozen" sets ofelementTypeelements.This is a shorthand for
set(elementType, false);.- Parameters:
elementType- the type of the set elements.- Returns:
- the type of "not frozen" sets of
elementTypeelements.
-
map
public static DataType.CollectionType map(DataType keyType, DataType valueType, boolean frozen)
Returns the type of maps ofkeyTypetovalueTypeelements.- Parameters:
keyType- the type of the map keys.valueType- the type of the map values.frozen- whether the map is frozen.- Returns:
- the type of maps of
keyTypetovalueTypeelements.
-
map
public static DataType.CollectionType map(DataType keyType, DataType valueType)
Returns the type of "not frozen" maps ofkeyTypetovalueTypeelements.This is a shorthand for
map(keyType, valueType, false);.- Parameters:
keyType- the type of the map keys.valueType- the type of the map values.- Returns:
- the type of "not frozen" maps of
keyTypetovalueTypeelements.
-
custom
public static DataType.CustomType custom(java.lang.String typeClassName)
Returns a Custom type.A custom type is defined by the name of the class used on the Cassandra side to implement it. Note that the support for custom types by the driver is limited.
The use of custom types is rarely useful and is thus not encouraged.
- Parameters:
typeClassName- the server-side fully qualified class name for the type.- Returns:
- the custom type for
typeClassName.
-
duration
public static DataType duration()
Returns the Duration type, introduced in Cassandra 3.10.Note that a Duration type does not have a native representation in CQL, and technically, is merely a special
custom typefrom the driver's point of view.- Returns:
- the Duration type. The returned instance is a singleton.
-
getName
public DataType.Name getName()
Returns the name of that type.- Returns:
- the name of that type.
-
isFrozen
public abstract boolean isFrozen()
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.
- Returns:
- whether this data type is frozen.
-
isCollection
public boolean isCollection()
Returns whether this data type represent a CQLcollection type, that is, a list, set or map.- Returns:
- whether this data type name represent the name of a collection type.
-
getTypeArguments
public java.util.List<DataType> getTypeArguments()
Returns the type arguments of this type.Note that only the collection types (LIST, MAP, SET) have type arguments. For the other types, this will return an empty list.
For the collection types:
- For lists and sets, this method returns one argument, the type of the elements.
- For maps, this method returns two arguments, the first one is the type of the map keys, the second one is the type of the map values.
- Returns:
- an immutable list containing the type arguments of this type.
-
asFunctionParameterString
public 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.In such places, the String representation might vary from the canonical one as returned by
Object.toString(); e.g. thefrozenkeyword is not accepted.- Returns:
- a String representation of this data type suitable for inclusion as a parameter type in a function or aggregate signature.
-
-