tritigi / redis

Automatically exported from code.google.com/p/redis
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Feature request: ZREVRANGEBYSCORE #211

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be great to have a ZREVRANGEBYSCORE so that I could get the last N 
elements which fall 
between given scores. I am currently limited to getting the first N elements.

Further discussion can be found here:
http://groups.google.com/group/redis-
db/browse_thread/thread/43e41a44e1a1b90f/fabce3fdba55c3cb?lnk=raot

Original issue reported on code.google.com by acharnock on 29 Mar 2010 at 1:53

GoogleCodeExporter commented 9 years ago
also to make it more generic ZRANGEBYSCORE min max  can be altered to 
ZRANGEBYSCORE 
scorefrom scoreto.. will not be a breaking change also

Original comment by sariputr...@gmail.com on 14 Apr 2010 at 10:16

GoogleCodeExporter commented 9 years ago
It is really required not only for the completness of the operation set, but to 
avoid
doing client side resorting.

Original comment by anibalro...@gmail.com on 11 May 2010 at 10:00

GoogleCodeExporter commented 9 years ago
agreed.. and in a desperate need for it...

Original comment by sariputr...@gmail.com on 11 May 2010 at 10:39

GoogleCodeExporter commented 9 years ago
Yep. I am currently using a pretty clunky work around and hoping to see this in 
Redis before too long.

Original comment by acharnock on 11 May 2010 at 10:41

GoogleCodeExporter commented 9 years ago
I'll put in a $200 bounty on this feature. Anyone else in? (The $200 is yours 
if you implement this, even if nobody else is.)

Original comment by wils...@gmail.com on 3 Aug 2010 at 7:22

GoogleCodeExporter commented 9 years ago
I'm currently storing scores in negative to obtain a reverse order (and 
querying min and max in negative too), but still can't do forward and reverse 
at the same time.

Original comment by gbi...@gmail.com on 4 Aug 2010 at 1:44

GoogleCodeExporter commented 9 years ago
I have implemented it in my fork here: 
http://github.com/schleyfox/redis/commit/05c2521752b467337083947ec8789a8256e6c60
9

Going in reverse is slower because it does not benefit from the skip list.  As 
always, optimize for the more common use case.

Original comment by schley...@gmail.com on 9 Aug 2010 at 7:25

GoogleCodeExporter commented 9 years ago
patch by schleyfox work fine... but it whould be great to have ZREVRANGEBYSCORE 
(as we have ZREVRANGE, ZREVRANK) in all new versions

Original comment by vita...@gmail.com on 26 Aug 2010 at 1:28

GoogleCodeExporter commented 9 years ago
Any rough estimation when it's going to be written/merged? I'll probably have 
to start storing negative scores as well just to be able to fetch 10 items with 
the highest score...

Original comment by szi...@gmail.com on 5 Nov 2010 at 11:24

GoogleCodeExporter commented 9 years ago
ZREVRANGEBYSCORE is implemented in Redis master (see Github repository). The 
semantic is identical to ZRANGEBYSCORE but assumes a zset ordered from high to 
low scores. The min and max arguments should be used accordingly.

To get the highest N scores, use:
ZREVRANGEBYSCORE key +inf -inf LIMIT 0 N

Original comment by pcnoordh...@gmail.com on 5 Nov 2010 at 12:09