This discussion is archived
1 Reply Latest reply: Oct 6, 2012 12:56 PM by greybird RSS

counters or sequence generators

450652 Explorer
Currently Being Moderated
wondering if it provides some kind of counters or sequence number generator? i want to use the sequence for minor keys. the use case is, i have bunch log data that i collected, i want to store them using some kind of auto-incremented minor keys.

is there any append to value feature.. lets say i have an existing kv, now i collected more data for the key, i just want to append the value to the existing value. i don't want to fetch the whole value, append them in application layer and send the updated value to kvstore.
  • 1. Re: counters or sequence generators
    greybird Expert
    Currently Being Moderated
    Neither of these features are in the product.

    It is possible to implement your own counter using a single kv pair that stores the last used value. When you update it, you'll need to use putIfVersion along with a retry loop to support concurrent updates. And you should increment the value by more than 1 -- say by 100 -- and dole out the 100 values on the client side before updating the counter again; this avoid updating the counter for every insert operation.

    If you find yourself wanting to append to a value, you should consider multiple kv pairs instead, with keys designed such that they can be queried using a multi-get operation. In almost all cases the data store performs better when multiple values are inserted, rather than updating a single kv pair and appending to its value.

    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points