Open GoogleCodeExporter opened 9 years ago
Noted. This has come up before, but we haven't decided on whether
or not to do it. You have two options without direct leveldb support:
(1) Do a read-modify-write operation to update (can be expensive
and you will have to implement some concurrency control to lock
out other writers to the same key during this oepration).
(2) Arrange your schema in such a way that every logical key
maps to a set of neighboring leveldb keys (e.g.,
logical_key#seq_number). Then updates can be done by just
creating a new key and writing the delta under that key.
And reads can be done by adding a wrapper that merges
together values that fall under the same logical key.
Original comment by san...@google.com
on 18 Jan 2012 at 6:06
Thanks, I already use your first suggestion, as I need to read the old value to
check that the new is a valid state change anyway.
Original comment by morten.h...@gmail.com
on 3 Feb 2012 at 3:58
i am interesting of the secondary suggestion, maybe we need to introduce a
chain like store unit in the DB
Original comment by jyf1987
on 11 Sep 2012 at 8:09
For option (2), how would you recommend allocating sequence numbers?
- Could have sequence number in memory in process reading/writing to db but
awkward to recover sequence number if process crashes (would have to iterate
over all keys and use max_sequence_number + 1).
- Could store sequence number in db but would then have to use option (1) above
in order to read-modify-write to allocate a new sequence number.
- Could use a time-based sequence number but seems dangerous to trust clock
after crash/restart.
- Could use an external service to allocate sequence numbers but that seems
like kicking the can down the road.
What do you think?
Original comment by jtconnor@gmail.com
on 29 Mar 2014 at 8:07
Original issue reported on code.google.com by
morten.h...@gmail.com
on 10 Jan 2012 at 9:33