155155-type client_msstate () :: # client_msstate {
156156 server :: server (),
157157 client_ref :: client_ref (),
158- file_handle_cache :: dict : dict (),
158+ file_handle_cache :: map (),
159159 index_state :: any (),
160160 index_module :: atom (),
161161 dir :: file :filename (),
@@ -495,7 +495,7 @@ client_init(Server, Ref, MsgOnDiskFun, CloseFDsFun) when is_pid(Server); is_atom
495495 ? CREDIT_DISC_BOUND ),
496496 # client_msstate { server = Server ,
497497 client_ref = Ref ,
498- file_handle_cache = dict : new () ,
498+ file_handle_cache = #{} ,
499499 index_state = IState ,
500500 index_module = IModule ,
501501 dir = Dir ,
@@ -703,7 +703,7 @@ client_update_flying(Diff, MsgId, #client_msstate { flying_ets = FlyingEts,
703703
704704clear_client (CRef , State = # msstate { cref_to_msg_ids = CTM ,
705705 dying_clients = DyingClients }) ->
706- State # msstate { cref_to_msg_ids = dict : erase (CRef , CTM ),
706+ State # msstate { cref_to_msg_ids = maps : remove (CRef , CTM ),
707707 dying_clients = maps :remove (CRef , DyingClients ) }.
708708
709709
@@ -740,7 +740,7 @@ init([Type, BaseDir, ClientRefs, StartupFunState]) ->
740740 {CleanShutdown , IndexState , ClientRefs1 } =
741741 recover_index_and_client_refs (IndexModule , FileSummaryRecovered ,
742742 ClientRefs , Dir , Name ),
743- Clients = dict :from_list (
743+ Clients = maps :from_list (
744744 [{CRef , {undefined , undefined , undefined }} ||
745745 CRef <- ClientRefs1 ]),
746746 % % CleanShutdown => msg location index and file_summary both
@@ -776,7 +776,7 @@ init([Type, BaseDir, ClientRefs, StartupFunState]) ->
776776 index_state = IndexState ,
777777 current_file = 0 ,
778778 current_file_handle = undefined ,
779- file_handle_cache = dict : new () ,
779+ file_handle_cache = #{} ,
780780 sync_timer_ref = undefined ,
781781 sum_valid_data = 0 ,
782782 sum_file_size = 0 ,
@@ -790,7 +790,7 @@ init([Type, BaseDir, ClientRefs, StartupFunState]) ->
790790 clients = Clients ,
791791 successfully_recovered = CleanShutdown ,
792792 file_size_limit = FileSizeLimit ,
793- cref_to_msg_ids = dict : new () ,
793+ cref_to_msg_ids = #{} ,
794794 credit_disc_bound = CreditDiscBound
795795 },
796796 % % If we didn't recover the msg location index then we need to
@@ -843,7 +843,7 @@ handle_call({new_client_state, CRef, CPid, MsgOnDiskFun, CloseFDsFun}, _From,
843843 flying_ets = FlyingEts ,
844844 clients = Clients ,
845845 gc_pid = GCPid }) ->
846- Clients1 = dict : store (CRef , {CPid , MsgOnDiskFun , CloseFDsFun }, Clients ),
846+ Clients1 = maps : put (CRef , {CPid , MsgOnDiskFun , CloseFDsFun }, Clients ),
847847 erlang :monitor (process , CPid ),
848848 reply ({IndexState , IndexModule , Dir , GCPid , FileHandlesEts , FileSummaryEts ,
849849 CurFileCacheEts , FlyingEts },
@@ -874,15 +874,15 @@ handle_cast({client_dying, CRef},
874874
875875handle_cast ({client_delete , CRef },
876876 State = # msstate { clients = Clients }) ->
877- State1 = State # msstate { clients = dict : erase (CRef , Clients ) },
877+ State1 = State # msstate { clients = maps : remove (CRef , Clients ) },
878878 noreply (clear_client (CRef , State1 ));
879879
880880handle_cast ({write , CRef , MsgId , Flow },
881881 State = # msstate { cur_file_cache_ets = CurFileCacheEts ,
882882 clients = Clients ,
883883 credit_disc_bound = CreditDiscBound }) ->
884884 case Flow of
885- flow -> {CPid , _ , _ } = dict : fetch (CRef , Clients ),
885+ flow -> {CPid , _ , _ } = maps : get (CRef , Clients ),
886886 % % We are going to process a message sent by the
887887 % % rabbit_amqqueue_process. Now we are accessing the
888888 % % msg_store process dictionary.
@@ -1003,7 +1003,7 @@ terminate(_Reason, State = #msstate { index_state = IndexState,
10031003 [true = ets :delete (T ) || T <- [FileSummaryEts , FileHandlesEts ,
10041004 CurFileCacheEts , FlyingEts ]],
10051005 IndexModule :terminate (IndexState ),
1006- case store_recovery_terms ([{client_refs , dict : fetch_keys (Clients )},
1006+ case store_recovery_terms ([{client_refs , maps : keys (Clients )},
10071007 {index_module , IndexModule }], Dir ) of
10081008 ok ->
10091009 rabbit_log :info (" Message store for directory '~s ' is stopped" , [Dir ]),
@@ -1035,12 +1035,12 @@ reply(Reply, State) ->
10351035
10361036next_state (State = # msstate { sync_timer_ref = undefined ,
10371037 cref_to_msg_ids = CTM }) ->
1038- case dict :size (CTM ) of
1038+ case maps :size (CTM ) of
10391039 0 -> {State , hibernate };
10401040 _ -> {start_sync_timer (State ), 0 }
10411041 end ;
10421042next_state (State = # msstate { cref_to_msg_ids = CTM }) ->
1043- case dict :size (CTM ) of
1043+ case maps :size (CTM ) of
10441044 0 -> {stop_sync_timer (State ), hibernate };
10451045 _ -> {State , 0 }
10461046 end .
@@ -1055,7 +1055,7 @@ stop_sync_timer(State) ->
10551055internal_sync (State = # msstate { current_file_handle = CurHdl ,
10561056 cref_to_msg_ids = CTM }) ->
10571057 State1 = stop_sync_timer (State ),
1058- CGs = dict :fold (fun (CRef , MsgIds , NS ) ->
1058+ CGs = maps :fold (fun (CRef , MsgIds , NS ) ->
10591059 case gb_sets :is_empty (MsgIds ) of
10601060 true -> NS ;
10611061 false -> [{CRef , MsgIds } | NS ]
@@ -1327,7 +1327,7 @@ orddict_store(Key, Val, Dict) ->
13271327update_pending_confirms (Fun , CRef ,
13281328 State = # msstate { clients = Clients ,
13291329 cref_to_msg_ids = CTM }) ->
1330- case dict : fetch (CRef , Clients ) of
1330+ case maps : get (CRef , Clients ) of
13311331 {_CPid , undefined , _CloseFDsFun } -> State ;
13321332 {_CPid , MsgOnDiskFun , _CloseFDsFun } -> CTM1 = Fun (MsgOnDiskFun , CTM ),
13331333 State # msstate {
@@ -1337,21 +1337,22 @@ update_pending_confirms(Fun, CRef,
13371337record_pending_confirm (CRef , MsgId , State ) ->
13381338 update_pending_confirms (
13391339 fun (_MsgOnDiskFun , CTM ) ->
1340- dict :update (CRef , fun (MsgIds ) -> gb_sets :add (MsgId , MsgIds ) end ,
1341- gb_sets :singleton (MsgId ), CTM )
1340+ maps :update_with (CRef ,
1341+ fun (MsgIds ) -> gb_sets :add (MsgId , MsgIds ) end ,
1342+ gb_sets :singleton (MsgId ), CTM )
13421343 end , CRef , State ).
13431344
13441345client_confirm (CRef , MsgIds , ActionTaken , State ) ->
13451346 update_pending_confirms (
13461347 fun (MsgOnDiskFun , CTM ) ->
1347- case dict :find (CRef , CTM ) of
1348+ case maps :find (CRef , CTM ) of
13481349 {ok , Gs } -> MsgOnDiskFun (gb_sets :intersection (Gs , MsgIds ),
13491350 ActionTaken ),
13501351 MsgIds1 = rabbit_misc :gb_sets_difference (
13511352 Gs , MsgIds ),
13521353 case gb_sets :is_empty (MsgIds1 ) of
1353- true -> dict : erase (CRef , CTM );
1354- false -> dict : store (CRef , MsgIds1 , CTM )
1354+ true -> maps : remove (CRef , CTM );
1355+ false -> maps : put (CRef , MsgIds1 , CTM )
13551356 end ;
13561357 error -> CTM
13571358 end
@@ -1402,9 +1403,9 @@ close_handle(Key, State = #msstate { file_handle_cache = FHC }) ->
14021403 State # msstate { file_handle_cache = close_handle (Key , FHC ) };
14031404
14041405close_handle (Key , FHC ) ->
1405- case dict :find (Key , FHC ) of
1406+ case maps :find (Key , FHC ) of
14061407 {ok , Hdl } -> ok = file_handle_cache :close (Hdl ),
1407- dict : erase (Key , FHC );
1408+ maps : remove (Key , FHC );
14081409 error -> FHC
14091410 end .
14101411
@@ -1419,7 +1420,7 @@ mark_handle_to_close(ClientRefs, FileHandlesEts, File, Invoke) ->
14191420 [ begin
14201421 case (ets :update_element (FileHandlesEts , Key , {2 , close })
14211422 andalso Invoke ) of
1422- true -> case dict : fetch (Ref , ClientRefs ) of
1423+ true -> case maps : get (Ref , ClientRefs ) of
14231424 {_CPid , _MsgOnDiskFun , undefined } ->
14241425 ok ;
14251426 {_CPid , _MsgOnDiskFun , CloseFDsFun } ->
@@ -1456,16 +1457,16 @@ close_all_indicated(#client_msstate { file_handles_ets = FileHandlesEts,
14561457close_all_handles (CState = # client_msstate { file_handles_ets = FileHandlesEts ,
14571458 file_handle_cache = FHC ,
14581459 client_ref = Ref }) ->
1459- ok = dict :fold (fun (File , Hdl , ok ) ->
1460+ ok = maps :fold (fun (File , Hdl , ok ) ->
14601461 true = ets :delete (FileHandlesEts , {Ref , File }),
14611462 file_handle_cache :close (Hdl )
14621463 end , ok , FHC ),
1463- CState # client_msstate { file_handle_cache = dict : new () };
1464+ CState # client_msstate { file_handle_cache = #{} };
14641465
14651466close_all_handles (State = # msstate { file_handle_cache = FHC }) ->
1466- ok = dict :fold (fun (_Key , Hdl , ok ) -> file_handle_cache :close (Hdl ) end ,
1467+ ok = maps :fold (fun (_Key , Hdl , ok ) -> file_handle_cache :close (Hdl ) end ,
14671468 ok , FHC ),
1468- State # msstate { file_handle_cache = dict : new () }.
1469+ State # msstate { file_handle_cache = #{} }.
14691470
14701471get_read_handle (FileNum , CState = # client_msstate { file_handle_cache = FHC ,
14711472 dir = Dir }) ->
@@ -1478,11 +1479,11 @@ get_read_handle(FileNum, State = #msstate { file_handle_cache = FHC,
14781479 {Hdl , State # msstate { file_handle_cache = FHC2 }}.
14791480
14801481get_read_handle (FileNum , FHC , Dir ) ->
1481- case dict :find (FileNum , FHC ) of
1482+ case maps :find (FileNum , FHC ) of
14821483 {ok , Hdl } -> {Hdl , FHC };
14831484 error -> {ok , Hdl } = open_file (Dir , filenum_to_name (FileNum ),
14841485 ? READ_MODE ),
1485- {Hdl , dict : store (FileNum , Hdl , FHC )}
1486+ {Hdl , maps : put (FileNum , Hdl , FHC )}
14861487 end .
14871488
14881489preallocate (Hdl , FileSizeLimit , FinalPos ) ->
0 commit comments