Class ReadChangeStreamPartitionRangeTracker

  • All Implemented Interfaces:
    org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.HasProgress

    public class ReadChangeStreamPartitionRangeTracker
    extends TimestampRangeTracker
    This restriction tracker delegates most of its behavior to an internal TimestampRangeTracker. It has a different logic for tryClaim and trySplit methods. It ignores claims for the same timestamp multiple times. This is because several change stream records might have the same timestamp, thus leading to multiple claims of the same Timestamp. Other than that, it always denies splits for the InitialPartition.PARTITION_TOKEN, since we only need to perform this query once.
    • Constructor Detail

      • ReadChangeStreamPartitionRangeTracker

        public ReadChangeStreamPartitionRangeTracker​(PartitionMetadata partition,
                                                     TimestampRange range)
        Receives the partition that will be queried and the timestamp range that belongs to it.
        Parameters:
        partition - the partition that will use the tracker
        range - closed / open range interval for the start / end times of the given partition
    • Method Detail

      • tryClaim

        public boolean tryClaim​(com.google.cloud.Timestamp position)
        Attempts to claim the given position.

        Must be equal or larger than the last successfully claimed position.

        Overrides:
        tryClaim in class TimestampRangeTracker
        Returns:
        true if the position was successfully claimed, false if it is outside the current TimestampRange of this tracker (in that case this operation is a no-op).
      • trySplit

        public @Nullable org.apache.beam.sdk.transforms.splittabledofn.SplitResult<TimestampRange> trySplit​(double fractionOfRemainder)
        If the partition token is the InitialPartition.PARTITION_TOKEN, it does not allow for splits (returns null).

        If a split is successful (non-null), then the restriction is updated to the result of the primary.

        Overrides:
        trySplit in class TimestampRangeTracker
        Returns:
        a SplitResult if a split was possible or null if the splitPosition is beyond the end of the range.