hbase客户端查询API
来源:互联网 发布:时尚笔记本电脑淘宝 编辑:程序博客网 时间:2024/04/29 23:37
/* * 查询数据 */ @Test public void testGet() throws IOException { Configuration conf = HBaseConfiguration.create(); conf.set("hbase.zookeeper.quorum","os-1:2181,os-2:2181,os-3:2181"); //插入数据必须拿到一个客户端对象 HTable hTable = new HTable(conf, "cart"); Get get = new Get(Bytes.toBytes("user_03")); //指定要查询的列 get.addColumn("product".getBytes(), Bytes.toBytes("product_num")); Result result = hTable.get(get); byte[] value = result.getValue("product".getBytes(), "product_num".getBytes()); System.out.println("值为:"+Bytes.toString(value)); hTable.close(); } /* * scan查询 */ @Test public void testScan() throws IOException { Configuration conf = HBaseConfiguration.create(); conf.set("hbase.zookeeper.quorum","os-1:2181,os-2:2181,os-3:2181"); HTable hTable = new HTable(conf, "cart"); Scan scan = new Scan(Bytes.toBytes("user_01"),"user_03".getBytes()); ResultScanner scanner = hTable.getScanner(scan); Iterator<Result> iterator = scanner.iterator(); while(iterator.hasNext()) { Result result= iterator.next(); byte[] value_num = result.getValue("product".getBytes(), "product_num".getBytes()); byte[] value_id = result.getValue("product".getBytes(), "product_id".getBytes()); byte[] value_num_01 = result.getValue("product".getBytes(), "product_num_01".getBytes()); System.out.println(Bytes.toString(value_num_01)); System.out.println(Bytes.toString(value_num)); System.out.println(Bytes.toString(value_id)); } hTable.close(); }
阅读全文
0 0
- hbase客户端查询API
- Hbase 基础客户端API
- HBase--客户端API(基础知识)
- HBase客户端API使用
- HBase客户端API使用
- hbase客户端api实例
- Hbase客户端操作api
- hbase客户端api--建表
- java api 查询hbase
- java api 查询hbase
- HBase--客户端API(基础知识)二
- HBase客户端API基本操作
- hBase客户端API-增删改
- [hbase]使用HBase的Java API查询HBase(2)
- [hbase]使用HBase的Java api查询HBase
- HBase客户端Java API使用总结
- Hbase 笔记(3) 客户端API基础
- Hbase 笔记(4) 客户端API高级性能
- android简单接口回调
- 算法导论之广度优先搜索
- 解决使用python3.5来获取PCL库出现 unable to find vcvarsall.bat的问题
- 九度OJ题目解答1000
- Java:求树最小的深度
- hbase客户端查询API
- 【队内胡策】题解
- 1020 中序,后序转换为层序遍历
- 【BashuOJ2041】最大矩形-矩阵型DP
- 万达正式起诉10家自媒体 每家索赔500万元人民币
- ArrayList中常用方法
- PAT 1126. Eulerian Path (25)
- 【bzoj1196】【二分+最小生成树】公路修建问题
- String to Integer