lukecwik commented on a change in pull request #11735:
URL: https://github.com/apache/beam/pull/11735#discussion_r426195050
##########
File path: sdks/java/core/src/main/java/org/apache/beam/sdk/io/Read.java
##########
@@ -487,51 +493,54 @@ public void splitRestriction(
@NewTracker
public RestrictionTracker<
- KV<UnboundedSource<OutputT, CheckpointT>, CheckpointT>,
UnboundedSourceValue<OutputT>[]>
+ UnboundedSourceRestriction<OutputT, CheckpointT>,
UnboundedSourceValue<OutputT>[]>
restrictionTracker(
- @Restriction KV<UnboundedSource<OutputT, CheckpointT>,
CheckpointT> restriction,
+ @Restriction UnboundedSourceRestriction<OutputT, CheckpointT>
restriction,
PipelineOptions pipelineOptions) {
return new UnboundedSourceAsSDFRestrictionTracker(restriction,
pipelineOptions);
}
@ProcessElement
public ProcessContinuation processElement(
- RestrictionTracker<
- KV<UnboundedSource<OutputT, CheckpointT>, CheckpointT>,
UnboundedSourceValue[]>
+ RestrictionTracker<UnboundedSourceRestriction<OutputT, CheckpointT>,
UnboundedSourceValue[]>
tracker,
ManualWatermarkEstimator<Instant> watermarkEstimator,
OutputReceiver<ValueWithRecordId<OutputT>> receiver,
BundleFinalizer bundleFinalizer)
throws IOException {
- KV<UnboundedSource<OutputT, CheckpointT>, CheckpointT>
initialRestriction =
+ UnboundedSourceRestriction<OutputT, CheckpointT> initialRestriction =
tracker.currentRestriction();
UnboundedSourceValue<OutputT>[] out = new UnboundedSourceValue[1];
while (tracker.tryClaim(out)) {
receiver.outputWithTimestamp(
new ValueWithRecordId<>(out[0].getValue(), out[0].getId()),
out[0].getTimestamp());
-
watermarkEstimator.setWatermark(ensureTimestampWithinBounds(out[0].getWatermark()));
}
+ UnboundedSourceRestriction<OutputT, CheckpointT> currentRestriction =
+ tracker.currentRestriction();
+
+ // Advance the watermark even if zero elements may have been output.
Review comment:
This is the key part of the change here, moving
`watermarkEstimator.setWatermark` out of the while loop.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]