Author: stack
Date: Sat Jun 18 22:12:07 2011
New Revision: 1137257
URL: http://svn.apache.org/viewvc?rev=1137257&view=rev
Log:
HBASE-4000 You can't specify split points when you create a table in the shell
Modified:
hbase/trunk/CHANGES.txt
hbase/trunk/src/main/ruby/hbase.rb
hbase/trunk/src/main/ruby/hbase/admin.rb
hbase/trunk/src/main/ruby/shell/commands/create.rb
Modified: hbase/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1137257&r1=1137256&r2=1137257&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Sat Jun 18 22:12:07 2011
@@ -128,6 +128,8 @@ Release 0.91.0 - Unreleased
HBASE-3793 HBASE-3468 Broke checkAndPut with null value (Ming Ma)
HBASE-3995 HBASE-3946 broke TestMasterFailover
HBASE-3889 NPE in Distributed Log Splitting (Anirudh Todi)
+ HBASE-4000 You can't specify split points when you create a table in
+ the shell (Joey Echeverria)
IMPROVEMENTS
HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack)
Modified: hbase/trunk/src/main/ruby/hbase.rb
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/main/ruby/hbase.rb?rev=1137257&r1=1137256&r2=1137257&view=diff
==============================================================================
--- hbase/trunk/src/main/ruby/hbase.rb (original)
+++ hbase/trunk/src/main/ruby/hbase.rb Sat Jun 18 22:12:07 2011
@@ -51,6 +51,8 @@ module HBaseConstants
INTERVAL = 'INTERVAL'
CACHE = 'CACHE'
FILTER = 'FILTER'
+ SPLITS = 'SPLITS'
+ SPLITS_FILE = 'SPLITS_FILE'
# Load constants from hbase java API
def self.promote_constants(constants)
Modified: hbase/trunk/src/main/ruby/hbase/admin.rb
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/main/ruby/hbase/admin.rb?rev=1137257&r1=1137256&r2=1137257&view=diff
==============================================================================
--- hbase/trunk/src/main/ruby/hbase/admin.rb (original)
+++ hbase/trunk/src/main/ruby/hbase/admin.rb Sat Jun 18 22:12:07 2011
@@ -142,24 +142,48 @@ module Hbase
# Start defining the table
htd = org.apache.hadoop.hbase.HTableDescriptor.new(table_name)
-
- # All args are columns, add them to the table definition
+ splits = nil
+ # Args are either columns or splits, add them to the table definition
# TODO: add table options support
args.each do |arg|
unless arg.kind_of?(String) || arg.kind_of?(Hash)
raise(ArgumentError, "#{arg.class} of #{arg.inspect} is not of Hash
or String type")
end
- # Add column to the table
- descriptor = hcd(arg, htd)
- if arg[COMPRESSION_COMPACT]
- descriptor.setValue(COMPRESSION_COMPACT, arg[COMPRESSION_COMPACT])
+ if arg.kind_of?(Hash) and (arg.has_key?(SPLITS) or
arg.has_key?(SPLITS_FILE))
+ if arg.has_key?(SPLITS_FILE)
+ unless File.exist?(arg[SPLITS_FILE])
+ raise(ArgumentError, "Splits file #{arg[SPLITS_FILE]} doesn't
exist")
+ end
+ arg[SPLITS] = []
+ File.foreach(arg[SPLITS_FILE]) do |line|
+ arg[SPLITS].push(line.strip())
+ end
+ end
+
+ splits = Java::byte[][arg[SPLITS].size].new
+ idx = 0
+ arg[SPLITS].each do |split|
+ splits[idx] = split.to_java_bytes
+ idx = idx + 1
+ end
+ else
+ # Add column to the table
+ descriptor = hcd(arg, htd)
+ if arg[COMPRESSION_COMPACT]
+ descriptor.setValue(COMPRESSION_COMPACT, arg[COMPRESSION_COMPACT])
+ end
+ htd.addFamily(descriptor)
end
- htd.addFamily(descriptor)
end
- # Perform the create table call
- @admin.createTable(htd)
+ if splits.nil?
+ # Perform the create table call
+ @admin.createTable(htd)
+ else
+ # Perform the create table call
+ @admin.createTable(htd, splits)
+ end
end
#----------------------------------------------------------------------------------------------
Modified: hbase/trunk/src/main/ruby/shell/commands/create.rb
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/main/ruby/shell/commands/create.rb?rev=1137257&r1=1137256&r2=1137257&view=diff
==============================================================================
--- hbase/trunk/src/main/ruby/shell/commands/create.rb (original)
+++ hbase/trunk/src/main/ruby/shell/commands/create.rb Sat Jun 18 22:12:07 2011
@@ -33,6 +33,8 @@ Examples:
hbase> # The above in shorthand would be the following:
hbase> create 't1', 'f1', 'f2', 'f3'
hbase> create 't1', {NAME => 'f1', VERSIONS => 1, TTL => 2592000, BLOCKCACHE
=> true}
+ hbase> create 't1', 'f1', {SPLITS => ['10', '20', '30', '40']}
+ hbase> create 't1', 'f1', {SPLITS_FILE => 'splits.txt'}
EOF
end