How to Create a Column family in a Selected Cluster in HBase

China☆狼群 提交于 2019-12-12 01:58:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!