On Thu, Oct 25, 2012 at 9:41 AM, Dvir Volk <
dvi...@gmail.com> wrote:
> please do. I was just stating my own need here.
> what if you could just pass a lambda expression in Lua that takes S1, S1 and
> returns whatever you want? :)
Okay, I'll post them later. But I can just about assure you that you
really don't want this done in Lua unless your ZSETs are small or
unless you've already swapped Lua out for LuaJIT.
> Well, you're right, but it doesn't matter if you do it in your app on in
> redis - you have floating point numbers and it's fragile. obviously any app
> where this matters won't use this feature anyhow, but for most cases it
> should be perfectly fine IMHO. Especially in the use case of turning integer
> counts into fractions of the total.
Generally speaking, I've been a big fan of keeping total count
information as part of tree structures themselves. ZSET skiplists
should include "order statistic" information for pulling the Xth item,
adding running totals isn't really that bad in practice (I've done it
myself for other structures I've built). If done as part of the
structure, any arbitrary operation can get flushed back into the
structure without much difficulty, though binary trees can make this
easier. It can increase memory use (depending on whether there is
internal fragmentation for the nodes already), but but would address
many of the issues with precision in the majority of cases.
Then again, maybe just keeping a total is simpler and solves most of the issues.
- Josiah