@@ -99,11 +99,13 @@ where
99
99
unsafe { C :: struct_from_raw ( pointer) }
100
100
}
101
101
102
+ /// Mark the given tracked struct as valid in the current revision.
102
103
pub fn validate < ' db > ( & ' db self , runtime : & ' db Runtime , id : Id ) {
103
104
Self :: validate_in_map ( & self . map , runtime, id)
104
105
}
105
106
106
- pub fn validate_in_map < ' db > (
107
+ /// Internal helper to provide shared functionality for [`StructMapView`].
108
+ fn validate_in_map < ' db > (
107
109
map : & ' db FxDashMap < Id , Alloc < Value < C > > > ,
108
110
runtime : & ' db Runtime ,
109
111
id : Id ,
@@ -209,6 +211,18 @@ where
209
211
unsafe { C :: struct_from_raw ( data. as_raw ( ) ) }
210
212
}
211
213
214
+ /// Lookup an existing tracked struct from the map, maybe validating it to current revision.
215
+ ///
216
+ /// Validates to current revision if the struct was last created/validated in a revision that
217
+ /// is still current for the struct's durability. That is, if the struct is HIGH durability
218
+ /// (created by a HIGH durability query) and was created in R2, and we are now at R3 but no
219
+ /// HIGH durability input has changed since R2, the struct is still valid and we can validate
220
+ /// it to R3.
221
+ ///
222
+ /// # Panics
223
+ ///
224
+ /// * If the value is not present in the map.
225
+ /// * If the value has not been updated in the last-changed revision for its durability.
212
226
fn get_and_validate_last_changed < ' db > (
213
227
map : & ' db FxDashMap < Id , Alloc < Value < C > > > ,
214
228
runtime : & ' db Runtime ,
@@ -217,20 +231,13 @@ where
217
231
let data = map. get ( & id) . unwrap ( ) ;
218
232
219
233
// UNSAFE: We permit `&`-access in the current revision once data.created_at
220
- // has been updated to the current revision (which we check below).
234
+ // has been updated to the current revision (which we ensure below).
221
235
let data_ref: & Value < C > = unsafe { data. as_ref ( ) } ;
222
236
223
- // Before we drop the lock, check that the value has
224
- // been updated in the most recent version in which the query that created it could have
225
- // changed (based on durability), and validate to the current revision if so.
237
+ // Before we drop the lock, check that the value has been updated in the most recent
238
+ // version in which the query that created it could have changed (based on durability).
226
239
let created_at = data_ref. created_at ;
227
240
let last_changed = runtime. last_changed_revision ( data_ref. durability ) ;
228
- dbg ! (
229
- runtime. current_revision( ) ,
230
- created_at,
231
- last_changed,
232
- data_ref. durability
233
- ) ;
234
241
assert ! (
235
242
created_at >= last_changed,
236
243
"access to tracked struct from obsolete revision"
@@ -287,7 +294,15 @@ where
287
294
StructMap :: get_from_map ( & self . map , current_revision, id)
288
295
}
289
296
290
- pub fn get_and_validate_last_changed < ' db > (
297
+ /// Lookup an existing tracked struct from the map, maybe validating it to current revision.
298
+ ///
299
+ /// See [`StructMap::get_and_validate_last_changed`].
300
+ ///
301
+ /// # Panics
302
+ ///
303
+ /// * If the value is not present in the map.
304
+ /// * If the value has not been updated in the last-changed revision for its durability.
305
+ pub ( super ) fn get_and_validate_last_changed < ' db > (
291
306
& ' db self ,
292
307
runtime : & ' db Runtime ,
293
308
id : Id ,
0 commit comments