开发者学堂课程【分布式数据库 HBase 快速入门:获取微博内容 &;过器介绍】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/101/detail/1779
获取微博内容 &;过器介绍
Pubilc static void getData(String uid) throws IOException{0
//获取连接
Connection connection= ConnectionFactory . createConnection ( configuration );
//获取表对象
Table table = connection . getTable ( TableNane . valueOf( Constant . CONTENT ));
//扫描(过滤器)
Scan scan = new Scan();
RoaFilter ro w Filter = new Ro w Filter ( CormpareFilter . CompareOp . EQUAL ,new SubstringComparator ( uid +"_"));
scan . setFilter ( rowFilter );
ResultScanner results = table . getScanner ( scan );
//遍历打印
for ( Result result : results ){
Cell [ ]cells = result , rawCells();
for ( Cell cell : cells ){
System.out . println (" RK :"+ Bytes . toString ( CellUtil . cloneRoa (cell))
+", Content :"+ Bytes . toString (CellUtil. clonelvalue (cell)));
//关闭资源
table .close() ;
connection . close();
}