11
11
//! This module does not implement any of the safety checks that should be run
12
12
//! *before* the migration.
13
13
14
- use std:: { collections :: HashMap , pin:: pin, time:: Instant } ;
14
+ use std:: { pin:: pin, time:: Instant } ;
15
15
16
16
use chrono:: { DateTime , Utc } ;
17
17
use compact_str:: CompactString ;
@@ -26,7 +26,7 @@ use ulid::Ulid;
26
26
use uuid:: Uuid ;
27
27
28
28
use crate :: {
29
- SynapseReader ,
29
+ HashMap , RandomState , SynapseReader ,
30
30
mas_writer:: {
31
31
self , MasNewCompatAccessToken , MasNewCompatRefreshToken , MasNewCompatSession ,
32
32
MasNewEmailThreepid , MasNewUnsupportedThreepid , MasNewUpstreamOauthLink , MasNewUser ,
@@ -116,7 +116,7 @@ struct MigrationState {
116
116
117
117
/// A mapping of Synapse external ID providers to MAS upstream OAuth 2.0
118
118
/// provider ID
119
- provider_id_mapping : HashMap < String , Uuid > ,
119
+ provider_id_mapping : std :: collections :: HashMap < String , Uuid > ,
120
120
}
121
121
122
122
/// Performs a migration from Synapse's database to MAS' database.
@@ -139,7 +139,7 @@ pub async fn migrate(
139
139
server_name : String ,
140
140
clock : & dyn Clock ,
141
141
rng : & mut impl RngCore ,
142
- provider_id_mapping : HashMap < String , Uuid > ,
142
+ provider_id_mapping : std :: collections :: HashMap < String , Uuid > ,
143
143
) -> Result < ( ) , Error > {
144
144
let span = Span :: current ( ) ;
145
145
span. pb_set_message ( "counting work" ) ;
@@ -150,8 +150,11 @@ pub async fn migrate(
150
150
server_name,
151
151
// We oversize the hashmaps, as the estimates are innaccurate, and we would like to avoid
152
152
// reallocations.
153
- users : HashMap :: with_capacity ( counts. users * 9 / 8 ) ,
154
- devices_to_compat_sessions : HashMap :: with_capacity ( counts. devices * 9 / 8 ) ,
153
+ users : HashMap :: with_capacity_and_hasher ( counts. users * 9 / 8 , RandomState :: default ( ) ) ,
154
+ devices_to_compat_sessions : HashMap :: with_capacity_and_hasher (
155
+ counts. devices * 9 / 8 ,
156
+ RandomState :: default ( ) ,
157
+ ) ,
155
158
provider_id_mapping,
156
159
} ;
157
160
0 commit comments