Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 19C10200B20 for ; Wed, 11 May 2016 21:12:53 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 181B5160A18; Wed, 11 May 2016 19:12:53 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 38EBC160A17 for ; Wed, 11 May 2016 21:12:52 +0200 (CEST) Received: (qmail 87363 invoked by uid 500); 11 May 2016 19:12:51 -0000 Mailing-List: contact commits-help@kudu.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@kudu.incubator.apache.org Delivered-To: mailing list commits@kudu.incubator.apache.org Received: (qmail 87354 invoked by uid 99); 11 May 2016 19:12:51 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 May 2016 19:12:51 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id CD291C3A6B for ; Wed, 11 May 2016 19:12:50 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.636 X-Spam-Level: X-Spam-Status: No, score=-4.636 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.416] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id BqvveHHKwNBh for ; Wed, 11 May 2016 19:12:48 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with SMTP id 92BC95FBC4 for ; Wed, 11 May 2016 19:12:47 +0000 (UTC) Received: (qmail 86279 invoked by uid 99); 11 May 2016 19:12:46 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 May 2016 19:12:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8A880DFD9F; Wed, 11 May 2016 19:12:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: todd@apache.org To: commits@kudu.incubator.apache.org Message-Id: <27ec5d208e72428e902821a2305013f4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-kudu git commit: KUDU-1388: Master web UI should show table's partition schema Date: Wed, 11 May 2016 19:12:46 +0000 (UTC) archived-at: Wed, 11 May 2016 19:12:53 -0000 Repository: incubator-kudu Updated Branches: refs/heads/master df040987f -> 568c12c19 KUDU-1388: Master web UI should show table's partition schema This patch adds PartitionSchema::DisplayString that creates a pretty-printed string suitable for display, and changes the web UI to display this string on /table. The format is Hash bucket schemas: Key columns: name_s00 type_s00 name_s01 type_s01 ... Bucket count: b0 Seed: sd0 Key columns: name_s10 type_s10 name_s11 type_s11 ... Bucket count: b1 Seed: sd1 ... Range columns: name_r0 type_r0 name_r1 type_r1 The display on the web UI is naive and it won't, e.g., display Unicode characters correctly, but that's true of the web UI in general and a fix should probably wait until after KUDU-981. Change-Id: I81b634f6dd51e63205bbd7956273b74ca63459f7 Reviewed-on: http://gerrit.cloudera.org:8080/3022 Tested-by: Kudu Jenkins Reviewed-by: Todd Lipcon Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/568c12c1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/568c12c1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/568c12c1 Branch: refs/heads/master Commit: 568c12c197a9c4019ded5ae2a9903be521840c98 Parents: df04098 Author: Will Berkeley Authored: Wed May 11 02:03:01 2016 -0400 Committer: Todd Lipcon Committed: Wed May 11 19:12:05 2016 +0000 ---------------------------------------------------------------------- src/kudu/common/partition.cc | 30 ++++++++++++++++++++++++++++ src/kudu/common/partition.h | 4 ++++ src/kudu/master/master-path-handlers.cc | 5 +++++ 3 files changed, 39 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/568c12c1/src/kudu/common/partition.cc ---------------------------------------------------------------------- diff --git a/src/kudu/common/partition.cc b/src/kudu/common/partition.cc index 76b341e..a06936b 100644 --- a/src/kudu/common/partition.cc +++ b/src/kudu/common/partition.cc @@ -35,6 +35,7 @@ using std::vector; using google::protobuf::RepeatedPtrField; using strings::Substitute; +using strings::SubstituteAndAppend; // The encoded size of a hash bucket in a partition key. static const size_t kEncodedBucketSize = sizeof(uint32_t); @@ -635,6 +636,35 @@ string PartitionSchema::DebugString(const Schema& schema) const { return JoinStrings(component_types, ", "); } +string PartitionSchema::DisplayString(const Schema& schema) const { + string display_string; + + if (!hash_bucket_schemas_.empty()) { + display_string.append("Hash bucket schemas:\n"); + for (const HashBucketSchema& hash_bucket_schema : hash_bucket_schemas_) { + display_string.append(" Key columns:\n"); + for (const ColumnId& col_id : hash_bucket_schema.column_ids) { + const ColumnSchema& col = schema.column(col_id); + SubstituteAndAppend(&display_string, " $0 $1\n", col.name(), col.type_info()->name()); + } + SubstituteAndAppend(&display_string, " Bucket count: $0\n", hash_bucket_schema.num_buckets); + if (hash_bucket_schema.seed != 0) { + SubstituteAndAppend(&display_string, " Seed: $0\n", hash_bucket_schema.seed); + } + display_string.append("\n"); + } + } + + if (!range_schema_.column_ids.empty()) { + display_string.append("Range columns:\n"); + for (const ColumnId& col_id : range_schema_.column_ids) { + const ColumnSchema& col = schema.column(col_id); + SubstituteAndAppend(&display_string, " $0 $1\n", col.name(), col.type_info()->name()); + } + } + return display_string; +} + bool PartitionSchema::Equals(const PartitionSchema& other) const { if (this == &other) return true; http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/568c12c1/src/kudu/common/partition.h ---------------------------------------------------------------------- diff --git a/src/kudu/common/partition.h b/src/kudu/common/partition.h index 06527dc..9937d33 100644 --- a/src/kudu/common/partition.h +++ b/src/kudu/common/partition.h @@ -176,6 +176,10 @@ class PartitionSchema { // Returns a text description of this partition schema suitable for debug printing. std::string DebugString(const Schema& schema) const; + // Returns a text description of this partition schema suitable for display in the web UI. + // The format of this string is not guaranteed to be identical cross-version. + std::string DisplayString(const Schema& schema) const; + // Returns true if the other partition schema is equivalent to this one. bool Equals(const PartitionSchema& other) const; http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/568c12c1/src/kudu/master/master-path-handlers.cc ---------------------------------------------------------------------- diff --git a/src/kudu/master/master-path-handlers.cc b/src/kudu/master/master-path-handlers.cc index 11eb5f2..de68cc1 100644 --- a/src/kudu/master/master-path-handlers.cc +++ b/src/kudu/master/master-path-handlers.cc @@ -190,6 +190,11 @@ void MasterPathHandlers::HandleTablePage(const Webserver::WebRequest& req, } *output << "\n"; + *output << "

Partition schema

"; + *output << "
";
+  *output << EscapeForHtmlToString(partition_schema.DisplayString(schema));
+  *output << "
"; + *output << "

Impala CREATE TABLE statement

\n"; string master_addresses;