Using all values in as_map/as_hashmap

I want to use/store all the as_map/as_hashmap keys and their corresponding values in my client program. I’ve not been able to find a function using which I can iteratively go through all the keys/values in the as_map/as_hashmap. Please help.

There is as_map_foreach() and as_map_iterator_init().

See aerospike-client-c/udf_types.c at bda70092be0b3e14c24b4debe96dd52f45c2a485 · aerospike/aerospike-client-c · GitHub

1 Like
as_hashmap_iterator it;
as_hashmap_iterator_init(&it, &map);
while ( as_hashmap_iterator_has_next(&it) )
 {
    const as_val * val = as_hashmap_iterator_next(&it);
        }

How will I get the map’s key and value from as_val? Are there any functions like as_map_get_key(iterator) and as_map_get_value(iterator)?

You cast it to (as_pair*). See aerospike-client-c/udf_types.c at bda70092be0b3e14c24b4debe96dd52f45c2a485 · aerospike/aerospike-client-c · GitHub

1 Like

Thanks a lot! This looks like exactly what I wanted. Will try this method today.

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