kylin-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KYLIN-3398) Inaccurate arithmetic operation in LookupTableToHFileJob#calculateShardNum
Date Sun, 10 Jun 2018 07:09:00 GMT

    [ https://issues.apache.org/jira/browse/KYLIN-3398?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16507288#comment-16507288
] 

ASF GitHub Bot commented on KYLIN-3398:
---------------------------------------

shaofengshi closed pull request #152: KYLIN-3398 Fix inaccurate arithmetic operations
URL: https://github.com/apache/kylin/pull/152
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/lookup/LookupTableToHFileJob.java
b/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/lookup/LookupTableToHFileJob.java
index 39ebe996a6..054e1466b6 100644
--- a/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/lookup/LookupTableToHFileJob.java
+++ b/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/lookup/LookupTableToHFileJob.java
@@ -233,8 +233,8 @@ private void removeSnapshotIfExist(ExtTableSnapshotInfoManager extSnapshotInfoMa
     }
 
     private int calculateShardNum(KylinConfig kylinConfig, long dataSize) {
-        long shardSize = kylinConfig.getExtTableSnapshotShardingMB() * 1024 * 1024;
-        return dataSize < shardSize ? 1 : (int) (Math.ceil(dataSize / shardSize));
+        long shardSize = (long) (kylinConfig.getExtTableSnapshotShardingMB()) * 1024 * 1024;
+        return dataSize < shardSize ? 1 : (int) (Math.ceil((double) dataSize / shardSize));
     }
 
     private byte[][] getSplitsByShardNum(int shardNum) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


> Inaccurate arithmetic operation in LookupTableToHFileJob#calculateShardNum
> --------------------------------------------------------------------------
>
>                 Key: KYLIN-3398
>                 URL: https://issues.apache.org/jira/browse/KYLIN-3398
>             Project: Kylin
>          Issue Type: Bug
>            Reporter: Ted Yu
>            Assignee: jiatao.tao
>            Priority: Major
>
> There're two issues with the following code:
> {code}
>     private int calculateShardNum(KylinConfig kylinConfig, long dataSize) {
>         long shardSize = kylinConfig.getExtTableSnapshotShardingMB() * 1024 * 1024;
>         return dataSize < shardSize ? 1 : (int) (Math.ceil(dataSize / shardSize));
> {code}
> getExtTableSnapshotShardingMB returns an int. The multiplication is done using 32-bit
arithmetic, and then used in a context that expects an expression of type "long".
> Second, Math.ceil expects a double. The integer division would lose some precision.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message