Skip to content

Commit 77c7f93

Browse files
committed
address comments
1 parent 563a6d2 commit 77c7f93

File tree

2 files changed

+31
-58
lines changed

2 files changed

+31
-58
lines changed

kernel/src/log_reader/manifest.rs renamed to kernel/src/log_reader/checkpoint_manifest.rs

Lines changed: 30 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ pub(crate) struct CheckpointManifestReader {
2525
manifest_file: FileMeta,
2626
}
2727

28-
/// Possible transitions after CheckpointManifestReader completes.
29-
#[allow(unused)]
30-
pub(crate) enum AfterManifest {
31-
/// Sidecars extracted from the manifest phase
32-
Sidecars(Vec<FileMeta>),
33-
/// No sidecars
34-
Done,
35-
}
36-
3728
impl CheckpointManifestReader {
3829
/// Create a new manifest phase for a single-part checkpoint.
3930
///
@@ -86,17 +77,14 @@ impl CheckpointManifestReader {
8677
})
8778
}
8879

89-
/// Transition to the next phase.
90-
///
91-
/// Returns an enum indicating what comes next:
92-
/// - `Sidecars`: Extracted sidecar files
93-
/// - `Done`: No sidecars found
80+
/// Extract the sidecars from the manifest file if there were any.
81+
/// NOTE: The iterator must be completely exhausted before calling this
9482
#[allow(unused)]
95-
pub(crate) fn finalize(self) -> DeltaResult<AfterManifest> {
83+
pub(crate) fn extract_sidecars(self) -> DeltaResult<Vec<FileMeta>> {
9684
require!(
9785
self.is_complete,
9886
Error::generic(format!(
99-
"Cannot finalize in-progress ManifestReader for file: {}",
87+
"Cannot extract sidecars from in-progress ManifestReader for file: {}",
10088
self.manifest_file.location
10189
))
10290
);
@@ -108,11 +96,7 @@ impl CheckpointManifestReader {
10896
.map(|s| s.to_filemeta(&self.log_root))
10997
.try_collect()?;
11098

111-
if sidecars.is_empty() {
112-
Ok(AfterManifest::Done)
113-
} else {
114-
Ok(AfterManifest::Sidecars(sidecars))
115-
}
99+
Ok(sidecars)
116100
}
117101
}
118102

@@ -195,41 +179,30 @@ mod tests {
195179
);
196180

197181
// Check sidecars
198-
let next = manifest_phase.finalize()?;
182+
let actual_sidecars = manifest_phase.extract_sidecars()?;
199183

200-
match (next, expected_sidecars) {
201-
(AfterManifest::Sidecars(sidecars), []) => {
202-
panic!("Expected to be Done, but found Sidecars: {:?}", sidecars)
203-
}
204-
(AfterManifest::Done, []) => { /* Empty expected sidecars is Done */ }
205-
(AfterManifest::Done, sidecars) => {
206-
panic!("Expected manifest phase to be Done, but got {:?}", sidecars)
207-
}
208-
(AfterManifest::Sidecars(sidecars), expected_sidecars) => {
209-
assert_eq!(
210-
sidecars.len(),
211-
expected_sidecars.len(),
212-
"Should collect exactly {} sidecars",
213-
expected_sidecars.len()
214-
);
215-
216-
// Extract and verify the sidecar paths
217-
let mut collected_paths: Vec<String> = sidecars
218-
.iter()
219-
.map(|fm| {
220-
fm.location
221-
.path_segments()
222-
.and_then(|mut segments| segments.next_back())
223-
.unwrap_or("")
224-
.to_string()
225-
})
226-
.collect();
227-
228-
collected_paths.sort();
229-
// Verify they're the expected sidecar files
230-
assert_eq!(collected_paths, expected_sidecars.to_vec());
231-
}
232-
}
184+
assert_eq!(
185+
actual_sidecars.len(),
186+
expected_sidecars.len(),
187+
"Should collect exactly {} actual_sidecars",
188+
expected_sidecars.len()
189+
);
190+
191+
// Extract and verify the sidecar paths
192+
let mut collected_paths: Vec<String> = actual_sidecars
193+
.iter()
194+
.map(|fm| {
195+
fm.location
196+
.path_segments()
197+
.and_then(|mut segments| segments.next_back())
198+
.unwrap_or("")
199+
.to_string()
200+
})
201+
.collect();
202+
203+
collected_paths.sort();
204+
// Verify they're the expected sidecar files
205+
assert_eq!(collected_paths, expected_sidecars.to_vec());
233206

234207
Ok(())
235208
}
@@ -276,10 +249,10 @@ mod tests {
276249
engine.clone(),
277250
)?;
278251

279-
let result = manifest_phase.finalize();
252+
let result = manifest_phase.extract_sidecars();
280253
assert_result_error_with_message(
281254
result,
282-
"Cannot finalize in-progress ManifestReader for file",
255+
"Cannot extract sidecars from in-progress ManifestReader for file",
283256
);
284257
Ok(())
285258
}

kernel/src/log_reader/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1+
pub(crate) mod checkpoint_manifest;
12
pub(crate) mod commit;
2-
pub(crate) mod manifest;

0 commit comments

Comments
 (0)