topk icon indicating copy to clipboard operation
topk copied to clipboard

Question about TOPK.PRANGE

Open ancuop opened this issue 8 years ago • 2 comments

I have played with your topk module and found something that make me confuse. I don't know whether it is bug or not. Please help to confirm. I made a test as below:

127.0.0.1:6379> TOPK.ADD testtop 5 t1 t2 t3 t4 t5 (integer) 5 127.0.0.1:6379> TOPK.PRANK testtop t1 t2 t3 t4 t5

  1. (integer) 100
  2. (integer) 100
  3. (integer) 100
  4. (integer) 100
  5. (integer) 100 127.0.0.1:6379> TOPK.PRANGE testtop 0 100
  6. "t5"
  7. "t5"
  8. "t4"
  9. "t3"
  10. "t2"

I thought TOPK.PRANGE should return "t5, t4, t3, t2, t1", is it correct? Thanks.

ancuop avatar Jun 28 '16 03:06 ancuop

From source code I found an issue on function TopKPRange_RedisCommand.

  • for ASC it run correctly because it replies with vector[0] to vector[vector_size-1]
  • for DESC it run not incorrectly as my previous comment because replies with vector[vector_size] to vector[1].

I have created a pull request, please help to review

ancuop avatar Jun 28 '16 05:06 ancuop

Thanks for spotting this issue - I'll review the PR asap!

itamarhaber avatar Jun 29 '16 12:06 itamarhaber