如何在HBase的选定群集中创建列族 [英] How to Create a Column family in a Selected Cluster in HBase

查看:291
本文介绍了如何在HBase的选定群集中创建列族的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在cassandra中,hector API允许按如下方式在选定的集群上创建表。我想用HBase做同样的事情,有人可以帮我解决吗?



这是如何使用Cassandra完成的:

  public void createColumnFamily(簇群集,字符串表名,
字符串columnFamilyName,
流定义流定义){
}


HBase中没有这样的集群命名空间的概念。
。您可以在使用的HBase HBaseAdmin类的方法简单创建一个表。



  HBaseConfiguration CONF = HBaseConfiguration.create() ; 
HBaseAdmin admin = new HBaseAdmin(conf);
HTableDescriptor tableDescriptor = new HTableDescriptor(tableName); //映射到cassandra的密钥空间名称。
HColumnDescriptor hColumnDescriptor = new HColumnDescriptor(columnFamilyName); //映射到cassandra的列名称。
tableDescriptor.addFamily(hColumnDescriptor);

admin.createTable(hTableDescriptor);


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) {
    }

解决方案

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);

这篇关于如何在HBase的选定群集中创建列族的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆