zoukankan      html  css  js  c++  java
  • HBase的常用Java API

    1. 创建HBase表的对象

    HBase表的对项名字叫HTable,创建它的方法有很多,常见的有如下:

    org.apache.hadoop.hbase.client.HTable hTable = new HTable(org.apache.hadoop.hbase.HBaseConfiguration conf, String tableName);
    
    或
    
    org.apache.hadoop.hbase.client.HTable hTable = new HTable(org.apache.hadoop.hbase.HBaseConfiguration conf, Byte[] tableName);

    1.1 其中的conf为配置对象,它的创建以及相关参数设置如下:

    //创建对象
    HBaseConfiguration conf = HBaseConfiguration.create();/
    
    //设置zookeeper
    conf.set("hbase.zookeeper.quorum","hadoop-task04,hadoop-task05,hadoop-task06");

    注:1.它的相关册数设置是和配置文件hbase-site.xml里的设置是一致的。

      2.建表还可以通过表的资源池来拿到一张表,不过这个方法已经过时了(org.apache.hadoop.hbase.client.HTablePool).

      3.可以通过客户端与HBase的连接来拿到一张表的对象,代码如下(推荐):

    HConnection connection = HConnectionManager.createConnection(config);
     HTableInterface table = connection.getTable("table1");
     try {
       // Use the table as needed, for a single operation and a single thread
     } finally {
       table.close();
       connection.close();
     }

    这样就可以拿到一个表的对象了。

    待更新。。。

  • 相关阅读:
    js 比较日期的大小
    日历(从今天起后面的14天)
    数字转大写
    object对象进行深拷贝
    浏览器渲染机制
    t-5.倒计时(秒杀效果)--本地--服务器(待续)
    s-1.rem自适应
    t-3.跑马灯
    t-2.手机端简单轮播(无滑动效果)
    16.弹性布局
  • 原文地址:https://www.cnblogs.com/leocook/p/HBase_javaapi_base.html
Copyright © 2011-2022 走看看