赞
踩
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;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。