You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/04/19 05:41:07 UTC

[GitHub] [spark] sarutak commented on a change in pull request #32224: [SPARK-35128][UI] Some columns in table Data Distribution of storage page shows incorrectly when sorted

sarutak commented on a change in pull request #32224:
URL: https://github.com/apache/spark/pull/32224#discussion_r615552503



##########
File path: core/src/main/resources/org/apache/spark/ui/static/sorttable.js
##########
@@ -278,6 +282,19 @@ sorttable = {
     if (isNaN(bb)) bb = 0;
     return aa-bb;
   },
+  sort_storage_size: function(src, dst) {
+    if(src[0].toLowerCase() === dst[0].toLowerCase()) {

Review comment:
       nit: Please insert one whitespace between `if` and `(`.

##########
File path: core/src/main/resources/org/apache/spark/ui/static/sorttable.js
##########
@@ -185,6 +185,10 @@ sorttable = {
         if (text.match(/^-?[£$¤]?[\d,.]+%?$/)) {
           return sorttable.sort_numeric;
         }
+        // match content like '287.1 MiB (17.2 GiB Remaining)', '0.0 B'
+        else if(text.match(/^(\d+(?:\.\d+)?)\s*(b|[k|m|g|t|p|e|z|y]ib)[\s\S]*/i)) {

Review comment:
       `else` keyword should be immediately after `if` block with one whitespace inserted between `}` and `else` like:
   ```
   if ( ... ) {
   } else if ( ... ) {
     ...
   }
   ```
   
   Also, you should insert one whitespace between `if` and `(`.

##########
File path: core/src/main/resources/org/apache/spark/ui/static/sorttable.js
##########
@@ -505,3 +522,28 @@ var forEach = function(object, block, context) {
   }
 };
 
+// getStorageSize from str like '9.75 Mib'/'1290 B'
+function storageSizeConverter(data) {
+  var data =data.toString()

Review comment:
       Please insert one white space after `=`. and `;` after this statement.

##########
File path: core/src/main/resources/org/apache/spark/ui/static/sorttable.js
##########
@@ -505,3 +522,28 @@ var forEach = function(object, block, context) {
   }
 };
 
+// getStorageSize from str like '9.75 Mib'/'1290 B'
+function storageSizeConverter(data) {
+  var data =data.toString()
+  var multipliers = {
+    b: 1,
+    kib: 1024,
+    mib: 1048576,
+    gib: 1073741824,
+    tib: 1099511627776,
+    pib: 1125899906842624,
+    eib: 1152921504606846976,
+    zib: 1180591620717411303424,
+    yib: 1208925819614629174706176,
+  }
+
+  var matches = data.match(/^(\d+(?:\.\d+)?)\s*(b|[k|m|g|t|p|e|z|y]ib)[\s\S]*/i);
+
+  if(matches) {
+    var unit = matches[2].toLowerCase()

Review comment:
       `;`

##########
File path: core/src/main/resources/org/apache/spark/ui/static/sorttable.js
##########
@@ -278,6 +282,19 @@ sorttable = {
     if (isNaN(bb)) bb = 0;
     return aa-bb;
   },
+  sort_storage_size: function(src, dst) {
+    if(src[0].toLowerCase() === dst[0].toLowerCase()) {
+      return 0;
+    }
+    srcSize = storageSizeConverter(src[0])
+    dstSize = storageSizeConverter(dst[0])
+
+    if(srcSize === dstSize) {

Review comment:
       Please insert one whitespace.

##########
File path: core/src/main/resources/org/apache/spark/ui/static/sorttable.js
##########
@@ -185,6 +185,10 @@ sorttable = {
         if (text.match(/^-?[£$¤]?[\d,.]+%?$/)) {
           return sorttable.sort_numeric;
         }
+        // match content like '287.1 MiB (17.2 GiB Remaining)', '0.0 B'
+        else if(text.match(/^(\d+(?:\.\d+)?)\s*(b|[k|m|g|t|p|e|z|y]ib)[\s\S]*/i)) {
+          return sorttable.sort_storage_size

Review comment:
       Please append `;` to this statement.

##########
File path: core/src/main/resources/org/apache/spark/ui/static/sorttable.js
##########
@@ -278,6 +282,19 @@ sorttable = {
     if (isNaN(bb)) bb = 0;
     return aa-bb;
   },
+  sort_storage_size: function(src, dst) {
+    if(src[0].toLowerCase() === dst[0].toLowerCase()) {
+      return 0;
+    }
+    srcSize = storageSizeConverter(src[0])
+    dstSize = storageSizeConverter(dst[0])
+
+    if(srcSize === dstSize) {
+      return 0;
+    }else {

Review comment:
       Please insert one whitespace.

##########
File path: core/src/main/resources/org/apache/spark/ui/static/sorttable.js
##########
@@ -505,3 +522,28 @@ var forEach = function(object, block, context) {
   }
 };
 
+// getStorageSize from str like '9.75 Mib'/'1290 B'
+function storageSizeConverter(data) {
+  var data =data.toString()
+  var multipliers = {
+    b: 1,
+    kib: 1024,
+    mib: 1048576,
+    gib: 1073741824,
+    tib: 1099511627776,
+    pib: 1125899906842624,
+    eib: 1152921504606846976,
+    zib: 1180591620717411303424,
+    yib: 1208925819614629174706176,
+  }
+
+  var matches = data.match(/^(\d+(?:\.\d+)?)\s*(b|[k|m|g|t|p|e|z|y]ib)[\s\S]*/i);
+
+  if(matches) {

Review comment:
       Please insert one whitespace.

##########
File path: core/src/main/resources/org/apache/spark/ui/static/sorttable.js
##########
@@ -505,3 +522,28 @@ var forEach = function(object, block, context) {
   }
 };
 
+// getStorageSize from str like '9.75 Mib'/'1290 B'
+function storageSizeConverter(data) {
+  var data =data.toString()
+  var multipliers = {
+    b: 1,
+    kib: 1024,
+    mib: 1048576,
+    gib: 1073741824,
+    tib: 1099511627776,
+    pib: 1125899906842624,
+    eib: 1152921504606846976,
+    zib: 1180591620717411303424,
+    yib: 1208925819614629174706176,
+  }

Review comment:
       `;`

##########
File path: core/src/main/resources/org/apache/spark/ui/static/sorttable.js
##########
@@ -278,6 +282,19 @@ sorttable = {
     if (isNaN(bb)) bb = 0;
     return aa-bb;
   },
+  sort_storage_size: function(src, dst) {
+    if(src[0].toLowerCase() === dst[0].toLowerCase()) {
+      return 0;
+    }
+    srcSize = storageSizeConverter(src[0])
+    dstSize = storageSizeConverter(dst[0])

Review comment:
       Please append `;` to the statements above.




-- 
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



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org