Creating a leaderboard with getting rank of a particular 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.