hadoop之根据Rowkey从HBase中查询数据
2015-11-29 12:04
411 查看
1.Hbase 根据rowkey 查询
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
conf的配置信息如下:
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
conf = new Configuration(); conf.set("hbase.zookeeper.quorum", "192.168.50.253:2181"); conf.set("hbase.rootdir", "hdfs://192.168.50.253:9000/hbase");
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
public ArrayList<String> getRoutes(String rowkey,String tablename) throws IOException { HTable hTable = new HTable(conf, tablename);//traffic_route Get get = new Get(rowkey.getBytes()); Result r = hTable.get(get); KeyValue[] kv = r.raw(); // 行健对应的值. ArrayList<String> list = new ArrayList<>(); if (kv.length > 0) { String ss = kv[0].getValue().toString(); DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date tempDay = new Date(); tempDay = null; int sum = 0; String tempDate = ""; String mapStringValue = ""; for (int i = 0; i < kv.length; i++) { String value = new String(kv[i].getValue()); // System.out.println("value = " + value); String[] station = value.split("--"); // System.out.println(station[0]); String[] date = station[0].split(" "); try { Date day = sdf.parse(date[0]); if (tempDay == null) { tempDay = day; } if ((day.compareTo(tempDay) == 0)) { tempDate = date[0]; mapStringValue = mapStringValue + station[1] + "-"; } else { Map<String, String> map = new HashMap<>(); map.put(tempDate, mapStringValue); list.add(mapStringValue); mapStringValue = ""; tempDay = day; mapStringValue += station[1] + "-"; } } catch (ParseException e) { e.printStackTrace(); } } // System.out.println("list = " + list.size()); Map<String, String> map = new HashMap<>(); map.put(tempDate, mapStringValue); list.add(mapStringValue); mapStringValue = ""; } // System.out.println("list.get(0) = " + list.get(0)); // System.out.println("list.get(1) = " + list.get(1)); if (list.size() == 0) { System.out.println("取出数据为空"); } else { System.out.println("获取数据成功"); } return list; }
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
相关文章推荐
- linux系统管理命令kata练习
- 关于rest风格一些理解
- video4linux(v4l)使用摄像头的实例基础教程与体会
- CentOS 下安装Vmware Tools
- 安装和使用nmon监测hadoop集群性能
- Video4Linux 中文解析
- Linux进程状态解析之R、S、D、T、Z、X
- CentOS6.4_X86_64 安装Drupal-7.31必须成功版!
- OpenJudge_P7834 分成互质组
- linux shell对应的配置文件是怎么被执行的呢?-----聊聊/etc/profile, ~/.bash_profile, ~/.bashrc等配置文件的执行流程
- 阿里云ubuntu集成nginx+tomcat7
- Windows下secureCRT、putty使用秘钥登录Linux
- linux shell中的变量PS1------定制linux shell提示符
- crontab,linux中创建定时任务与取消
- OpenJudge_P3525 上台阶(DP)
- PopupWindow使用总结
- Unclean shutdown of previous Apache run问题处理
- UVA 12576 Simply Loopy
- Debian下安装配置OpenLDAP
- Hadoop2.6.0学习笔记(三)Hadoop序列化