Tuesday, 2 May 2017

How to Implement Javascript Sorted set? (Similar to Redis' sorted set)

I'm trying to implement a sorted set data structure. The functionality I need is to insert a hash and a corresponding score. So the sorted set will be sorted based on the score, which is a number. When I search the sorted set by score, some of the scores I'm searching for won't be in the sorted set. I want to find the next-biggest score's hash.

For example, if the scores are 1, 3, and 4 in the sorted set and if I want to search for score 2, I want to return the hash at score 3.

To summarize: I have a data set of 11 million records so that's why I'm trying to implement a javascript sorted set that can search by score, and return the next biggest score's hash if the score I'm looking for doesn't exist.

Thank you!



via PythonNoobile

No comments:

Post a Comment