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 ;
@@ -25,7 +25,7 @@ use ulid::Ulid;
25
25
use uuid:: { NonNilUuid , Uuid } ;
26
26
27
27
use crate :: {
28
- SynapseReader ,
28
+ HashMap , RandomState , SynapseReader ,
29
29
mas_writer:: {
30
30
self , MasNewCompatAccessToken , MasNewCompatRefreshToken , MasNewCompatSession ,
31
31
MasNewEmailThreepid , MasNewUnsupportedThreepid , MasNewUpstreamOauthLink , MasNewUser ,
@@ -114,7 +114,7 @@ struct MigrationState {
114
114
115
115
/// A mapping of Synapse external ID providers to MAS upstream OAuth 2.0
116
116
/// provider ID
117
- provider_id_mapping : HashMap < String , Uuid > ,
117
+ provider_id_mapping : std :: collections :: HashMap < String , Uuid > ,
118
118
}
119
119
120
120
/// Performs a migration from Synapse's database to MAS' database.
@@ -136,16 +136,19 @@ pub async fn migrate(
136
136
server_name : String ,
137
137
clock : & dyn Clock ,
138
138
rng : & mut impl RngCore ,
139
- provider_id_mapping : HashMap < String , Uuid > ,
139
+ provider_id_mapping : std :: collections :: HashMap < String , Uuid > ,
140
140
) -> Result < ( ) , Error > {
141
141
let counts = synapse. count_rows ( ) . await . into_synapse ( "counting users" ) ?;
142
142
143
143
let state = MigrationState {
144
144
server_name,
145
145
// We oversize the hashmaps, as the estimates are innaccurate, and we would like to avoid
146
146
// 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
+ ) ,
149
152
provider_id_mapping,
150
153
} ;
151
154
0 commit comments