Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-13350

getByPk() utility methods in Datastax session object

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Normal
    • Resolution: Invalid
    • None
    • None
    • None

    Description

      Data modeling in Cassandra is the key to querying.
      Best way to query is to have tables where you always query by primary-key or by partition-key.

      And yet there is no method in the datastax's session object that simplifies this process.
      It would be great to have methods like:

      1. session.getByPrimaryKey (String tableName, Object []primaryKeys)
      2. session.getByPartitionKey (String tableName, Object []partitionKeys)
      3. session.getByPartitionKeys (String tableName, Object [][]partitionKeys) // Like an in-query
      4. session.getByPrimaryKeys (String tableName, Object [][]primaryKeys)

      The last is an unsupported feature yet in Cassandra but it would be really awesome to have the same. It would be like a read equivalent of the batch-statements in write.

      Advantages:

      1. Ease-of-use: User does not have to create a string query or a prepared query.
      2. User does not have to worry about using prepared statements with select * queries. I am not yet sure how the driver would handle it but if it can, wow!
      3. If murmur-3 hashing in the client is same as the cluster, clients can query just the right node (Better token-aware?)

      Such methods are present in several other software. Examples:

      1. Hibernate: session.get() and
      2. JPA: find().
      3. Solr: getById() and several flavors of the same.

      (Please note that these links are just an example, not meant to provide implementation details or the behavior).

      As a feature, session.getByPrimaryKeys (String tableName, Object [][]primaryKeys) should help get a performance boost to the users because it allows running queries for different partitions in parallel and also allows getting results from the same partition in one query. We can put this in a separate JIRA task if it is seen as a useful feature by all.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sachingoyal Sachin Goyal
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: