How to re-insert record with counter column after delete it in Cassandra? -


i create table counter column in cassandra, :

create table test_count(     pk int,     count counter,     primary key (pk) ); 

and after update record like:

update test_count set count = count + 1 pk = 1; 

then want reset count 0, there's no reset command in cql, delete record:

delete test_count pk = 1; 

and re-execute update cql, when select * test_count, there's no record pk = 1, bug of cassandra? when delete record counter column, disappears forever? how can reset count column 0? how can re-insert record counter column?

  1. you can first query counter current value , issue update subtract amount.

  2. you can delete counter, , start new counter using different row key. no longer try use original counter. approach might want partition counters day or week, when new day started, you'd start fresh set of zeroed out counters.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -