Main Content

Convert CQL Data Types toMATLABData Types Using ApacheCassandraDatabase C++ Interface

When you import data into MATLAB®using the Apache Cassandra®database C++ interface, thepartitionReadandexecutecqlfunctions convert the Cassandra Query Language (CQL) data types to MATLAB data types. When you export from MATLAB into a Cassandra database, theupsert将MATLAB数据类型转换为泰CQL数据pes. This table describes the CQL data types and shows their corresponding MATLAB data types for data import and export.

CQL Data Type CQL Data Type Description Data Type of MATLAB Table Variable for Data Import Data Type of MATLAB Table Variable for Data Export

ascii

US-ASCII character string

string

char,string, or cell array of character vectors

bigint

64-bit signed long integer

int64

  • double

  • single

  • int8

  • int16

  • int32

  • int64

  • uint8

  • uint16

  • uint32

  • uint64

  • logical

blob

Arbitrary bytes (no validation)

uint8

cell array of numeric vectors

boolean

trueorfalse

logical

  • double

  • single

  • int8

  • int16

  • int32

  • int64

  • uint8

  • uint16

  • uint32

  • uint64

  • logical

counter

Distributed counter value (64-bit long integer)

int64

Not supported by theupsertfunction

date

Value is a date with no corresponding time value. Cassandra encodes the date as a 32-bit integer representing days since epoch (January 1, 1970).

datetimearray without the time component and time zone

datetimearray,char,string, or cell array of character vectors

decimal

Variable-precision decimal

string

  • string

  • cell array of character vectors

  • double

  • single

  • int8

  • int16

  • int32

  • int64

  • uint8

  • uint16

  • uint32

  • uint64

  • sym

double

64-bit IEEE®-754 floating point

double

  • double

  • single

  • int8

  • int16

  • int32

  • int64

  • uint8

  • uint16

  • uint32

  • uint64

  • logical

float

32-bit IEEE-754 floating point

single

  • double

  • single

  • int8

  • int16

  • int32

  • int64

  • uint8

  • uint16

  • uint32

  • uint64

  • logical

inet

IP address string in IPv4 or IPv6 format

string

char,string, or cell array of character vectors

int

32-bit signed integer

int32

  • double

  • single

  • int8

  • int16

  • int32

  • int64

  • uint8

  • uint16

  • uint32

  • uint64

  • logical

list<type>

Collection of one or more ordered elements (for example,[literal, literal, literal])

Array of data types, one for each item in the collection.

For example, if a Cassandra database table column has thelistdata type, then each row in the MATLAB table contains an array ofint32数据类型。在这种情况下,data type of the MATLAB table variable is a cell array of arrays.

Cell array of vectors, where each vector is compatible with the type of the list.

For example, if the Cassandra database table containslist, then the MATLAB table must contain a cell array of numeric vectors.

map<keyType,valueType>

JSON-style array of literals (for example,{ literal : literal, literal : literal, ...})

Ann-by-2 MATLAB table wherenis the number of key-value pairs in the map. The first variableKeyshas the keys of the map. The data type for this variable depends on the key type defined for the map. Similarly, theValuesvariable has the values that correspond to each key. The data type for theValuesvariable depends on the value type defined for the map.

For example, if a Cassandra database table column has themapdata type, then thepartitionReadandexecutecqlfunctions convert this data type into a MATLAB table. The table has theKeysvariable as string scalars and theValuesvariable as adoublearray. In this case, the data type of the MATLAB table variable is a cell array of tables.

Cell array of tables, where each table contains theKeysandValuesvariables.

The data types of these two variables are compatible with the data types of the keys and values of the Cassandra database map.

For example, if the Cassandra database table containsmap, then the MATLAB table must contain a cell array of tables, where each table has aKeysvariable that is numeric and aValuesvariable that is a string.

set<type>

Collection of one or more elements (for example,{literal, literal, literal})

Array of data types, one for each item in the collection.

For example, if a Cassandra database column has thesetdata type, then each row in the resulting MATLAB table contains an array ofsinglevalues. In this case, the data type of the MATLAB table variable is a cell array of arrays.

Cell array of vectors, where each vector is compatible with the type of the collection.

For example, if the Cassandra database table containsset, then the MATLAB table must contain a cell array of numeric vectors.

smallint

2-byte integer

int16

  • double

  • single

  • int8

  • int16

  • int32

  • int64

  • uint8

  • uint16

  • uint32

  • uint64

  • logical

text

UTF-8 encoded string

string

char,string, or cell array of character vectors

time

Cassandra database encodes this value as a 64-bit signed integer that represents the number of nanoseconds since midnight.

durationarray

durationarray,char,string, or cell array of character vectors

timestamp

Date and time with millisecond precision, encoded as 8 bytes since epoch (January 1, 1970)

datetimearray with the date component and time zone as UTC or GMT

datetimearray,char,string, or cell array of character vectors

timeuuid

Version 1 UUID only

string

char,string, or cell array of character vectors

tinyint

1-byte integer

int8

  • double

  • single

  • int8

  • int16

  • int32

  • int64

  • uint8

  • uint16

  • uint32

  • uint64

  • logical

tuple<Type1,...,TypeN>

Group of unnamed but typed fields

A 1-by-nMATLAB表,nis the number of fields in the tuple. The variable names areVar1,Var2,Var3, and so on, untilVar(n). The data type of each variable depends on the Cassandra data types defined in the tuple.

For example, if a Cassandra database column has thetupledata type, then thepartitionReadandexecutecqlfunctions convert this data type into a MATLAB table. The table has theVar1variable as astringarray,Var2as anint16array, andVar3as adatetimearray. In this case, the data type of the MATLAB table variable is a table.

MATLAB table.

The position of each variable in the table determines which field the variable maps to in the tuple. The first variable in the table maps to the first field in the tuple, the second variable maps to the second field, and so on.

For example, if the Cassandra database table containstuple, then the MATLAB table must contain a table where the first variable is numeric and the second variable is a string.

user-defined type (UDT)

Group of named fields

A 1-by-nMATLAB表,nis the number of fields in the UDT. Variable names match the field names of the UDT. The data type of each variable depends on the Cassandra data types defined in the UDT. The data type of the MATLAB table variable is a table.

MATLAB table.

The names of the variables in the table must match the names of the UDT fields. The data type of each variable in the table must be compatible with the Cassandra data type of the corresponding UDT field.

uuid

UUID in standard UUID format

string

char,string, or cell array of character vectors

varchar

UTF-8 encoded string

string

char,string, or cell array of character vectors

varint

Arbitrary-precision integer

string

  • string

  • cell array of character vectors

  • double

  • single

  • int8

  • int16

  • int32

  • int64

  • uint8

  • uint16

  • uint32

  • uint64

  • sym

Note

For the CQL data type, if the data type is a collection (for example,list,map, and so on), then the value contains angle brackets (<>). These brackets surround the data types of the items in the collection. For details about valid Cassandra data types, seeCQL Data Types.

See Also

||

Related Topics

External Websites