Understand the numeric data types available in Cassandra.
- Cassandra is often used to store large volumes of data. In these cases, it is especially important to understand the differences and data types. There are several kinds of numeric data types in Cassandra. Using the right numeric data type will help ensure that you're able to capture the information you need, without wasting space because your data type uses more bytes than is needed. The options for storing numeric data type include: INT, BIGINT, TINYINT, and VARINT for integers, as well as decimals, doubles, and floats.
The INT data type is used to specify 32 bit signed integers. This means that one bit is used to indicate a positive or negative number, and 31 bits are used to represent the number itself. The largest number it can hold is about 2.147 billion. And the smallest is about negative 2.147 billion. BIGINT is like INT, but it is a signed 64 bit number. It uses one bit to indicate a positive or negative number, and 63 bits to represent the numeric value.
The largest number it can store is two to the 63rd, and the smallest is minus two to the 63rd. These numbers are in the range of about negative nine quintrillion, to positive nine quintrillion. TINYINTs are used to store one byte numbers. Signed numbers are in the range of negative 127 to 127. Unsigned numbers range from zero to 255. VARINT is used to store variable length integers.
Like VARCHAR, that uses a variable length in coding to store integers. Decimal values let us define variable precision decimal values. For example, we could specify a column with 10 numbers, two of which are used for decimal values. This supports numbers such as 12345678.01. A float is used to store 32 bit IEEE 754 floating point number, while a double is used to specify a 64 bit IEEE 754 floating point number.
Now the IEEE 754 standard, is a widely used standard for defining floating point numbers. These same float and double data types, are also used in Java.
- Cassandra architecture
- Keyspaces, tables, and columns
- Installing Java and Cassandra
- CQL data types
- Designing Cassandra tables
- Tuning tables to optimize queries
- When to use secondary indexes and materialized views
- Physical data modeling and distributing data
- Cassandra architecture and its impact on data modeling