问题
In cassandra hector API allow to create table on a selected cluster as follows. I want to do the same thing using HBase, can someone please help me out?
This is how it can done using Cassandra :
public void createColumnFamily(Cluster cluster, String tableName,
String columnFamilyName,
StreamDefinition streamDefinition) {
}
回答1:
There is no such concept of cluster namespace in HBase. You can simple create a table in HBase using methods of HBaseAdmin class.
HBaseConfiguration conf = HBaseConfiguration.create();
HBaseAdmin admin = new HBaseAdmin(conf);
HTableDescriptor tableDescriptor = new HTableDescriptor(tableName);// maps to keyspace name of cassandra.
HColumnDescriptor hColumnDescriptor = new HColumnDescriptor(columnFamilyName);// maps to column family name of cassandra.
tableDescriptor.addFamily(hColumnDescriptor);
admin.createTable(hTableDescriptor);
来源:https://stackoverflow.com/questions/23333060/how-to-create-a-column-family-in-a-selected-cluster-in-hbase