topk
topk copied to clipboard
Question about TOPK.PRANGE
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
- (integer) 100
- (integer) 100
- (integer) 100
- (integer) 100
- (integer) 100 127.0.0.1:6379> TOPK.PRANGE testtop 0 100
- "t5"
- "t5"
- "t4"
- "t3"
- "t2"
I thought TOPK.PRANGE should return "t5, t4, t3, t2, t1", is it correct? Thanks.
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
Thanks for spotting this issue - I'll review the PR asap!