dhruvarya-db commented on code in PR #3260:
URL: https://github.com/apache/iceberg-rust/pull/3260#discussion_r4087987395
##########
crates/iceberg/src/util/snapshot.rs:
##########
@@ -76,6 +77,28 @@ pub fn ancestors_between(
})
}
+/// Resolve the snapshot ID from the latest main-history entry at or before
+/// `timestamp_ms` (milliseconds since the Unix epoch).
+///
+/// Equal timestamps select the first entry. Returns [`ErrorKind::DataInvalid`]
+/// if no matching history exists; does not check whether the snapshot is
retained.
+pub fn snapshot_id_as_of_time(metadata: &TableMetadata, timestamp_ms: i64) ->
Result<i64> {
+ let mut best: Option<&SnapshotLog> = None;
+ for entry in metadata.history() {
+ if entry.timestamp_ms() <= timestamp_ms
Review Comment:
The suggestion looks much cleaner. Updated!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]