kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject incubator-kudu git commit: KUDU-1388: Master web UI should show table's partition schema
Date Wed, 11 May 2016 19:12:46 GMT
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 <todd@apache.org>


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 <wdberkeley@gmail.com>
Authored: Wed May 11 02:03:01 2016 -0400
Committer: Todd Lipcon <todd@apache.org>
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 << "</table>\n";
 
+  *output << "<h2>Partition schema</h2>";
+  *output << "<pre>";
+  *output << EscapeForHtmlToString(partition_schema.DisplayString(schema));
+  *output << "</pre>";
+
   *output << "<h2>Impala CREATE TABLE statement</h2>\n";
 
   string master_addresses;


Mime
View raw message