Scylla Documentation Logo Documentation
  • Server
    • Scylla Open Source
    • Scylla Enterprise
    • Scylla Alternator
  • Cloud
    • Scylla Cloud
    • Scylla Cloud Docs
  • Tools
    • Scylla Manager
    • Scylla Monitoring Stack
    • Scylla Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
Download
Menu

Caution

You're viewing documentation for a previous version of Scylla Java Driver. Switch to the latest stable version.

Scylla Java Driver Upgrade guide Migrating from Astyanax Language change : from Thrift to CQL

Language change : from Thrift to CQL¶

The data model changes when using CQL (Cassandra Query Language). CQL is providing an abstraction of the low-level data stored in Cassandra, in opposition to Thrift that aims to expose the low-level data structure directly. But note that this changes with Cassandra 3’s new storage engine.

Thrift exposes Keyspaces, and these Keyspaces contain Column Families. A ColumnFamily contains Rows in which each Row has a list of an arbitrary number of column-values. With CQL, the data is tabular, ColumnFamily gets viewed as a Table, the Table Rows get a fixed and finite number of named columns. Thrift’s columns inside the Rows get distributed in a tabular way through the Table Rows. See the following figure:

                                                     Thrift
             /-                                                                                          -\
             |                                                                                            |
             |  /------------\              /---------------+---------------+---------------+---------+   |
             |  |    cRED    |              |cFA0    1      |        2      |        3      |         |   |
             |  |     1      | ---------->  +---------------+---------------+---------------+ ...     |   +--> One Thrift
             |  |            |              |c1AB   'a'     |       'b'     |       'c'     |         |   |    ROW
             |  \------------/              \---------------+---------------+---------------+---------+   |
             |                                                                                            |
One Thrift   |                                                                                           -/
COLUMNFAMILY |          
             |  
             |  /------------\              /---------------+---------------+---------+
             |  |            |              |        1      |        2      |         |
             |  |     2      | ---------->  +---------------+---------------+ ...     |
             |  |            |              |       'a'     |       'b'     |         |
             |  \------------/              \---------------+---------------+---------+
             |  
             \- 


                      -----------------------------------------------------------------------


                                                     CQL

             /-                              
             |                               
             |  /--------------------+---------------------------------+-----------------------------\
             |  |       key          |              column1            |            value            |  
             |  +--------------------+---------------------------------+-----------------------------+
             |  | cRED   1           |  cFA0          1                |   c1AB      'a'             |
             |  +--------------------+---------------------------------+-----------------------------+ -\
             |  | cRED   1           |                2                |             'b'             |  +--> One CQL
   One CQL   |  +--------------------+---------------------------------+-----------------------------+ -/    ROW
   TABLE     |  | cRED   1           |                3                |             'c'             |
             |  +--------------------+---------------------------------+-----------------------------+
             |  | cRED  ...          |               ...               |             ...             |
             |  +--------------------+---------------------------------+-----------------------------+
             |  |        2           |                1                |             'a'             |
             |  +--------------------+---------------------------------+-----------------------------+
             |  |        2           |                2                |             'b'             |
             |  +--------------------+---------------------------------+-----------------------------+
             |  |       ...          |               ...               |             ...             |
             |  +--------------------+---------------------------------+-----------------------------+
             \-

Some of the columns of a CQL Table have a special role that is specifically related to the Cassandra architecture. Indeed, the Row key of the Thrift Row, becomes the Partition Key in the CQL Table, and can be composed of 1 or multiple CQL columns (the key column in Figure 1). The “Column” part of the Column-value component in a Thrift Row, becomes the Clustering Column in CQL, and can also be composed of multiple columns (in the figure, column1 is the only column composing the Clustering Column, but there can be others if the Thrift’s ColumnComparator is a CompositeType).

Here is the basic architectural concept of CQL, a detailed explanation and CQL examples can be found in this article : http://www.planetcassandra.org/making-the-change-from-thrift-to-cql/. Understanding the CQL abstraction plays a key role in developing performing and scaling applications.

PREVIOUS
Configuration
NEXT
Queries and Results
  • 3.11.2.x
    • 4.13.0.x
    • 4.12.0.x
    • 4.11.1.x
    • 4.10.0.x
    • 4.7.2.x
    • 3.11.2.x
    • 3.11.0.x
    • 3.10.2.x
    • 3.7.2.x
  • Scylla Java Driver for Scylla and Apache Cassandra®
  • API Documentation
  • Manual
    • Address resolution
    • Asynchronous programming
    • Authentication
    • Compression
    • Control connection
    • Custom Codecs
    • Custom Payloads
    • Query idempotence
    • Load balancing
    • Logging
    • Metadata
    • Metrics
    • Native protocol
    • Object Mapper
      • Definition of mapped classes
      • Using custom codecs
      • Using the mapper
    • OSGi
    • Paging
    • Connection pooling
    • Query timestamps
    • Reconnection
    • Retries
    • Using the shaded JAR
    • Socket options
    • Speculative query execution
    • SSL
    • Statements
      • Simple statements
      • Prepared statements
      • Built statements
      • Batch statements
    • Using Tuples with the Java driver
    • User-defined types
  • Upgrade guide
    • Migrating from Astyanax
      • Configuration
      • Language change : from Thrift to CQL
      • Queries and Results
  • Frequently Asked Questions
  • Changelog
  • Create an issue
  • Edit this page
Logo
Docs Contact Us About Us
Mail List Icon Slack Icon
© 2022, ScyllaDB. All rights reserved.
Last updated on 25 May 2022.
Powered by Sphinx 4.3.2 & ScyllaDB Theme 1.2.2