Class ReadChangeStreamPartitionRangeTracker
- java.lang.Object
-
- org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker<TimestampRange,com.google.cloud.Timestamp>
-
- org.apache.beam.sdk.io.gcp.spanner.changestreams.restriction.TimestampRangeTracker
-
- org.apache.beam.sdk.io.gcp.spanner.changestreams.restriction.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 internalTimestampRangeTracker. 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 sameTimestamp. Other than that, it always denies splits for theInitialPartition.PARTITION_TOKEN, since we only need to perform this query once.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker
org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.HasProgress, org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.IsBounded, org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.Progress, org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.TruncateResult<RestrictionT extends java.lang.Object>
-
-
Field Summary
-
Fields inherited from class org.apache.beam.sdk.io.gcp.spanner.changestreams.restriction.TimestampRangeTracker
lastAttemptedPosition, lastClaimedPosition, range, timeSupplier
-
-
Constructor Summary
Constructors Constructor Description ReadChangeStreamPartitionRangeTracker(PartitionMetadata partition, TimestampRange range)Receives the partition that will be queried and the timestamp range that belongs to it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleantryClaim(com.google.cloud.Timestamp position)Attempts to claim the given position.@Nullable org.apache.beam.sdk.transforms.splittabledofn.SplitResult<TimestampRange>trySplit(double fractionOfRemainder)If the partition token is theInitialPartition.PARTITION_TOKEN, it does not allow for splits (returns null).-
Methods inherited from class org.apache.beam.sdk.io.gcp.spanner.changestreams.restriction.TimestampRangeTracker
checkDone, currentRestriction, getProgress, isBounded, setTimeSupplier, tryClaim
-
-
-
-
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 trackerrange- 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:
tryClaimin classTimestampRangeTracker- Returns:
trueif the position was successfully claimed,falseif it is outside the currentTimestampRangeof 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 theInitialPartition.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:
trySplitin classTimestampRangeTracker- Returns:
- a
SplitResultif a split was possible ornullif thesplitPositionis beyond the end of the range.
-
-