Zsumscore patch #1222

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
1 participant
Contributor

ripcurld0 commented Jul 27, 2013

Introduction

My patch to this feature request #1044

Syntax: ZSUMSCORE key min max

What it does is computing the sum of scores of members, which their scores are between min and max values, in the sorted set key.

Therefore, to compute the sum of scores of all the members in a specific sorted set, run:

ZSUMSCORE sorted_set_name -inf +inf

Notes

  • I have had the notion of adding a new variable, which holds the sum, to the skip-list & zip-list structures. By doing so, I probably achieve better performance (complexity O(1)). However, I guess that it is harder to implement and to test.
  • When running the ZSUMSCORE double stress test at the unit test, I get inaccurate results. Nevertheless, after replicating it manually, it seems fine. Even though, please note that when the score is with a floating point, the sum is accurate up to the 15th number after the point (or at least that is what I get when running the unit test).
  • Would like to hear you comments/ideas.

@ripcurld0 ripcurld0 closed this Mar 22, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment