Support Lightweight Transactions in the Mapper API

Description

I don't believe it's currently possible to use the Mapper API to execute CQL that's using LWT. The Insert, Update, Delete, and Execute methods all return void (or Task in the case of the async versions) so there's no current way to retrieve the [applied] column that would come back, or the current values that would be returned in the case where [applied] is false.

Questions:

  • What should the API look like?

    • Can we reuse an existing method and just add an overload with a return value or do we need to create a specific method?

    • If we do create specific methods, do we need to be able to generate appropriate CQL for LWT?

  • The LINQ driver looks like it supports adding IF or IF NOT EXISTS to generated CQL, but the Execute methods don't return anything where you can check the result. Is this accurate? Should we fix them?


Update

Mapper API:

Environment

None

Activity

Show:
Rui Taborda
August 21, 2015, 11:47 PM

Hi, I'm currently trying to use the ExecuteConditional method but I'm having a problem with getting the rows that failed.
Apparently the ExecuteConditional only returns one of the objects that failed to be inserted, but what if there where more than one?
In my case I need to get all the rows that failed to be inserted.

I tried this but it doesn't work:
AppliedInfo<IEnumerable<MyClass>>

Thanks for your time

Jorge Bay Gondra
August 22, 2015, 12:07 AM

Cassandra only yields the first condition that failed in a batch result so there is no way to get that information at driver level.

You should check if that information is enough for you or if changes in the data model or data access solve the issue. If you have any doubt or need any help, don't hesitate to post it in the project mailing list: https://groups.google.com/a/lists.datastax.com/forum/#!forum/csharp-driver-user

Rui Taborda
August 22, 2015, 12:31 AM

I have this implemented without using the mappings and it is returning all the rows that failed.
In that implementation I'm creating a BatchStatement, and then I add several BoundStatements to it and execute the batch with session.Execute(batch). The result RowSet object I get from that execution has a RowQueue property that contains a collection of Cassandra.Row objects that represent the rows that failed.

Shouldn't it be possible to do the same with the ExecuteConditional and the AppliedInfo?

Jorge Bay Gondra
August 22, 2015, 1:55 AM

Ohh... sorry, you are right: I just created a ticket for it CSHARP-334.

Thanks for insisting!

Rui Taborda
August 22, 2015, 2:01 AM

Thank you

Fixed

Assignee

Jorge Bay Gondra

Reporter

Luke Tillman

PM Priority

A

Fix versions

External issue ID

None

Doc Impact

None

Reviewer

Luke Tillman

Pull Request

None

Epic Link

None

Sprint

None

Pull Requests

None

Size

None

Components

Priority

Major