[ https://issues.apache.org/jira/browse/BEAM-8872?focusedWorklogId=422395&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-422395 ]
ASF GitHub Bot logged work on BEAM-8872: ---------------------------------------- Author: ASF GitHub Bot Created on: 14/Apr/20 22:32 Start Date: 14/Apr/20 22:32 Worklog Time Spent: 10m Work Description: lukecwik commented on pull request #11418: [BEAM-8872] Support split at fraction for OffsetRangeTracker URL: https://github.com/apache/beam/pull/11418#discussion_r408473271 ########## File path: sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/splittabledofn/OffsetRangeTracker.java ########## @@ -49,13 +50,22 @@ public OffsetRange currentRestriction() { @Override public SplitResult<OffsetRange> trySplit(double fractionOfRemainder) { - // TODO(BEAM-8872): Add support for splitting off a fixed amount of work for this restriction - // instead of only supporting checkpointing. - - checkState( - lastClaimedOffset != null, "Can't checkpoint before any offset was successfully claimed"); - OffsetRange res = new OffsetRange(lastClaimedOffset + 1, range.getTo()); - this.range = new OffsetRange(range.getFrom(), lastClaimedOffset + 1); + checkState(lastClaimedOffset != null, "Can't split before any offset was successfully claimed"); + // No more split should be performed if checkpoint has happened. + if (checkpointed) { + return null; + } + Long splitPos = + lastClaimedOffset + + Math.max(1L, (long) ((range.getTo() - lastClaimedOffset) * fractionOfRemainder)); + if (splitPos >= range.getTo()) { + return null; + } + if (fractionOfRemainder == 0.0) { + checkpointed = true; Review comment: Why do we need `checkpointed`? Shouldn't the range restriction change so that `to` becomes `lastClaimed` (or `from` if nothing has been claimed)? ---------------------------------------------------------------- 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 422395) Time Spent: 0.5h (was: 20m) > Add support for splitting at fractions > 0 to > org.apache.beam.sdk.transforms.splittabledofn.OffsetRangeTracker > -------------------------------------------------------------------------------------------------------------- > > Key: BEAM-8872 > URL: https://issues.apache.org/jira/browse/BEAM-8872 > Project: Beam > Issue Type: Sub-task > Components: sdk-java-core > Reporter: Luke Cwik > Assignee: Boyuan Zhang > Priority: Major > Time Spent: 0.5h > Remaining Estimate: 0h > > org.apache.beam.sdk.transforms.splittabledofn.OffsetRangeTracker only > supports checkpointing. -- This message was sent by Atlassian Jira (v8.3.4#803005)