You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by zh...@apache.org on 2016/02/17 09:11:25 UTC

kylin git commit: KYLIN-1423 fix HBase size precision issue

Repository: kylin
Updated Branches:
  refs/heads/2.x-staging d3c9bd86f -> fedd47e3c


KYLIN-1423 fix HBase size precision issue


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/fedd47e3
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/fedd47e3
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/fedd47e3

Branch: refs/heads/2.x-staging
Commit: fedd47e3c53702e8d9f06de3e8665a2c3392f041
Parents: d3c9bd8
Author: janzhongi <ji...@ebay.com>
Authored: Wed Feb 17 16:11:27 2016 +0800
Committer: janzhongi <ji...@ebay.com>
Committed: Wed Feb 17 16:11:45 2016 +0800

----------------------------------------------------------------------
 webapp/app/js/filters/filter.js            | 16 ++++++++++++++--
 webapp/app/partials/cubes/cube_detail.html |  4 ++--
 2 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/fedd47e3/webapp/app/js/filters/filter.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/filters/filter.js b/webapp/app/js/filters/filter.js
index 1b0590c..3f1d8d3 100755
--- a/webapp/app/js/filters/filter.js
+++ b/webapp/app/js/filters/filter.js
@@ -83,7 +83,7 @@ KylinApp
   .filter('bytes', function () {
     return function (bytes, precision) {
       if (bytes === 0) {
-        return '0 bytes'
+        return 'N/A'
       }
       ;
       if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) {
@@ -96,7 +96,19 @@ KylinApp
 
       var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
         number = Math.floor(Math.log(bytes) / Math.log(1024));
-      return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
+      switch(number){
+        case 0:
+          precision = 0;
+          break;
+        case 1:
+        case 2:
+          precision = 3;
+          break;
+        default:
+          precision = 5;
+      }
+
+      return Math.round((bytes / Math.pow(1024, Math.floor(number)))*Math.pow(10,precision))/Math.pow(10,precision) + ' ' + units[number];
     }
   }).filter('resizePieHeight', function () {
     return function (item) {

http://git-wip-us.apache.org/repos/asf/kylin/blob/fedd47e3/webapp/app/partials/cubes/cube_detail.html
----------------------------------------------------------------------
diff --git a/webapp/app/partials/cubes/cube_detail.html b/webapp/app/partials/cubes/cube_detail.html
index 32246a8..4997865 100755
--- a/webapp/app/partials/cubes/cube_detail.html
+++ b/webapp/app/partials/cubes/cube_detail.html
@@ -99,14 +99,14 @@
                 <h5><b>HTable:</b> {{table.tableName}}</h5>
                 <ul>
                     <li>Region Count: <span class="red">{{table.regionCount}}</span></li>
-                    <li>Size: <span class="red">{{table.tableSize | bytes:5}}</span></li>
+                    <li>Size: <span class="red">{{table.tableSize | bytes}}</span></li>
                     <li>Start Time: <span class="red">{{table.dateRangeStart | reverseToGMT0}}</span></li>
                     <li>End Time: <span class="red">{{table.dateRangeEnd | reverseToGMT0}}</span></li>
                 </ul>
             </div>
             <div ng-if="cube.hbase">
                 <div class="hr hr8 hr-double hr-dotted"></div>
-                <h5><b>Total Size:</b> <span class="red">{{cube.totalSize | bytes:5}}</span></h5>
+                <h5><b>Total Size:</b> <span class="red">{{cube.totalSize | bytes}}</span></h5>
                 <h5><b>Total Number:</b> <span class="red">{{cube.hbase.length}}</span></h5>
             </div>
             <div ng-if="cube.hbase.length == 0">