[
https://issues.apache.org/jira/browse/HBASE-13100?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14340438#comment-14340438
]
Sean Busbey commented on HBASE-13100:
-------------------------------------
{code}
+ create_test_table_with_splits(@testTableName)
+ @table = table(@testTableName)
+ splits = @table._get_splits_internal()
+ #Total splits is 5 but here count is 4 as we ignore implicit empty split.
+ assert_equal(4, splits.size)
+ assert_equal(["10", "20", "30", "40"], splits)
+ drop_test_table(@testTableName)
+ end
+
end
end
diff --git a/hbase-shell/src/test/ruby/test_helper.rb
b/hbase-shell/src/test/ruby/test_helper.rb
index e2ab921..c75242d 100644
--- a/hbase-shell/src/test/ruby/test_helper.rb
+++ b/hbase-shell/src/test/ruby/test_helper.rb
@@ -85,6 +85,19 @@ module Hbase
end
end
+ def create_test_table_with_splits(name)
+ # Create the table if needed
+ unless admin.exists?(name)
+ admin.create name, 'f1', SPLITS => ['10', '20', '30', '40']
+ return
+ end
{code}
You should pass the split array as an argument to
create_test_table_with_splits. That way it's easier to understand why the test
looks for those particular splits and also makes the helper more widely useful.
> Shell command to retrieve table splits
> --------------------------------------
>
> Key: HBASE-13100
> URL: https://issues.apache.org/jira/browse/HBASE-13100
> Project: HBase
> Issue Type: Improvement
> Components: shell
> Reporter: Sean Busbey
> Assignee: Ashish Singhi
> Priority: Minor
> Labels: beginner
> Fix For: 2.0.0, 1.1.0
>
> Attachments: HBASE-13100-v1.patch, HBASE-13100-v2.patch,
> HBASE-13100-v3.patch, HBASE-13100.patch
>
>
> Add a shell command that returns the splits for a table.
> Doing this yourself is currently possible, but involves going outside of the
> public api.
> {code}
> jruby-1.7.3 :012 > create 'example_table', 'f1', SPLITS => ["10", "20", "30",
> "40"]
> 0 row(s) in 0.5500 seconds
> => Hbase::Table - example_table
> jruby-1.7.3 :013 >
> get_table('example_table').table.get_all_region_locations.map do |location|
> org.apache.hadoop.hbase.util.Bytes::toStringBinary(location.get_region_info.get_start_key)
> end
> 0 row(s) in 0.0130 seconds
> => ["", "10", "20", "30", "40"]
> jruby-1.7.3 :014 >
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)