@@ -703,7 +703,7 @@ client_update_flying(Diff, MsgId, #client_msstate { flying_ets = FlyingEts,
703
703
704
704
clear_client (CRef , State = # msstate { cref_to_msg_ids = CTM ,
705
705
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 ),
707
707
dying_clients = maps :remove (CRef , DyingClients ) }.
708
708
709
709
@@ -740,7 +740,7 @@ init([Type, BaseDir, ClientRefs, StartupFunState]) ->
740
740
{CleanShutdown , IndexState , ClientRefs1 } =
741
741
recover_index_and_client_refs (IndexModule , FileSummaryRecovered ,
742
742
ClientRefs , Dir , Name ),
743
- Clients = dict :from_list (
743
+ Clients = maps :from_list (
744
744
[{CRef , {undefined , undefined , undefined }} ||
745
745
CRef <- ClientRefs1 ]),
746
746
% % CleanShutdown => msg location index and file_summary both
@@ -790,7 +790,7 @@ init([Type, BaseDir, ClientRefs, StartupFunState]) ->
790
790
clients = Clients ,
791
791
successfully_recovered = CleanShutdown ,
792
792
file_size_limit = FileSizeLimit ,
793
- cref_to_msg_ids = dict : new () ,
793
+ cref_to_msg_ids = #{} ,
794
794
credit_disc_bound = CreditDiscBound
795
795
},
796
796
% % 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,
843
843
flying_ets = FlyingEts ,
844
844
clients = Clients ,
845
845
gc_pid = GCPid }) ->
846
- Clients1 = dict : store (CRef , {CPid , MsgOnDiskFun , CloseFDsFun }, Clients ),
846
+ Clients1 = maps : put (CRef , {CPid , MsgOnDiskFun , CloseFDsFun }, Clients ),
847
847
erlang :monitor (process , CPid ),
848
848
reply ({IndexState , IndexModule , Dir , GCPid , FileHandlesEts , FileSummaryEts ,
849
849
CurFileCacheEts , FlyingEts },
@@ -874,15 +874,15 @@ handle_cast({client_dying, CRef},
874
874
875
875
handle_cast ({client_delete , CRef },
876
876
State = # msstate { clients = Clients }) ->
877
- State1 = State # msstate { clients = dict : erase (CRef , Clients ) },
877
+ State1 = State # msstate { clients = maps : remove (CRef , Clients ) },
878
878
noreply (clear_client (CRef , State1 ));
879
879
880
880
handle_cast ({write , CRef , MsgId , Flow },
881
881
State = # msstate { cur_file_cache_ets = CurFileCacheEts ,
882
882
clients = Clients ,
883
883
credit_disc_bound = CreditDiscBound }) ->
884
884
case Flow of
885
- flow -> {CPid , _ , _ } = dict : fetch (CRef , Clients ),
885
+ flow -> {CPid , _ , _ } = maps : get (CRef , Clients ),
886
886
% % We are going to process a message sent by the
887
887
% % rabbit_amqqueue_process. Now we are accessing the
888
888
% % msg_store process dictionary.
@@ -1003,7 +1003,7 @@ terminate(_Reason, State = #msstate { index_state = IndexState,
1003
1003
[true = ets :delete (T ) || T <- [FileSummaryEts , FileHandlesEts ,
1004
1004
CurFileCacheEts , FlyingEts ]],
1005
1005
IndexModule :terminate (IndexState ),
1006
- case store_recovery_terms ([{client_refs , dict : fetch_keys (Clients )},
1006
+ case store_recovery_terms ([{client_refs , maps : keys (Clients )},
1007
1007
{index_module , IndexModule }], Dir ) of
1008
1008
ok ->
1009
1009
rabbit_log :info (" Message store for directory '~s ' is stopped" , [Dir ]),
@@ -1035,12 +1035,12 @@ reply(Reply, State) ->
1035
1035
1036
1036
next_state (State = # msstate { sync_timer_ref = undefined ,
1037
1037
cref_to_msg_ids = CTM }) ->
1038
- case dict :size (CTM ) of
1038
+ case maps :size (CTM ) of
1039
1039
0 -> {State , hibernate };
1040
1040
_ -> {start_sync_timer (State ), 0 }
1041
1041
end ;
1042
1042
next_state (State = # msstate { cref_to_msg_ids = CTM }) ->
1043
- case dict :size (CTM ) of
1043
+ case maps :size (CTM ) of
1044
1044
0 -> {stop_sync_timer (State ), hibernate };
1045
1045
_ -> {State , 0 }
1046
1046
end .
@@ -1055,7 +1055,7 @@ stop_sync_timer(State) ->
1055
1055
internal_sync (State = # msstate { current_file_handle = CurHdl ,
1056
1056
cref_to_msg_ids = CTM }) ->
1057
1057
State1 = stop_sync_timer (State ),
1058
- CGs = dict :fold (fun (CRef , MsgIds , NS ) ->
1058
+ CGs = maps :fold (fun (CRef , MsgIds , NS ) ->
1059
1059
case gb_sets :is_empty (MsgIds ) of
1060
1060
true -> NS ;
1061
1061
false -> [{CRef , MsgIds } | NS ]
@@ -1327,7 +1327,7 @@ orddict_store(Key, Val, Dict) ->
1327
1327
update_pending_confirms (Fun , CRef ,
1328
1328
State = # msstate { clients = Clients ,
1329
1329
cref_to_msg_ids = CTM }) ->
1330
- case dict : fetch (CRef , Clients ) of
1330
+ case maps : get (CRef , Clients ) of
1331
1331
{_CPid , undefined , _CloseFDsFun } -> State ;
1332
1332
{_CPid , MsgOnDiskFun , _CloseFDsFun } -> CTM1 = Fun (MsgOnDiskFun , CTM ),
1333
1333
State # msstate {
@@ -1337,21 +1337,22 @@ update_pending_confirms(Fun, CRef,
1337
1337
record_pending_confirm (CRef , MsgId , State ) ->
1338
1338
update_pending_confirms (
1339
1339
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 )
1342
1343
end , CRef , State ).
1343
1344
1344
1345
client_confirm (CRef , MsgIds , ActionTaken , State ) ->
1345
1346
update_pending_confirms (
1346
1347
fun (MsgOnDiskFun , CTM ) ->
1347
- case dict :find (CRef , CTM ) of
1348
+ case maps :find (CRef , CTM ) of
1348
1349
{ok , Gs } -> MsgOnDiskFun (gb_sets :intersection (Gs , MsgIds ),
1349
1350
ActionTaken ),
1350
1351
MsgIds1 = rabbit_misc :gb_sets_difference (
1351
1352
Gs , MsgIds ),
1352
1353
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 )
1355
1356
end ;
1356
1357
error -> CTM
1357
1358
end
@@ -1419,7 +1420,7 @@ mark_handle_to_close(ClientRefs, FileHandlesEts, File, Invoke) ->
1419
1420
[ begin
1420
1421
case (ets :update_element (FileHandlesEts , Key , {2 , close })
1421
1422
andalso Invoke ) of
1422
- true -> case dict : fetch (Ref , ClientRefs ) of
1423
+ true -> case maps : get (Ref , ClientRefs ) of
1423
1424
{_CPid , _MsgOnDiskFun , undefined } ->
1424
1425
ok ;
1425
1426
{_CPid , _MsgOnDiskFun , CloseFDsFun } ->
0 commit comments