You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/04/17 21:19:54 UTC

[GitHub] [beam] boyuanzz opened a new pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker

boyuanzz opened a new pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker
URL: https://github.com/apache/beam/pull/11454
 
 
   **Please** add a meaningful description for your change here
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] [**Choose reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and mention them in a comment (`R: @username`).
    - [ ] Format the pull request title like `[BEAM-XXX] Fixes bug in ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/#make-reviewers-job-easier).
   
   Post-Commit Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   
   Lang | SDK | Apex | Dataflow | Flink | Gearpump | Samza | Spark
   --- | --- | --- | --- | --- | --- | --- | ---
   Go | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/) | --- | --- | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/) | --- | --- | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/)
   Java | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Apex/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Apex/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow/lastCompletedBuild/)<br>[![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow_Java11/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow_Java11/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink/lastCompletedBuild/)<br>[![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Batch/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Batch/lastCompletedBuild/)<br>[![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Streaming/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Streaming/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Gearpump/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Gearpump/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark/lastCompletedBuild/)<br>[![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Spark_Batch/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Spark_Batch/lastCompletedBuild/)<br>[![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_SparkStructuredStreaming/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_SparkStructuredStreaming/lastCompletedBuild/)
   Python | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Python2/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Python2/lastCompletedBuild/)<br>[![Build Status](https://builds.apache.org/job/beam_PostCommit_Python35/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Python35/lastCompletedBuild/)<br>[![Build Status](https://builds.apache.org/job/beam_PostCommit_Python36/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Python36/lastCompletedBuild/)<br>[![Build Status](https://builds.apache.org/job/beam_PostCommit_Python37/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Python37/lastCompletedBuild/) | --- | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Py_VR_Dataflow/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Py_VR_Dataflow/lastCompletedBuild/)<br>[![Build Status](https://builds.apache.org/job/beam_PostCommit_Py_VR_Dataflow_V2/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Py_VR_Dataflow_V2/lastCompletedBuild/)<br>[![Build Status](https://builds.apache.org/job/beam_PostCommit_Py_ValCont/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Py_ValCont/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PreCommit_Python2_PVR_Flink_Cron/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PreCommit_Python2_PVR_Flink_Cron/lastCompletedBuild/)<br>[![Build Status](https://builds.apache.org/job/beam_PostCommit_Python35_VR_Flink/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Python35_VR_Flink/lastCompletedBuild/) | --- | --- | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Python_VR_Spark/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Python_VR_Spark/lastCompletedBuild/)
   XLang | --- | --- | --- | [![Build Status](https://builds.apache.org/job/beam_PostCommit_XVR_Flink/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_XVR_Flink/lastCompletedBuild/) | --- | --- | [![Build Status](https://builds.apache.org/job/beam_PostCommit_XVR_Spark/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_XVR_Spark/lastCompletedBuild/)
   
   Pre-Commit Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   
   --- |Java | Python | Go | Website
   --- | --- | --- | --- | ---
   Non-portable | [![Build Status](https://builds.apache.org/job/beam_PreCommit_Java_Cron/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PreCommit_Java_Cron/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PreCommit_Python_Cron/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PreCommit_Python_Cron/lastCompletedBuild/)<br>[![Build Status](https://builds.apache.org/job/beam_PreCommit_PythonLint_Cron/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PreCommit_PythonLint_Cron/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PreCommit_Go_Cron/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PreCommit_Go_Cron/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PreCommit_Website_Cron/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PreCommit_Website_Cron/lastCompletedBuild/) 
   Portable | --- | [![Build Status](https://builds.apache.org/job/beam_PreCommit_Portable_Python_Cron/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PreCommit_Portable_Python_Cron/lastCompletedBuild/) | --- | ---
   
   See [.test-infra/jenkins/README](https://github.com/apache/beam/blob/master/.test-infra/jenkins/README.md) for trigger phrase, status and link of all Jenkins jobs.
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [beam] iemejia commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker

Posted by GitBox <gi...@apache.org>.
iemejia commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker
URL: https://github.com/apache/beam/pull/11454#discussion_r410662863
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/splittabledofn/ByteKeyRangeTracker.java
 ##########
 @@ -64,31 +64,38 @@ public ByteKeyRange currentRestriction() {
 
   @Override
   public SplitResult<ByteKeyRange> trySplit(double fractionOfRemainder) {
-    // TODO(BEAM-8871): Add support for splitting off a fixed amount of work for this restriction
-    // instead of only supporting checkpointing.
-
-    // If we haven't done any work, we should return the original range we were processing
-    // as the checkpoint.
-    if (lastAttemptedKey == null) {
-      ByteKeyRange rval = range;
-      // We update our current range to an interval that contains no elements.
-      range = NO_KEYS;
-      return SplitResult.of(range, rval);
+    // No split on an empty range.
+    if (NO_KEYS.equals(range)) {
+      return null;
 
 Review comment:
   I am ok with `null` but couldn't we have modelled this with something more type friendly like `UnsplittableResult` a la Optional type?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [beam] lukecwik commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker

Posted by GitBox <gi...@apache.org>.
lukecwik commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker
URL: https://github.com/apache/beam/pull/11454#discussion_r410487283
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/splittabledofn/ByteKeyRangeTracker.java
 ##########
 @@ -64,31 +64,38 @@ public ByteKeyRange currentRestriction() {
 
   @Override
   public SplitResult<ByteKeyRange> trySplit(double fractionOfRemainder) {
-    // TODO(BEAM-8871): Add support for splitting off a fixed amount of work for this restriction
-    // instead of only supporting checkpointing.
-
-    // If we haven't done any work, we should return the original range we were processing
-    // as the checkpoint.
-    if (lastAttemptedKey == null) {
-      ByteKeyRange rval = range;
-      // We update our current range to an interval that contains no elements.
-      range = NO_KEYS;
-      return SplitResult.of(range, rval);
+    // No split on an empty range.
+    if (NO_KEYS.equals(range)) {
+      return null;
 
 Review comment:
   It should be in the parent class.
   
   @robertwb was going to take a look at fixing up the docs and method signatures to ensure that null, None, nil were allowed and what they meant under certain scenarios.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [beam] lukecwik commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker

Posted by GitBox <gi...@apache.org>.
lukecwik commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker
URL: https://github.com/apache/beam/pull/11454#discussion_r410592039
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/splittabledofn/RestrictionTracker.java
 ##########
 @@ -29,7 +30,7 @@
 public abstract class RestrictionTracker<RestrictionT, PositionT> {
   /**
    * Attempts to claim the block of work in the current restriction identified by the given
-   * position.
+   * position. Each claimed position should be a valid split point.
 
 Review comment:
   ```suggestion
      * position. Each claimed position MUST be a valid split point.
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [beam] lukecwik commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker

Posted by GitBox <gi...@apache.org>.
lukecwik commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker
URL: https://github.com/apache/beam/pull/11454#discussion_r410593566
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/splittabledofn/RestrictionTracker.java
 ##########
 @@ -80,6 +81,7 @@
    *     represent based upon the current known remaining amount of work.
    * @return a {@link SplitResult} if a split was possible, otherwise returns {@code null}.
 
 Review comment:
   We should make it clear that a checkpoint must return a valid split result or null where null represents that there is no residual.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [beam] lukecwik commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker

Posted by GitBox <gi...@apache.org>.
lukecwik commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker
URL: https://github.com/apache/beam/pull/11454#discussion_r410594056
 
 

 ##########
 File path: sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/splittabledofn/ByteKeyRangeTrackerTest.java
 ##########
 @@ -287,4 +318,30 @@ public void testBacklogPartiallyCompleted() {
     tracker.tryClaim(ByteKey.of(0xa0));
     assertThat(tracker.getSize(), allOf(greaterThan(0.), lessThan(1.)));
   }
+
+  /** Asserts the two ByteKey are equal except trailing zeros. */
+  private static void assertByteKeyEqualExceptPadding(ByteKey expected, ByteKey key) {
 
 Review comment:
   Make that method public and call it from this test since they are both in the same module.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [beam] boyuanzz commented on issue #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker

Posted by GitBox <gi...@apache.org>.
boyuanzz commented on issue #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker
URL: https://github.com/apache/beam/pull/11454#issuecomment-615517720
 
 
   Run Java PreCommit

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [beam] lukecwik commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker

Posted by GitBox <gi...@apache.org>.
lukecwik commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker
URL: https://github.com/apache/beam/pull/11454#discussion_r410594313
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/splittabledofn/ByteKeyRangeTracker.java
 ##########
 @@ -64,31 +64,38 @@ public ByteKeyRange currentRestriction() {
 
   @Override
   public SplitResult<ByteKeyRange> trySplit(double fractionOfRemainder) {
-    // TODO(BEAM-8871): Add support for splitting off a fixed amount of work for this restriction
-    // instead of only supporting checkpointing.
-
-    // If we haven't done any work, we should return the original range we were processing
-    // as the checkpoint.
-    if (lastAttemptedKey == null) {
-      ByteKeyRange rval = range;
-      // We update our current range to an interval that contains no elements.
-      range = NO_KEYS;
-      return SplitResult.of(range, rval);
+    // No split on an empty range.
+    if (NO_KEYS.equals(range)) {
+      return null;
 
 Review comment:
   That works for me.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [beam] boyuanzz commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker

Posted by GitBox <gi...@apache.org>.
boyuanzz commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker
URL: https://github.com/apache/beam/pull/11454#discussion_r410476018
 
 

 ##########
 File path: sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/splittabledofn/ByteKeyRangeTrackerTest.java
 ##########
 @@ -287,4 +318,30 @@ public void testBacklogPartiallyCompleted() {
     tracker.tryClaim(ByteKey.of(0xa0));
     assertThat(tracker.getSize(), allOf(greaterThan(0.), lessThan(1.)));
   }
+
+  /** Asserts the two ByteKey are equal except trailing zeros. */
+  private static void assertByteKeyEqualExceptPadding(ByteKey expected, ByteKey key) {
 
 Review comment:
   This is taken from https://github.com/apache/beam/blob/master/sdks/java/core/src/test/java/org/apache/beam/sdk/io/range/ByteKeyRangeTest.java#L365-L382

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [beam] iemejia commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker

Posted by GitBox <gi...@apache.org>.
iemejia commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker
URL: https://github.com/apache/beam/pull/11454#discussion_r410479854
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/splittabledofn/ByteKeyRangeTracker.java
 ##########
 @@ -64,31 +64,38 @@ public ByteKeyRange currentRestriction() {
 
   @Override
   public SplitResult<ByteKeyRange> trySplit(double fractionOfRemainder) {
-    // TODO(BEAM-8871): Add support for splitting off a fixed amount of work for this restriction
-    // instead of only supporting checkpointing.
-
-    // If we haven't done any work, we should return the original range we were processing
-    // as the checkpoint.
-    if (lastAttemptedKey == null) {
-      ByteKeyRange rval = range;
-      // We update our current range to an interval that contains no elements.
-      range = NO_KEYS;
-      return SplitResult.of(range, rval);
+    // No split on an empty range.
+    if (NO_KEYS.equals(range)) {
+      return null;
 
 Review comment:
   Should this method then be `@Nullable`  and/or in the parent class?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [beam] boyuanzz commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker

Posted by GitBox <gi...@apache.org>.
boyuanzz commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker
URL: https://github.com/apache/beam/pull/11454#discussion_r410493070
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/splittabledofn/ByteKeyRangeTracker.java
 ##########
 @@ -64,31 +64,38 @@ public ByteKeyRange currentRestriction() {
 
   @Override
   public SplitResult<ByteKeyRange> trySplit(double fractionOfRemainder) {
-    // TODO(BEAM-8871): Add support for splitting off a fixed amount of work for this restriction
-    // instead of only supporting checkpointing.
-
-    // If we haven't done any work, we should return the original range we were processing
-    // as the checkpoint.
-    if (lastAttemptedKey == null) {
-      ByteKeyRange rval = range;
-      // We update our current range to an interval that contains no elements.
-      range = NO_KEYS;
-      return SplitResult.of(range, rval);
+    // No split on an empty range.
+    if (NO_KEYS.equals(range)) {
+      return null;
 
 Review comment:
   I can update  java `RestrictionTracker` within this PR if that's preferable.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [beam] iemejia commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker

Posted by GitBox <gi...@apache.org>.
iemejia commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker
URL: https://github.com/apache/beam/pull/11454#discussion_r410480834
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/io/range/ByteKeyRange.java
 ##########
 @@ -218,6 +218,10 @@ public double estimateFractionForKey(ByteKey key) {
   public ByteKey interpolateKey(double fraction) {
     checkArgument(
         fraction >= 0.0 && fraction < 1.0, "Fraction %s must be in the range [0, 1)", fraction);
+    // Return starKey when fraction is 0 in order to avoid adding trailing zeros during computation.
 
 Review comment:
   s/starKey/startKey

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [beam] iemejia commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker

Posted by GitBox <gi...@apache.org>.
iemejia commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker
URL: https://github.com/apache/beam/pull/11454#discussion_r410662863
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/splittabledofn/ByteKeyRangeTracker.java
 ##########
 @@ -64,31 +64,38 @@ public ByteKeyRange currentRestriction() {
 
   @Override
   public SplitResult<ByteKeyRange> trySplit(double fractionOfRemainder) {
-    // TODO(BEAM-8871): Add support for splitting off a fixed amount of work for this restriction
-    // instead of only supporting checkpointing.
-
-    // If we haven't done any work, we should return the original range we were processing
-    // as the checkpoint.
-    if (lastAttemptedKey == null) {
-      ByteKeyRange rval = range;
-      // We update our current range to an interval that contains no elements.
-      range = NO_KEYS;
-      return SplitResult.of(range, rval);
+    // No split on an empty range.
+    if (NO_KEYS.equals(range)) {
+      return null;
 
 Review comment:
   I am ok with `null` but couldn't we have modelled this with something Option type friendly like `UnsplittableResult` maybe with a `isSplittable()` method to resolve the case difference?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [beam] iemejia commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker

Posted by GitBox <gi...@apache.org>.
iemejia commented on a change in pull request #11454: [BEAM-8871] Support trySplit for ByteKeyRangeTracker
URL: https://github.com/apache/beam/pull/11454#discussion_r410662863
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/splittabledofn/ByteKeyRangeTracker.java
 ##########
 @@ -64,31 +64,38 @@ public ByteKeyRange currentRestriction() {
 
   @Override
   public SplitResult<ByteKeyRange> trySplit(double fractionOfRemainder) {
-    // TODO(BEAM-8871): Add support for splitting off a fixed amount of work for this restriction
-    // instead of only supporting checkpointing.
-
-    // If we haven't done any work, we should return the original range we were processing
-    // as the checkpoint.
-    if (lastAttemptedKey == null) {
-      ByteKeyRange rval = range;
-      // We update our current range to an interval that contains no elements.
-      range = NO_KEYS;
-      return SplitResult.of(range, rval);
+    // No split on an empty range.
+    if (NO_KEYS.equals(range)) {
+      return null;
 
 Review comment:
   I am ok with `null` but couldn't we have modelled this with something more type friendly like `UnsplittableResult`

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services