Nested map read/get API

Hi,

I am new to Aerospike (started this week only) and don’t have good hold on the APIs yet. I am trying to build a schema which has only one bin and want to store a nested map structure in this bin. Here is the detail of my nested map data structure. At the first level of map, my key is as an integer (1, 2 etc) and the corresponding value is another map. In the second level of map I want to store two key value pairs, “size” and “data”; something similar like this:

{
  1: {
    size : 4096,
    data : "aaaa"
  },
  2: {
    size : 2048,
    data : "bbbb"
  }
}

I am able to write this into the aerospike db (using c client’s as_operations_add_map_put_items operation) but not able to read it back. I can read the first level of map using “as_operations_add_map_get_by_index(&ops, <bin_name>, 0, AS_MAP_RETURN_VALUE)" and get "{ size : 4096, data : "aaaa" }” as output but not able to find a way to extract the value from second level of map. I want to read the value of “data” key from the next level of map and looking for right method for that.

Thanks

1 Like

As of Aerospike version 4.6 you can apply list and map operations on nested structures at arbitrary depths by defining a context. The context is the logical/physical path to finding the nested element you want to operate on.

I wrote a medium post on the topic