HBASE-1859 Misc shell fixes patch
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@817947 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
873bb2b7c3
commit
41558cf59d
|
@ -43,6 +43,7 @@ Release 0.21.0 - Unreleased
|
||||||
HBASE-1857 WrongRegionException when setting region online after .META.
|
HBASE-1857 WrongRegionException when setting region online after .META.
|
||||||
split (Cosmin Lehane via Stack)
|
split (Cosmin Lehane via Stack)
|
||||||
HBASE-1809 NPE thrown in BoundedRangeFileInputStream
|
HBASE-1809 NPE thrown in BoundedRangeFileInputStream
|
||||||
|
HBASE-1859 Misc shell fixes patch (Kyle Oba via Stack)
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
HBASE-1760 Cleanup TODOs in HTable
|
HBASE-1760 Cleanup TODOs in HTable
|
||||||
|
|
|
@ -2,12 +2,20 @@
|
||||||
module Formatter
|
module Formatter
|
||||||
# Base abstract class for results formatting.
|
# Base abstract class for results formatting.
|
||||||
class Formatter
|
class Formatter
|
||||||
|
def is_kernel?(obj)
|
||||||
|
obj.kind_of?(Module) and obj.name == "Kernel"
|
||||||
|
end
|
||||||
|
|
||||||
# Takes an output stream and a print width.
|
# Takes an output stream and a print width.
|
||||||
def initialize(o, w = 100)
|
def initialize(opts={})
|
||||||
raise TypeError.new("Type %s of parameter %s is not IO" % [o.class, o]) \
|
defaults = {:output_stream => Kernel, :format_width => 100}
|
||||||
unless o.instance_of? IO
|
options = defaults.merge(opts)
|
||||||
@out = o
|
|
||||||
@maxWidth = w
|
@out = options[:output_stream]
|
||||||
|
raise TypeError.new("Type %s of parameter %s is not IO" % [@out.class, @out]) \
|
||||||
|
unless @out.instance_of? IO or is_kernel?(@out)
|
||||||
|
|
||||||
|
@maxWidth = options[:format_width]
|
||||||
@rowCount = 0
|
@rowCount = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,7 +35,7 @@ module Formatter
|
||||||
end
|
end
|
||||||
if args.class == String
|
if args.class == String
|
||||||
output(@maxWidth, args)
|
output(@maxWidth, args)
|
||||||
puts
|
@out.puts
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
# TODO: Look at the type. Is it RowResult?
|
# TODO: Look at the type. Is it RowResult?
|
||||||
|
@ -35,7 +43,7 @@ module Formatter
|
||||||
splits = split(@maxWidth, dump(args[0]))
|
splits = split(@maxWidth, dump(args[0]))
|
||||||
for l in splits
|
for l in splits
|
||||||
output(@maxWidth, l)
|
output(@maxWidth, l)
|
||||||
puts
|
@out.puts
|
||||||
end
|
end
|
||||||
elsif args.length == 2
|
elsif args.length == 2
|
||||||
col1width = (not widths or widths.length == 0) ? @maxWidth / 4 : @maxWidth * widths[0] / 100
|
col1width = (not widths or widths.length == 0) ? @maxWidth / 4 : @maxWidth * widths[0] / 100
|
||||||
|
@ -57,7 +65,7 @@ module Formatter
|
||||||
@out.print(" ")
|
@out.print(" ")
|
||||||
output(col2width, splits2[index])
|
output(col2width, splits2[index])
|
||||||
index += 1
|
index += 1
|
||||||
puts
|
@out.puts
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# Print a space to set off multi-column rows
|
# Print a space to set off multi-column rows
|
||||||
|
|
12
bin/hirb.rb
12
bin/hirb.rb
|
@ -71,7 +71,8 @@ for arg in found
|
||||||
ARGV.delete(arg)
|
ARGV.delete(arg)
|
||||||
end
|
end
|
||||||
# Presume console format.
|
# Presume console format.
|
||||||
@formatter = Formatter::Console.new(STDOUT, format_width)
|
# Formatter takes an :output_stream parameter, if you don't want STDOUT.
|
||||||
|
@formatter = Formatter::Console.new(:format_width => format_width)
|
||||||
# TODO, etc. @formatter = Formatter::XHTML.new(STDOUT)
|
# TODO, etc. @formatter = Formatter::XHTML.new(STDOUT)
|
||||||
|
|
||||||
# Setup the HBase module. Create a configuration.
|
# Setup the HBase module. Create a configuration.
|
||||||
|
@ -100,9 +101,6 @@ promoteConstants(org.apache.hadoop.hbase.HColumnDescriptor.constants)
|
||||||
promoteConstants(org.apache.hadoop.hbase.HTableDescriptor.constants)
|
promoteConstants(org.apache.hadoop.hbase.HTableDescriptor.constants)
|
||||||
promoteConstants(HBase.constants)
|
promoteConstants(HBase.constants)
|
||||||
|
|
||||||
# If script2run, try running it. Will go on to run the shell unless
|
|
||||||
# script calls 'exit' or 'exit 0' or 'exit errcode'.
|
|
||||||
load(script2run) if script2run
|
|
||||||
|
|
||||||
# Start of the hbase shell commands.
|
# Start of the hbase shell commands.
|
||||||
|
|
||||||
|
@ -428,6 +426,12 @@ def split(tableNameOrRegionName)
|
||||||
admin().split(tableNameOrRegionName)
|
admin().split(tableNameOrRegionName)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# If script2run, try running it. Will go on to run the shell unless
|
||||||
|
# script calls 'exit' or 'exit 0' or 'exit errcode'.
|
||||||
|
load(script2run) if script2run
|
||||||
|
|
||||||
|
|
||||||
# Output a banner message that tells users where to go for help
|
# Output a banner message that tells users where to go for help
|
||||||
puts <<HERE
|
puts <<HERE
|
||||||
HBase Shell; enter 'help<RETURN>' for list of supported commands.
|
HBase Shell; enter 'help<RETURN>' for list of supported commands.
|
||||||
|
|
Loading…
Reference in New Issue