cqlengine: Refactor the Counter column to be more intuitive

Description

This is a follow-up ticket of PYTHON-497. According to our internal discussion, we would like to improve the Counter column to be more intuitive. The main issues are the following:

  • We need to read the row before updating the counter

  • It doesn't work well if we need to scale horizontally.. due to how the CounterUpdateClause is done internally. Before doing the counter update, we need to read the current row and store the current counter value, then the value sent in the update clause will be (new_value - current_value). But the current_value might have changed on the server in the meantime.

The suggested refactor is:

  • The counter values can *only* be incremented with __add:

  • The counter values can *only* be decremented with __sub:

  • Other kind of updates and assignments should be disallowed

Environment

None

Pull Requests

None

Assignee

Unassigned

Reporter

Alan Boudreault

Fix versions

Labels

PM Priority

None

External issue ID

None

Doc Impact

None

Reviewer

None

Size

None

Pull Request

None

Sprint

Py P-MAJOR-NEXT

Priority

Minor