[ 
https://issues.apache.org/jira/browse/BEAM-9977?focusedWorklogId=435736&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-435736
 ]

ASF GitHub Bot logged work on BEAM-9977:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/May/20 22:28
            Start Date: 20/May/20 22:28
    Worklog Time Spent: 10m 
      Work Description: boyuanzz commented on a change in pull request #11715:
URL: https://github.com/apache/beam/pull/11715#discussion_r428343813



##########
File path: 
sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/splittabledofn/OffsetRangeTracker.java
##########
@@ -120,13 +136,27 @@ public String toString() {
   public Progress getProgress() {
     // If we have never attempted an offset, we return the length of the 
entire range as work
     // remaining.
+    // Convert to BigDecimal in computation to prevent overflow, which may 
result in loss of
+    // precision.
     if (lastAttemptedOffset == null) {
-      return Progress.from(0, range.getTo() - range.getFrom());
+      return Progress.from(
+          0,
+          BigDecimal.valueOf(range.getTo())
+              .subtract(BigDecimal.valueOf(range.getFrom()), 
MathContext.DECIMAL128)
+              .doubleValue());
     }
 
     // Compute the amount of work remaining from where we are to where we are 
attempting to get to
     // with a minimum of zero in case we have claimed beyond the end of the 
range.
-    long workRemaining = Math.max(range.getTo() - lastAttemptedOffset, 0);
-    return Progress.from(range.getTo() - range.getFrom() - workRemaining, 
workRemaining);
+    BigDecimal workRemaining =
+        BigDecimal.valueOf(range.getTo())
+            .subtract(BigDecimal.valueOf(lastAttemptedOffset), 
MathContext.DECIMAL128)
+            .max(BigDecimal.ZERO);
+    BigDecimal wholeWork =

Review comment:
       Done. Thanks!




----------------------------------------------------------------
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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 435736)
    Time Spent: 3h 40m  (was: 3.5h)

> Build Kafka Read on top of Java SplittableDoFn
> ----------------------------------------------
>
>                 Key: BEAM-9977
>                 URL: https://issues.apache.org/jira/browse/BEAM-9977
>             Project: Beam
>          Issue Type: New Feature
>          Components: io-java-kafka
>            Reporter: Boyuan Zhang
>            Assignee: Boyuan Zhang
>            Priority: P2
>          Time Spent: 3h 40m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to