Creating a leaderboard with getting rank of a particular record


Hello, I was going through this to create a leaderboard application for my work but I also need to calculate the rank of a particular record item at the same time, I can modify the aggregate function in the code given there to calculate the rank of that particular record in the particular stream, but then how can I reduce it to get the exact Rank for that record ??


Hi Piyush. The code you’re looking at is 2-3 years old. Since then Aerospike has expanded both the list and map complex data types (CDT) to have an extensive API. Specifically, map can now be defined as unsorted, K-sorted or KV-sorted, enabling you to create something like a leaderboard using the atomic rank operations for SortedMap.

I would be using these native map operations, rather than implementing them as a UDF for superior performance and reduced complexity. It’s also faster to develop with the atomic operations at hand than to recreate it as a UDF. In the Java client you’ll be using MapOrder and MapOperation classes. Other clients have support for the List and Map CDT API as well.

Take a look at Aveek’s engineering blog post Modelling Time-Series Data for Top-Performing Stocks in Aerospike using Sorted Maps.


Thanks Ronen for your reply I looked into the native map solution but I thought there might be a limit on how many entries a native map bin could have.


The limit, if the data is kept on SSD is the write-block-size defined for the namespace. Currently that is 1MB at most, but will rise to 8MB in a future release.

There are workarounds to overflowing into sub records.

closed #5

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.