Cassandra Java Driver: How are insert, update, and delete results reported?

AlphaGeek picture AlphaGeek · Jan 15, 2014 · Viewed 8.5k times · Source

I am writing an application and I need to be able to tell if an inserts and updates succeed. I am using "INSERT ... IF NOT EXISTS" to get the light weight transaction behavior and noticed that the result set returned from execute, contains a row with updated data and an "[applied]" column that can be queried. That is great. But I have an update statement that is returning an empty ResultSet. It appears as though the update is succeeding but I want an programatic way to verify that.

To Clarify:

I have turned on some logging of the result sets returned by my mutations. I have found that "INSERT...IF NOT EXIST"s returns a ResultSet with a boolean column named "[applied]". If "[applied]" is false, it also returns the row that already exits.

With UPDATE, I always see an empty ResultSet.

So I have two questions:

  1. Where is the documentation on what the ResultSet should contain for each type of mutation? I did not see it in the CQL docs or in the Java Driver docs. I even tried looking at other language integrations' docs and did not find any description of the ResultSet contents for mutations.
  2. Is there any way to find out how many rows were modified by an UPDATE or deleted by a DELETE?

Answer

Arya picture Arya · Jan 16, 2014

In Cassandra insert/update/delete behave the same and they are called mutations. If your client is not returning any exceptions, then the mutation is done.

If you are concerned about consistency of your mutation calls, then add USING CONSISTENCY with higher levels.

http://www.datastax.com/docs/1.0/references/cql/index http://www.datastax.com/docs/1.1/dml/data_consistency

If you are after good consistency, I recommend using LOCAL_QUORUM for both reads and mutations. That way you don't have to worry about programmatically check a mutation because it will require a consequent read.