Abacn commented on code in PR #41518:
URL: https://github.com/apache/beam/pull/41518#discussion_r4646047178
##########
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:
mtime is expected to be in sync across filepattern as long as live in same
filesystem. Introduce Map is unnecessary and add overhead.
If there is indeed different filesystem, allowedLateness should be used
anyways (for data integrity). Here is just a best effort method for watermark
estimation.
--
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]