Hash tables inside hash table - data modelling problem

Hello!

I want to store in Aerospike the maps of profiles(profileId(int type) → string) by some string keys (these keys count not limited). In other words - hash tables inside hash table: map[string]map[int]string.

And I have two use cases:

  1. Fast find all profiles by string key
  2. Fast find concrete profile by profileId key and string key

I found the next solution: store all in one record. Every bin will have the following form:

Bin("keyString", map[int]string{1: "profileData1", 2: "profileData2", ...})

For case1 I can use ‘Get’ function by key and binName.

For case2 - ‘MapGetByKeyOp’ function with binName, int key and MapReturnType.VALUE parameters.

But I found that exists limit on bin count in one record - 32767. It’s broke my solution but I cannot find any other.

Any ideas? Thank you.

Hi Nikki,

Here is my thought about your problems and how to solved it.

Your issues: you probably should not design a set like that as i thought very bad design. (remember aerospike also have limit in record size too )

1, For fast way to get all profiles by a key string, you can use a secondary index

2, For find concrete profile you can use Primary key directly

Set: user_profiles PK = string key + “|” + profileId (int) Bins:

  • key string - secondary index
  • profile data ( your bins for store data )

Assume you are using golang lib

So for question 1: We just create a query statement with filter equal to that bin we already indexed, response will be very fast as it only search in memory ( remember no expression operation here )

For question 2: Just get directly record by key combined from your key string and profile id

Hope that help. ( sorry if it feel aggressive as my english is not good so i just write it straigth what i thought )