Created
December 8, 2010 21:03
-
-
Save mikelikespie/733911 to your computer and use it in GitHub Desktop.
clones a table in hbase. Optionally takes an array of strings that are the keys to create the splits on
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clone_table(old_table_name, new_table_name, split_keys=nil) | |
admin = HBaseAdmin.new(HBaseConfiguration.new()) | |
td = admin.getTableDescriptor(old_table_name.to_java_bytes) | |
td.setName(new_table_name.to_java_bytes) | |
if split_keys.nil? | |
admin.createTable(td) | |
else | |
new_keys = Java::byte[][split_keys.size].new | |
split_keys.each_index {|i| new_keys[i] = split_keys[i].to_java_bytes} | |
admin.createTable(td, new_keys) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment