You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by ab...@apache.org on 2018/05/11 00:44:16 UTC

impala git commit: IMPALA-6966: sort table memory by size in catalogd web UI

Repository: impala
Updated Branches:
  refs/heads/master 49413d9c5 -> ea4715fd7


IMPALA-6966: sort table memory by size in catalogd web UI

This patch fix the sorting order in "Top-K Tables with Highest
Memory Requirements" in which "Estimated memory" column is sorted
as strings.

Values got from the catalog-server are changed from pretty-printed
strings to bytes numbers. So the web UI is able to sort and render
them correctly.

Change-Id: I60dc253f862f5fde6fa96147f114d8765bb31a85
Reviewed-on: http://gerrit.cloudera.org:8080/10292
Reviewed-by: Dimitris Tsirogiannis <dt...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>


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

Branch: refs/heads/master
Commit: ea4715fd76d6dba0c3777146989c2bf020efabdd
Parents: 49413d9
Author: stiga-huang <hu...@gmail.com>
Authored: Thu May 3 06:44:42 2018 -0700
Committer: Impala Public Jenkins <im...@cloudera.com>
Committed: Thu May 10 22:39:21 2018 +0000

----------------------------------------------------------------------
 be/src/catalog/catalog-server.cc |  5 ++---
 www/catalog.tmpl                 | 16 +++++++++++++++-
 2 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/impala/blob/ea4715fd/be/src/catalog/catalog-server.cc
----------------------------------------------------------------------
diff --git a/be/src/catalog/catalog-server.cc b/be/src/catalog/catalog-server.cc
index c2ebf14..e74db75 100644
--- a/be/src/catalog/catalog-server.cc
+++ b/be/src/catalog/catalog-server.cc
@@ -375,9 +375,8 @@ void CatalogServer::GetCatalogUsage(Document* document) {
         large_table.table_name.table_name).c_str(), document->GetAllocator());
     tbl_obj.AddMember("name", tbl_name, document->GetAllocator());
     DCHECK(large_table.__isset.memory_estimate_bytes);
-    Value memory_estimate(PrettyPrinter::Print(large_table.memory_estimate_bytes,
-        TUnit::BYTES).c_str(), document->GetAllocator());
-    tbl_obj.AddMember("mem_estimate", memory_estimate, document->GetAllocator());
+    tbl_obj.AddMember("mem_estimate", large_table.memory_estimate_bytes,
+        document->GetAllocator());
     large_tables.PushBack(tbl_obj, document->GetAllocator());
   }
   Value has_large_tables;

http://git-wip-us.apache.org/repos/asf/impala/blob/ea4715fd/www/catalog.tmpl
----------------------------------------------------------------------
diff --git a/www/catalog.tmpl b/www/catalog.tmpl
index ffe7c78..edd3f04 100644
--- a/www/catalog.tmpl
+++ b/www/catalog.tmpl
@@ -51,9 +51,23 @@ under the License.
 </div>
 
 <script>
+    function getReadableSize(bytes) {
+        var units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'];
+        if (bytes <= 0) return bytes + ' B';
+        var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
+        return (bytes / Math.pow(1024, i)).toFixed(2) + ' ' + units[i];
+    }
+    function renderSize(data, type, row) {
+        // If display or filter data is requested, format the data
+        if (type === 'display' || type === 'filter') {
+            return getReadableSize(data);
+        }
+        return data;
+    }
     $(document).ready(function() {
         $('#large-tables').DataTable({
-            "order": [[ 0, "desc" ]],
+            "columnDefs": [{"targets": 1, "render": renderSize}],
+            "order": [[ 1, "desc" ]],
             "pageLength": 10
         });
     });