Skip to content

Commit bcc8ff5

Browse files
refactor: ParsedLogPath::try_from to return Option<ParsedLogPath<Location>>
1 parent 98d5ae5 commit bcc8ff5

File tree

5 files changed

+67
-70
lines changed

5 files changed

+67
-70
lines changed

kernel/src/listed_log_files.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,18 @@ fn list_log_files(
9191
// NOTE: since engine APIs don't limit listing, we list from start_version and filter
9292
let files = storage
9393
.list_from(&start_from)?
94-
.map(|meta| ParsedLogPath::try_from(meta?))
94+
.filter_map(|meta| match meta {
95+
Ok(m) => ParsedLogPath::try_from(m)
96+
.filter(|p| p.should_list())
97+
.map(Ok),
98+
Err(e) => Some(Err(e)),
99+
})
95100
// NOTE: this filters out .crc files etc which start with "." - some engines
96101
// produce `.something.parquet.crc` corresponding to `something.parquet`. Kernel
97102
// doesn't care about these files. Critically, note these are _different_ than
98103
// normal `version.crc` files which are listed + captured normally. Additionally
99104
// we likely aren't even 'seeing' these files since lexicographically the string
100105
// "." comes before the string "0".
101-
.filter_map_ok(|path_opt| path_opt.filter(|p| p.should_list()))
102106
.take_while(move |path_res| match path_res {
103107
// discard any path with too-large version; keep errors
104108
Ok(path) => path.version <= list_end_version,

kernel/src/log_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl LogPath {
2525
/// valid log path.
2626
pub fn try_new(file_meta: FileMeta) -> DeltaResult<Self> {
2727
// TODO: we should avoid the clone
28-
let parsed = ParsedLogPath::try_from(file_meta.clone())?
28+
let parsed = ParsedLogPath::try_from(file_meta.clone())
2929
.ok_or_else(|| Error::invalid_log_path(&file_meta.location))?;
3030

3131
require!(

kernel/src/log_segment/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ fn create_log_path(path: &str) -> ParsedLogPath<FileMeta> {
205205
size: 0,
206206
})
207207
.unwrap()
208-
.unwrap()
209208
}
210209

211210
#[test]

0 commit comments

Comments
 (0)