hanoidb icon indicating copy to clipboard operation
hanoidb copied to clipboard

Implement update_counter

Open brigadier opened this issue 12 years ago • 2 comments

I wonder how hard it would be to change hanoidb to impleent something like mnesia's dirty_update_counter? Like, locate record, if found - treat value as int, increment it and write the result in the same place, if not found - create new record, everything in one atomic and probably fast operation? Would that be possible at all with architecture of this kv storage?

brigadier avatar Sep 09 '13 12:09 brigadier

There are some interesting possibilities with CRDT-based counters, especially if you want fast updates, and can live with slightly slower reads. In this case, we could write update deltas ("increment by X"), which would be very fast; and have the merge operation accumulate counter updates. A read would then have to go through all log(N) levels and add up the counter value. So yes, it would indeed be possible.

krestenkrab avatar Sep 10 '13 07:09 krestenkrab

Will deltas work with key expire time and space compaction? I think in this case we will have to update timestamps of all updates in the stack anyway.

brigadier avatar Sep 10 '13 11:09 brigadier