github-actions[bot] commented on code in PR #41518:
URL: https://github.com/apache/beam/pull/41518#discussion_r4645895107
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileIO.java:
##########
@@ -776,14 +865,92 @@ public void process(ProcessContext c) throws Exception {
}
}
- private static class MatchPollFn extends PollFn<String,
MatchResult.Metadata> {
+ @VisibleForTesting
+ static long ensureLastModifiedMillis(MatchResult.Metadata input) {
+ long timestamp = input.lastModifiedMillis();
+ if (0L == timestamp) {
+ throw new RuntimeException(
+ String.format(
+ "Extract file timestamp failed: got file timestamp == 0 for
%s.",
+ input.resourceId()));
+ }
+ return timestamp;
+ }
+
+ @VisibleForTesting
+ static class MatchPollFn extends PollFn<String, MatchResult.Metadata> {
+ private final @Nullable Duration timestampCursorAllowedLateness;
+
+ // Best-effort watermark tracking (not deduplication, which lives in
Watch's checkpointed
+ // restriction): remembers the greatest last-modified time seen so far
so a poll that
+ // discovers newer files holds the watermark at the filesystem clock,
while a quiet poll
+ // releases it to poll time.
+ private transient @Nullable Instant newestMtime;
Review Comment:
**🟡 Medium**: `MatchPollFn` is used by `FileIO.matchAll()`, which can watch
multiple filepatterns (`PCollection<String>`), each with its own independent
`Watch.Growth` restriction and watermark estimator. Because `newestMtime` is a
single field on `MatchPollFn` rather than tracked per `element` (filepattern),
polling a filepattern with a higher max mtime will cause subsequent polls of
other filepatterns with older mtimes to evaluate `updateNewestMtime(newest)` as
`false` and prematurely advance their watermark to `now`. Consider tracking
`newestMtime` per filepattern (e.g., in a `ConcurrentHashMap<String, Instant>`).
##########
sdks/java/core/src/test/java/org/apache/beam/sdk/io/FileIOTest.java:
##########
@@ -18,12 +18,16 @@
package org.apache.beam.sdk.io;
import static
org.apache.beam.sdk.io.fs.ResolveOptions.StandardResolveOptions.RESOLVE_FILE;
+import static
org.apache.beam.sdk.transforms.display.DisplayDataMatchers.hasDisplayItem;
Review Comment:
**🟠High**: `hasDisplayItem` (along with `not` on line 26, `assertNull` on
line 29, `assertThrows` on line 30, and `DisplayData` on line 81) is unused in
`FileIOTest.java`, which will fail Checkstyle (`UnusedImports`) and Spotless
checks. Please either remove these unused imports or include the unit test
covering `MatchConfiguration.withTimestampCursor` validation and `DisplayData`.
--
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]