Closed GoogleCodeExporter closed 8 years ago
sorry for the typo and the poor post title
Original comment by Bertrand...@gmail.com
on 30 Nov 2009 at 5:33
Hello! This is a nice idea in theory... but in practice it's an O(N) operation!
This is not
going to scale so this only gives the illusion of solving a problem in my
opinion. I'll
leave this issue open to think better about it.
Cheers,
Salvatore
Original comment by anti...@gmail.com
on 30 Nov 2009 at 5:52
I notice that adds into the sorted sets is O(log(n)), so I think you could get
a rank
in at least log(n) as well. This is assuming you're using some kind of tree to
do the
sorting. Basically, at every node in the tree, you store the total number of
elements
to the left and to the right.
So when you are navigating to a leaf you can use the number of elements you
know to
be less than it so far. If your child-nodes are linked back to the parent nodes
and
your hash structure is linked to the tree, then you could even find the node and
count up through the parents.
The hard part is maintaining those left and right sizes on inserts, removes, and
depending on your tree re-balancing.
Original comment by tyler...@gmail.com
on 17 Dec 2009 at 11:22
This feature is now available on git (as a log(N) operation). Docs at:
http://code.google.com/p/redis/wiki/ZrankCommand
Original comment by pcnoordh...@gmail.com
on 17 Mar 2010 at 4:27
Original issue reported on code.google.com by
Bertrand...@gmail.com
on 30 Nov 2009 at 5:32Attachments: