当前位置:   article > 正文

hbase java 建表_hbase java API跟新数据,创建表

hbase java 建表_hbase java API跟新数据,创建表

package hbaseCURD;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.hbase.HBaseConfiguration;

import org.apache.hadoop.hbase.client.Get;

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.util.Bytes;

public class test {

public static void main(String[] args) throws IOException {

TableManager tm = new TableManager();

tm.getConf();

// tm.createTable("testtable","cf1","cf2");

HTable mytable=tm.getTableObj("testtable");

// Put put = new Put(Bytes.toBytes("row1"));

// put.add(Bytes.toBytes("cf1"), Bytes.toBytes("c1"), Bytes.toBytes("cf1ddfddvalue"));

// put.add(Bytes.toBytes("cf2"), Bytes.toBytes("c2"), Bytes.toBytes("cf2v3333alue"));

// mytable.put(put);

//查询

Get get = new Get(Bytes.toBytes("row1"));

Result result = mytable.get(get);

System.out.println("get result:" + Bytes.toString(result.getValue(Bytes.toBytes("cf1"), Bytes.toBytes("c1"))));

//Result[] result = table.get(List);//查询指定Rowkey的多条记录

}

}

package hbaseCURD;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.hbase.HBaseConfiguration;

import org.apache.hadoop.hbase.HColumnDescriptor;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/772015
推荐阅读
相关标签
  

闽ICP备14008679号