HBASE-10082 Describe 'table' output is all on one line, could use better formatting (Srikanth Srungarapu)

This commit is contained in:
stack 2014-10-20 20:17:56 -07:00
parent a0bb3fbc9b
commit 3e073924be
2 changed files with 11 additions and 5 deletions

View File

@ -23,7 +23,6 @@ java_import org.apache.hadoop.hbase.util.Pair
java_import org.apache.hadoop.hbase.util.RegionSplitter
java_import org.apache.hadoop.hbase.util.Bytes
java_import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos::SnapshotDescription
java_import org.apache.commons.collections.MapUtils
# Wrapper for org.apache.hadoop.hbase.client.HBaseAdmin
@ -332,6 +331,10 @@ module Hbase
@admin.getTableDescriptor(table_name.to_java_bytes).to_s
end
def get_column_families(table_name)
@admin.getTableDescriptor(table_name.to_java_bytes).getColumnFamilies()
end
#----------------------------------------------------------------------------------------------
# Truncates table (deletes all records by recreating the table)
def truncate(table_name, conf = @conf)

View File

@ -28,17 +28,20 @@ Describe the named table. For example:
Alternatively, you can use the abbreviated 'desc' for the same thing.
hbase> desc 't1'
hbase> desc 'nds1:t1'
hbase> desc 'ns1:t1'
EOF
end
def command(table)
now = Time.now
desc = admin.describe(table)
column_families = admin.get_column_families(table)
formatter.header([ "DESCRIPTION", "ENABLED" ], [ 64 ])
formatter.row([ desc, admin.enabled?(table).to_s ], true, [ 64 ])
formatter.header(["Table " + table.to_s + " is " + if admin.enabled?(table) then "ENABLED" else "DISABLED" end])
formatter.header([ "COLUMN FAMILIES DESCRIPTION" ])
column_families.each do |column_family|
formatter.row([ column_family.to_s ], true)
end
formatter.footer(now)
end
end