Clearing map keys in UDF while using map.pairs

I am trying to clear keys from a map in a UDF while iterating it. Usually it is not a good idea to mutate a collection while using an iterator using map.pairs, is this also true for Aerospike maps? What is the recommended way to do this if it is not possible to iterate and mutate the map using map.pairs?

You are correct that it is not a good idea to make structural changes to a collection within an iterator over the collection. Removing an entry in a map would qualify as a structural change, while changing its value would not. If you want to remove certain keys from a map it would be safer to iterate over the map to collect such keys in a list, and then iterate over the list to remove the keys from the map.