Defining persistent map
A persistent map is an instance of a persistent map class. So, before instantiating the instance, we must define the persistent class as follows:
pmap_definition() ::= 'persistent' 'class' <ID> 'of' 'map' '<' key_type(),
',' value_type() '>'
top_declaration ::= ... |pmap_declaration();
The persistent map declaration needs to be done at the top level with global scope. The syntax for instantiating a persistent map from a persistent map class is as follows:
pmap_expr ::='new' <ID> [ '(' <string> ')' ] [ '{' item_list() '}' ]
For example, defining type of values in the persistent map is done as shown below:
type UserObject = object{avg_resp_time: float, max_time: int, current_user: string};
Defining persistent map:
persistent class UserCls of map<string, UserObject>;
Creating instance of persistent map,
val ucls0 = new UserCls ("ucls0"){
"user_key01" : UserObject {avg_resp_time: 4.4, max_time: 8, current_user: "John"},
"user_key02" : UserObject {avg_resp_time: 5.6, max_time: 4, current_user: "Smith"}
};