brishi19791 commented on code in PR #665:
URL: https://github.com/apache/incubator-xtable/pull/665#discussion_r1989661470
##########
xtable-core/src/main/java/org/apache/xtable/iceberg/IcebergConversionSource.java:
##########
@@ -246,31 +246,23 @@ public CommitsBacklog<Snapshot>
getCommitsBacklog(InstantsForIncrementalSync las
public boolean isIncrementalSyncSafeFrom(Instant instant) {
long timeInMillis = instant.toEpochMilli();
Table iceTable = getSourceTable();
- boolean doesInstantOfAgeExists = false;
- Long targetSnapshotId = null;
- for (Snapshot snapshot : iceTable.snapshots()) {
- if (snapshot.timestampMillis() <= timeInMillis) {
- doesInstantOfAgeExists = true;
- targetSnapshotId = snapshot.snapshotId();
- } else {
- break;
+ Snapshot currentSnapshot = iceTable.currentSnapshot();
+
+ while (currentSnapshot != null && currentSnapshot.timestampMillis() >
timeInMillis) {
+ Long parentSnapshotId = currentSnapshot.parentId();
+ if (parentSnapshotId == null) {
+ // no more snapshots in the chain and did not find targetSnapshot
+ return false;
}
- }
- if (!doesInstantOfAgeExists) {
- return false;
- }
- // Go from latest snapshot until targetSnapshotId through parent reference.
- // nothing has to be null in this chain to guarantee safety of incremental
sync.
- Long currentSnapshotId = iceTable.currentSnapshot().snapshotId();
- while (currentSnapshotId != null && currentSnapshotId != targetSnapshotId)
{
- Snapshot currentSnapshot = iceTable.snapshot(currentSnapshotId);
- if (currentSnapshot == null) {
- // The snapshot is expired.
+
+ Snapshot parentSnapshot = iceTable.snapshot(parentSnapshotId);
+ if (parentSnapshot == null) {
+ // chain is broken due to expired snapshot
Review Comment:
@ashvina yes, it would be helpful for debugging. done
--
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]