@@ -129,16 +129,6 @@ impl Snapshot {
129129 SnapshotBuilder :: new_from ( existing_snapshot)
130130 }
131131
132- /// Create a new [`Snapshot`] from a [`LogSegment`] and [`TableConfiguration`].
133- #[ internal_api]
134- pub ( crate ) fn new ( log_segment : LogSegment , table_configuration : TableConfiguration ) -> Self {
135- Self :: new_with_crc (
136- log_segment,
137- table_configuration,
138- Arc :: new ( LazyCrc :: new ( None ) ) ,
139- )
140- }
141-
142132 /// Internal constructor that accepts an explicit [`LazyCrc`].
143133 pub ( crate ) fn new_with_crc (
144134 log_segment : LogSegment ,
@@ -400,15 +390,11 @@ impl Snapshot {
400390 /// producing a post-commit snapshot without a full log replay from storage.
401391 ///
402392 /// The `crc_delta` captures the CRC-relevant changes from the committed transaction
403- /// (file stats, domain metadata, ICT, etc.). If the pre-commit snapshot had a loaded CRC
404- /// at its version, the delta is applied to produce a precomputed in-memory CRC for the new
405- /// version -- this CRC contains all important table metadata (protocol, metadata, domain
406- /// metadata, set transactions, ICT) and avoids re-reading them from storage. CREATE TABLE
407- /// always produces a CRC at v0. If no CRC was available on the pre-commit snapshot, the
408- /// existing lazy CRC is carried forward unchanged.
409- ///
410- /// TODO: Handle Protocol changes in CrcDelta (when Kernel-RS supports protocol changes)
411- /// TODO: Handle Metadata changes in CrcDelta (when Kernel-RS supports metadata changes)
393+ /// (file stats, domain metadata, ICT, etc.). If this snapshot had a loaded CRC at its
394+ /// version, the delta is applied to produce a precomputed in-memory CRC for the new
395+ /// version -- this avoids re-reading metadata from storage. If no CRC was available, the
396+ /// existing lazy CRC is carried forward unchanged. CREATE TABLE handles CRC construction
397+ /// separately in `Transaction::into_committed`.
412398 pub ( crate ) fn new_post_commit (
413399 & self ,
414400 commit : ParsedLogPath ,
@@ -432,8 +418,12 @@ impl Snapshot {
432418 ) )
433419 ) ;
434420
435- let new_table_configuration =
436- TableConfiguration :: new_post_commit ( self . table_configuration ( ) , new_version) ;
421+ let new_table_configuration = TableConfiguration :: new_post_commit (
422+ self . table_configuration ( ) ,
423+ new_version,
424+ crc_delta. metadata . clone ( ) ,
425+ crc_delta. protocol . clone ( ) ,
426+ ) ?;
437427
438428 let new_log_segment = self . log_segment . new_with_commit_appended ( commit) ?;
439429
@@ -448,21 +438,18 @@ impl Snapshot {
448438
449439 /// Compute the lazy CRC for a post-commit snapshot by applying a [`CrcDelta`].
450440 ///
451- /// For CREATE TABLE, builds a fresh CRC from the `crc_delta`. For existing tables, applies
452- /// the `crc_delta` to the current CRC if loaded, otherwise carries forward the existing lazy
453- /// CRC .
441+ /// Applies the `crc_delta` to the current CRC if loaded, otherwise carries forward the
442+ /// existing lazy CRC. Not used by CREATE TABLE, which builds its CRC from scratch via
443+ /// `CrcDelta::into_crc_for_version_zero` in `Transaction::into_committed` .
454444 fn compute_post_commit_crc ( & self , new_version : Version , crc_delta : CrcDelta ) -> Arc < LazyCrc > {
455- let crc = if self . version ( ) == crate :: PRE_COMMIT_VERSION {
456- crc_delta. into_crc_for_version_zero ( )
457- } else {
458- self . lazy_crc
459- . get_if_loaded_at_version ( self . version ( ) )
460- . map ( |base| {
461- let mut crc = base. as_ref ( ) . clone ( ) ;
462- crc. apply ( crc_delta) ;
463- crc
464- } )
465- } ;
445+ let crc = self
446+ . lazy_crc
447+ . get_if_loaded_at_version ( self . version ( ) )
448+ . map ( |base| {
449+ let mut crc = base. as_ref ( ) . clone ( ) ;
450+ crc. apply ( crc_delta) ;
451+ crc
452+ } ) ;
466453
467454 match crc {
468455 Some ( c) => Arc :: new ( LazyCrc :: new_precomputed ( c, new_version) ) ,
@@ -1297,7 +1284,11 @@ mod tests {
12971284 let log_segment =
12981285 LogSegment :: try_new ( listed_files, url. join ( "_delta_log/" ) ?, Some ( 0 ) , None ) ?;
12991286
1300- Ok ( Snapshot :: new ( log_segment, table_cfg) )
1287+ Ok ( Snapshot :: new_with_crc (
1288+ log_segment,
1289+ table_cfg,
1290+ Arc :: new ( LazyCrc :: new ( None ) ) ,
1291+ ) )
13011292 }
13021293
13031294 #[ test]
0 commit comments