1111//! This module does not implement any of the safety checks that should be run
1212//! *before* the migration.
1313
14- use std:: { collections :: HashMap , pin:: pin, time:: Instant } ;
14+ use std:: { pin:: pin, time:: Instant } ;
1515
1616use chrono:: { DateTime , Utc } ;
1717use compact_str:: CompactString ;
@@ -25,7 +25,7 @@ use ulid::Ulid;
2525use uuid:: { NonNilUuid , Uuid } ;
2626
2727use crate :: {
28- SynapseReader ,
28+ HashMap , RandomState , SynapseReader ,
2929 mas_writer:: {
3030 self , MasNewCompatAccessToken , MasNewCompatRefreshToken , MasNewCompatSession ,
3131 MasNewEmailThreepid , MasNewUnsupportedThreepid , MasNewUpstreamOauthLink , MasNewUser ,
@@ -114,7 +114,7 @@ struct MigrationState {
114114
115115 /// A mapping of Synapse external ID providers to MAS upstream OAuth 2.0
116116 /// provider ID
117- provider_id_mapping : HashMap < String , Uuid > ,
117+ provider_id_mapping : std :: collections :: HashMap < String , Uuid > ,
118118}
119119
120120/// Performs a migration from Synapse's database to MAS' database.
@@ -136,16 +136,19 @@ pub async fn migrate(
136136 server_name : String ,
137137 clock : & dyn Clock ,
138138 rng : & mut impl RngCore ,
139- provider_id_mapping : HashMap < String , Uuid > ,
139+ provider_id_mapping : std :: collections :: HashMap < String , Uuid > ,
140140) -> Result < ( ) , Error > {
141141 let counts = synapse. count_rows ( ) . await . into_synapse ( "counting users" ) ?;
142142
143143 let state = MigrationState {
144144 server_name,
145145 // We oversize the hashmaps, as the estimates are innaccurate, and we would like to avoid
146146 // reallocations.
147- users : HashMap :: with_capacity ( counts. users * 9 / 8 ) ,
148- devices_to_compat_sessions : HashMap :: with_capacity ( counts. devices * 9 / 8 ) ,
147+ users : HashMap :: with_capacity_and_hasher ( counts. users * 9 / 8 , RandomState :: default ( ) ) ,
148+ devices_to_compat_sessions : HashMap :: with_capacity_and_hasher (
149+ counts. devices * 9 / 8 ,
150+ RandomState :: default ( ) ,
151+ ) ,
149152 provider_id_mapping,
150153 } ;
151154
0 commit comments