JingsongLi commented on code in PR #9437:
URL: https://github.com/apache/paimon/pull/9437#discussion_r3912295256
##########
paimon-core/src/test/java/org/apache/paimon/utils/SnapshotManagerTest.java:
##########
@@ -423,6 +423,64 @@ public void testLaterOrEqualTimeMills() throws IOException
{
assertThat(snapshotManager.laterOrEqualTimeMills(millis +
10001)).isNull();
}
+ @Test
+ public void testEarlierOrEqualTimeMillsWithDuplicateCommitTimes() throws
IOException {
+ long millis = 1684726826L;
+ FileIO localFileIO = LocalFileIO.create();
+ SnapshotManager snapshotManager =
+ newSnapshotManager(localFileIO, new Path(tempDir.toString()));
+ for (long i = 0; i < 3; i++) {
+ Snapshot snapshot = createSnapshotWithMillis(i, millis);
+ localFileIO.tryToWriteAtomic(snapshotManager.snapshotPath(i),
snapshot.toJson());
+ }
+
+
assertThat(snapshotManager.earlierOrEqualTimeMills(millis).id()).isEqualTo(2);
Review Comment:
[P2] Exercise an interior duplicate-timestamp range
These duplicate-time tests give every snapshot the same timestamp, so
`earlierOrEqualTimeMills` returns through the latest-snapshot shortcut and
`laterOrEqualTimeMills` returns through the earliest-snapshot shortcut. Neither
test executes the changed equality branches inside the binary searches. The two
race tests added below also end at those shortcuts. I temporarily restored both
equality branches to the old `break`, while keeping the new boundary logic, and
all four tests introduced by this PR still passed.
Please add a history such as `[t-1, t, t, t, t+1]` and assert that
earlier-or-equal returns the last `t` snapshot while later-or-equal returns the
first one.
--
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]