mirror of
https://github.com/apache/impala.git
synced 2025-12-19 09:58:28 -05:00
Imported query profiles are currently being stored in IndexedDB. Although IndexedDB does not have storage limitations like other browser storage APIs, there is a storage limit for a single attribute / field. For supporting larger query profiles, 'pako' compression library's v2.1.0 has been added along with its associated license. Before adding query profile JSON to indexedDB, it undergoes compression using this library. As compression and parsing profile is a long running process that can block the main thread, this has been delegated to a worker script running in the background. The worker script returns parsed query attributes and compressed profile text sent to it. The process of compression consumes time; hence, an alert message is displayed on the queries page warning user to refrain from closing or reloading the page. On completion, the raw total size, compressed total size, and total processing time are logged to the browser console. When multiple profiles are chosen, after each query profile insertion, the subsequent one is not triggered until compression and insertion are finished. The inserted query profile field is decompressed before parsing on the query plan, query profile, query statement, and query timeline page. Added tests for the compression library methods utilized by the worker script. Manual testing has been done on Firefox 126.0.1 and Chrome 126.0.6478. Change-Id: I8c4f31beb9cac89051460bf764b6d50c3933bd03 Reviewed-on: http://gerrit.cloudera.org:8080/21463 Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com> Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
57 lines
2.6 KiB
JavaScript
57 lines
2.6 KiB
JavaScript
// 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.
|
|
|
|
importScripts("../../pako.min.js");
|
|
importScripts("../common_util.js");
|
|
|
|
self.onmessage = (e) => {
|
|
var query = {};
|
|
try {
|
|
var profile = JSON.parse(e.data).contents;
|
|
var val = profile.profile_name;
|
|
query.id = val.substring(val.indexOf("=") + 1, val.length - 1);
|
|
query.user = profile.child_profiles[0].info_strings
|
|
.find(({key}) => key === "User").value;
|
|
query.default_db = profile.child_profiles[0].info_strings
|
|
.find(({key}) => key === "Default Db").value;
|
|
query.type = profile.child_profiles[0].info_strings
|
|
.find(({key}) => key === "Query Type").value;
|
|
query.start_time = profile.child_profiles[0].info_strings
|
|
.find(({key}) => key === "Start Time").value;
|
|
query.end_time = profile.child_profiles[0].info_strings
|
|
.find(({key}) => key === "End Time").value;
|
|
query.bytes_read = profile.child_profiles[2].counters
|
|
.find(({counter_name}) => counter_name === "TotalBytesRead").value;
|
|
query.bytes_read = getReadableSize(query.bytes_read, 2);
|
|
query.bytes_sent = profile.child_profiles[2].counters
|
|
.find(({counter_name}) => counter_name === "TotalBytesSent").value;
|
|
query.bytes_sent = getReadableSize(query.bytes_sent, 2);
|
|
query.state = profile.child_profiles[0].info_strings
|
|
.find(({key}) => key === "Query State").value;
|
|
query.rows_fetched = profile.child_profiles[1].counters
|
|
.find(({counter_name}) => counter_name === "NumRowsFetched").value;
|
|
query.resource_pool = profile.child_profiles[0].info_strings
|
|
.find(({key}) => key === "Request Pool").value;
|
|
query.statement = profile.child_profiles[0].info_strings
|
|
.find(({key}) => key === "Sql Statement").value;
|
|
query.statement = query.statement.substring(0, 250) + "...";
|
|
query.profile = pako.deflate(e.data, {level : 3});
|
|
} catch (err) {
|
|
query.error = err;
|
|
}
|
|
self.postMessage(query);
|
|
} |