You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by ta...@apache.org on 2018/06/07 07:00:06 UTC
[3/3] impala git commit: IMPALA-7082: Show human readable size in
query backend page
IMPALA-7082: Show human readable size in query backend page
This patch reuse the JS function introduced in IMPALA-6966,
which can convert Long size value into human readable size,
to render the "Peak mem. consumption" column in the Query
details's Backends page.
Change-Id: I04afb4091bb8b6bc9dedfeceaf9284a8c65b16a1
Reviewed-on: http://gerrit.cloudera.org:8080/10523
Reviewed-by: Philip Zeyliger <ph...@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/725a47b3
Tree: http://git-wip-us.apache.org/repos/asf/impala/tree/725a47b3
Diff: http://git-wip-us.apache.org/repos/asf/impala/diff/725a47b3
Branch: refs/heads/master
Commit: 725a47b3f275aa76db6a65d4e320f8dbaf9d6b28
Parents: 68aeb71
Author: stiga-huang <hu...@gmail.com>
Authored: Sat May 26 03:16:26 2018 -0700
Committer: Impala Public Jenkins <im...@cloudera.com>
Committed: Thu Jun 7 06:10:36 2018 +0000
----------------------------------------------------------------------
www/catalog.tmpl | 13 -------------
www/common-header.tmpl | 1 +
www/query_backends.tmpl | 2 +-
www/scripts/util.js | 37 +++++++++++++++++++++++++++++++++++++
4 files changed, 39 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/impala/blob/725a47b3/www/catalog.tmpl
----------------------------------------------------------------------
diff --git a/www/catalog.tmpl b/www/catalog.tmpl
index edd3f04..35ebf5f 100644
--- a/www/catalog.tmpl
+++ b/www/catalog.tmpl
@@ -51,19 +51,6 @@ 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({
"columnDefs": [{"targets": 1, "render": renderSize}],
http://git-wip-us.apache.org/repos/asf/impala/blob/725a47b3/www/common-header.tmpl
----------------------------------------------------------------------
diff --git a/www/common-header.tmpl b/www/common-header.tmpl
index 227709d..7bf669c 100644
--- a/www/common-header.tmpl
+++ b/www/common-header.tmpl
@@ -23,6 +23,7 @@ common-footer.tmpl) }}
<head><title>Apache Impala</title>
<script src='/www/jquery/jquery-1.12.4.min.js'></script>
<script src='/www/bootstrap/js/bootstrap.min.js'></script>
+ <script src='/www/scripts/util.js'></script>
<link rel="stylesheet" type="text/css" href="/www/datatables.min.css"/>
<script type="text/javascript" src="/www/datatables.min.js"></script>
<link href='/www/bootstrap/css/bootstrap.min.css' rel='stylesheet' media='screen'>
http://git-wip-us.apache.org/repos/asf/impala/blob/725a47b3/www/query_backends.tmpl
----------------------------------------------------------------------
diff --git a/www/query_backends.tmpl b/www/query_backends.tmpl
index 07d1b57..77ed261 100644
--- a/www/query_backends.tmpl
+++ b/www/query_backends.tmpl
@@ -64,7 +64,7 @@ $(document).ready(function() {
{data: 'num_instances'},
{data: 'num_remaining_instances'},
{data: 'done'},
- {data: 'peak_mem_consumption'},
+ {data: 'peak_mem_consumption', render: renderSize},
{data: 'time_since_last_heard_from'}],
"order": [[ 0, "desc" ]],
"pageLength": 100
http://git-wip-us.apache.org/repos/asf/impala/blob/725a47b3/www/scripts/util.js
----------------------------------------------------------------------
diff --git a/www/scripts/util.js b/www/scripts/util.js
new file mode 100644
index 0000000..5d79ac5
--- /dev/null
+++ b/www/scripts/util.js
@@ -0,0 +1,37 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+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];
+}
+
+/*
+ * Useful render function used in DataTable. It renders the size
+ * value into human readable format in 'display' and 'filter' modes,
+ * and uses the original value in 'sort' mode.
+ */
+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;
+}
+