Skip to content

Instantly share code, notes, and snippets.

@rbm
Created November 25, 2014 22:30
Show Gist options
  • Save rbm/7ef5106f1e81bd5b824e to your computer and use it in GitHub Desktop.
Save rbm/7ef5106f1e81bd5b824e to your computer and use it in GitHub Desktop.
Dump HBase schema creation statements
include Java
import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.client.HTable
conf = HBaseConfiguration.new
jrb_tables = list()
hbase_tables = jrb_tables.map { |jt| HTable.new(conf, jt) }
hbase_tables.each do |tbl|
desc = tbl.getTableDescriptor()
name = desc.nameAsString()
fams = desc.getFamilies().toArray()
famstrs = fams.map { |fam| fam.toString() }
print "create '#{name}', #{famstr.join(', ')}"
print "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment