|
67 | 67 | if TYPE_CHECKING: |
68 | 68 | from apache_beam.transforms import sideinputs |
69 | 69 | from apache_beam.transforms.core import TimerSpec |
| 70 | + from apache_beam.iobase import WatermarkEstimator |
| 71 | + from apache_beam.iobase import RestrictionTracker |
70 | 72 |
|
71 | 73 |
|
72 | 74 | class NameContext(object): |
@@ -296,6 +298,7 @@ def get_restriction_provider(self): |
296 | 298 | return self.process_method.restriction_provider |
297 | 299 |
|
298 | 300 | def get_watermark_estimator_provider(self): |
| 301 | + # type: () -> WatermarkEstimatorProvider |
299 | 302 | return self.process_method.watermark_estimator_provider |
300 | 303 |
|
301 | 304 | def _validate(self): |
@@ -333,6 +336,7 @@ def is_splittable_dofn(self): |
333 | 336 | return self.get_restriction_provider() is not None |
334 | 337 |
|
335 | 338 | def get_restriction_coder(self): |
| 339 | + # type: () -> Optional[TupleCoder] |
336 | 340 | """Get coder for a restriction when processing an SDF. """ |
337 | 341 | if self.is_splittable_dofn(): |
338 | 342 | restriction_coder = TupleCoder([ |
@@ -437,11 +441,11 @@ def create_invoker( |
437 | 441 | def invoke_process(self, |
438 | 442 | windowed_value, # type: WindowedValue |
439 | 443 | restriction_tracker=None, # type: Optional[RestrictionTracker] |
440 | | - watermark_estimator=None, |
| 444 | + watermark_estimator=None, # type: Optional[WatermarkEstimator] |
441 | 445 | additional_args=None, |
442 | 446 | additional_kwargs=None |
443 | 447 | ): |
444 | | - # type: (...) -> Optional[SplitResultType] |
| 448 | + # type: (...) -> Optional[SplitResultResidual] |
445 | 449 |
|
446 | 450 | """Invokes the DoFn.process() function. |
447 | 451 |
|
@@ -524,7 +528,7 @@ def __init__(self, |
524 | 528 | def invoke_process(self, |
525 | 529 | windowed_value, # type: WindowedValue |
526 | 530 | restriction_tracker=None, # type: Optional[RestrictionTracker] |
527 | | - watermark_estimator=None, |
| 531 | + watermark_estimator=None, # type: Optional[WatermarkEstimator] |
528 | 532 | additional_args=None, |
529 | 533 | additional_kwargs=None |
530 | 534 | ): |
@@ -557,8 +561,8 @@ def __init__(self, |
557 | 561 | signature.is_stateful_dofn()) |
558 | 562 | self.user_state_context = user_state_context |
559 | 563 | self.is_splittable = signature.is_splittable_dofn() |
560 | | - self.threadsafe_restriction_tracker = None |
561 | | - self.threadsafe_watermark_estimator = None |
| 564 | + self.threadsafe_restriction_tracker = None # type: Optional[ThreadsafeRestrictionTracker] |
| 565 | + self.threadsafe_watermark_estimator = None # type: Optional[ThreadsafeWatermarkEstimator] |
562 | 566 | self.current_windowed_value = None # type: Optional[WindowedValue] |
563 | 567 | self.bundle_finalizer_param = bundle_finalizer_param |
564 | 568 | self.is_key_param_required = False |
@@ -640,12 +644,12 @@ def __init__(self, placeholder): |
640 | 644 |
|
641 | 645 | def invoke_process(self, |
642 | 646 | windowed_value, # type: WindowedValue |
643 | | - restriction_tracker=None, |
644 | | - watermark_estimator=None, |
| 647 | + restriction_tracker=None, # type: Optional[RestrictionTracker] |
| 648 | + watermark_estimator=None, # type: Optional[WatermarkEstimator] |
645 | 649 | additional_args=None, |
646 | 650 | additional_kwargs=None |
647 | 651 | ): |
648 | | - # type: (...) -> Optional[SplitResultType] |
| 652 | + # type: (...) -> Optional[SplitResultResidual] |
649 | 653 | if not additional_args: |
650 | 654 | additional_args = [] |
651 | 655 | if not additional_kwargs: |
@@ -790,9 +794,6 @@ def _invoke_process_per_window(self, |
790 | 794 |
|
791 | 795 | if self.is_splittable: |
792 | 796 | assert self.threadsafe_restriction_tracker is not None |
793 | | - # TODO: Consider calling check_done right after SDF.Process() finishing. |
794 | | - # In order to do this, we need to know that current invoking dofn is |
795 | | - # ProcessSizedElementAndRestriction. |
796 | 797 | self.threadsafe_restriction_tracker.check_done() |
797 | 798 | deferred_status = self.threadsafe_restriction_tracker.deferred_status() |
798 | 799 | if deferred_status: |
|
0 commit comments