栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何从Hbase读取数据?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何从Hbase读取数据?

从网站:

// Sometimes, you won't know the row you're looking for. In this case, you// use a Scanner. This will give you cursor-like interface to the contents// of the table.  To set up a Scanner, do like you did above making a Put// and a Get, create a Scan.  Adorn it with column names, etc.Scan s = new Scan();s.addColumn(Bytes.toBytes("myLittleFamily"), Bytes.toBytes("someQualifier"));ResultScanner scanner = table.getScanner(s);try {  // Scanners return Result instances.  // Now, for the actual iteration. One way is to use a while loop like so:  for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {    // print out the row we found and the columns we were looking for    System.out.println("Found row: " + rr);  }  // The other approach is to use a foreach loop. Scanners are iterable!  // for (Result rr : scanner) {  //   System.out.println("Found row: " + rr);  // }} finally {  // Make sure you close your scanners when you are done!  // Thats why we have it inside a try/finally clause  scanner.close();}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/508850.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号