hbase功能实现API
来源:互联网 发布:网络四大名著三大奇书 编辑:程序博客网 时间:2024/05/29 23:23
hbase功能实现API
package com.ucky.hbase;import java.io.IOException;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.hbase.HBaseConfiguration;import org.apache.hadoop.hbase.HColumnDescriptor;import org.apache.hadoop.hbase.HTableDescriptor;import org.apache.hadoop.hbase.client.HBaseAdmin;import org.apache.hadoop.hbase.client.HTable;import org.apache.hadoop.hbase.client.Put;import org.apache.hadoop.hbase.client.Result;import org.apache.hadoop.hbase.client.ResultScanner;import org.apache.hadoop.hbase.client.Scan;import com.sun.org.apache.bcel.internal.generic.FMUL;public class hbase {private static final String TABLE_NAME="table1";private static final String FAMILY_NAME="family";private static final String ROW_KEY="row1";public static void main(String[] args) throws Exception {Configuration conf = HBaseConfiguration.create();conf.set("hbase.rootdir", "hdfs://hadoop-master.dragon.org:9000/hbase");conf.set("hbase.zookeeper.quorum", "hadoop-master");HBaseAdmin hBaseAdmin = new HBaseAdmin(conf);HTable hTable = new HTable(conf, TABLE_NAME);//createTable(hBaseAdmin);//deleteTable(hBaseAdmin);//createRow(hTable);//scanTable(hTable);}private static void scanTable(HTable hTable) throws IOException {Scan scan = new Scan();ResultScanner scanner = hTable.getScanner(scan);for (Result sc : scanner) {byte[] value = sc.getValue(FAMILY_NAME.getBytes(), "age".getBytes());System.out.println(sc + "\t" + new String(value));}hTable.close();}private static void createRow(HTable hTable) throws IOException {Put put = new Put(ROW_KEY.getBytes());put.add(FAMILY_NAME.getBytes(), "age".getBytes(), "22".getBytes());hTable.put(put);hTable.close();}private static void deleteTable(HBaseAdmin hBaseAdmin) throws IOException {hBaseAdmin.disableTable(TABLE_NAME);hBaseAdmin.deleteTable(TABLE_NAME);}private static void createTable(HBaseAdmin hBaseAdmin) throws IOException {HTableDescriptor desc = new HTableDescriptor(TABLE_NAME);HColumnDescriptor family = new HColumnDescriptor(FAMILY_NAME);desc.addFamily(family);hBaseAdmin.createTable(desc);}}
0 0
- hbase功能实现API
- Hbase葱岭探秘--Hbase管理功能Api
- Hbase API管理功能1
- HBase功能实现
- Hbase API管理功能2-HBaseAdmin
- Hbase API管理功能3-集群管理
- Hbase 笔记(5) 客户端API 管理功能
- hbase分页的功能实现
- hbase开发,hbase表操作及其java api实现
- hbase开发,hbase表操作及其java api实现
- Hbase 新api连接java实现
- Hbase的Java开发API操作实现
- Hbase-简介-存储API与实现
- 【hbase】Hbase分页功能的实现及源码
- hbase分页功能的实现及源码
- HBase 数据导入功能实现方式解释
- Hbase API管理功能4-集群状态信息
- win32 API 实现ping功能
- 瀑布流布局-初接触
- switch红色下划线,Error:控制传输跳过的实例化解决办法
- HDFS快照(HDFS Snapshots)
- FreeRTOS系列第5篇---FreeRTOS在Cortex-M3上的移植
- jqury multiselect
- hbase功能实现API
- T-SQL - 同表中,以某一列聚合,详细聚合信息在一列显示
- 位图索引
- android之CardView的使用
- 行为图---状态图和活动图
- HDFS架构( HDFS Architecture)
- Android使用AttributeSet自定义控件的方法
- 《剑指Offer》读书笔记06:旋转数组的最小数字
- 教你如何在Mac上搭建自己的服务器——Nginx