大数据全系列 教程
1869个小节阅读:467k
目录
408考研
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
####3.3.5 查询某用户3月份的通话记录
xxxxxxxxxx
//查询某用户3月份的通话记录
@Test
public void scanData() throws Exception {
//1.定义某用户的手机号码
String phoneNumber = "15893647910";
//2.定义startRow 包含
String startRow = phoneNumber+"_"+(Long.MAX_VALUE-
simpleDateFormat.parse("2050-04-01 00:00:00").getTime());
//3.定义stopRow 包含
String stopRow = phoneNumber+"_"+(Long.MAX_VALUE-
simpleDateFormat.parse("2050-03-01 00:00:00").getTime());
//4.创建Scan对象
Scan scan = new Scan();
//5.设置起始和结束行
scan.withStartRow(Bytes.toBytes(startRow));
scan.withStopRow(Bytes.toBytes(stopRow),true);
//6.执行查询
ResultScanner resultScanner = table.getScanner(scan);
//7.解析resultScanner
for(Result result:resultScanner){
//8.解析result
Cell[] cells = result.rawCells();
String rowInfo = "rowkey:"+Bytes.toString(CellUtil.cloneRow(cells[0]));
rowInfo +=","+Bytes.toString(CellUtil.cloneQualifier(cells[0]))
+":"+Bytes.toString(CellUtil.cloneValue(cells[0]));
rowInfo +=","+Bytes.toString(CellUtil.cloneQualifier(cells[1]))
+":"+Bytes.toString(CellUtil.cloneValue(cells[1]));
rowInfo +=","+Bytes.toString(CellUtil.cloneQualifier(cells[2]))
+":"+Bytes.toInt(CellUtil.cloneValue(cells[2]));
rowInfo +=","+Bytes.toString(CellUtil.cloneQualifier(cells[3]))
+":"+Bytes.toInt(CellUtil.cloneValue(cells[3]));
//9输出
System.out.println(rowInfo);
}
}