接上一篇,patientvisit表中的数据,最终是什么样子的呢?
为了便于查看,我把数据拆分成了两个Table:
Row Key | personinfo | personinfoex | |||||
empi | name | sex | birthday | address | patid | ||
visit001 | empi001 | zhangsan | male | 1999-12-31 | shanghai xxx road | pat001 | |
visit002 | empi002 | lisi | male | 2000-01-01 | beijing | pat002 | |
visit003 | empi003 | wangwu | female | 1999-12-30 | guangzhou | pat002 |
Row Key | visitinfo | visitinfoex | |||
visitid | visittime | visitdocid | visitdocname | ||
visit001 | visit001 | 2015-07-25 10:10:00 | doc001 | Dr. Yang | |
visit002 | visit002 | 2015-07-26 11:11:00 | doc001 | Dr. Yang | |
visit003 | visit003 | 2015-07-27 13:13:00 | doc002 | Dr. Li |
那接下来我们我们进行一下高级一些的操作。
首先是用get
hbase(main):001:0> get 'patientvisit','visit001' COLUMN CELL personinfo:address timestamp=1454230894972, value=shanghai xxx road personinfo:birthday timestamp=1454227896430, value=1999-12-31 personinfo:empi timestamp=1454227855358, value=empi001 personinfo:name timestamp=1454227867312, value=zhangsan personinfo:patid timestamp=1454230911137, value=pat001 personinfo:sex timestamp=1454227875809, value=male visitinfo:visitdocid timestamp=1454231377871, value=doc001 visitinfo:visitdocname timestamp=1454230997776, value=Dr. Yang visitinfo:visitid timestamp=1454230932806, value=visit001 visitinfo:visittime timestamp=1454230971848, value=2015-07-25 10:10:00 10 row(s) in 0.3760 seconds hbase(main):013:0> get 'patientvisit','visit001','personinfo' COLUMN CELL personinfo:address timestamp=1454230894972, value=shanghai xxx road personinfo:birthday timestamp=1454227896430, value=1999-12-31 personinfo:empi timestamp=1454227855358, value=empi001 personinfo:name timestamp=1454227867312, value=zhangsan personinfo:patid timestamp=1454230911137, value=pat001 personinfo:sex timestamp=1454227875809, value=male 6 row(s) in 0.0190 seconds hbase(main):002:0> get 'patientvisit','visit001','personinfo:name' COLUMN CELL personinfo:name timestamp=1454227867312, value=zhangsan 1 row(s) in 0.0100 seconds hbase(main):003:0> get 'patientvisit','visit001','personinfo:name','visitinfo:visitdocname' COLUMN CELL personinfo:name timestamp=1454227867312, value=zhangsan visitinfo:visitdocname timestamp=1454230997776, value=Dr. Yang 2 row(s) in 0.0110 seconds hbase(main):004:0> get 'patientvisit','visit001',COLUMN=>'personinfo:name' COLUMN CELL personinfo:name timestamp=1454227867312, value=zhangsan 1 row(s) in 0.0070 seconds hbase(main):005:0> get 'patientvisit','visit001',COLUMN=>['personinfo:name','visitinfo:visitdocname'] COLUMN CELL personinfo:name timestamp=1454227867312, value=zhangsan visitinfo:visitdocname timestamp=1454230997776, value=Dr. Yang 2 row(s) in 0.0220 seconds
然后是scan
hbase(main):006:0> scan 'patientvisit' ROW COLUMN+CELL visit001 column=personinfo:address, timestamp=1454230894972, value=shanghai xxx road visit001 column=personinfo:birthday, timestamp=1454227896430, value=1999-12-31 visit001 column=personinfo:empi, timestamp=1454227855358, value=empi001 visit001 column=personinfo:name, timestamp=1454227867312, value=zhangsan visit001 column=personinfo:patid, timestamp=1454230911137, value=pat001 visit001 column=personinfo:sex, timestamp=1454227875809, value=male visit001 column=visitinfo:visitdocid, timestamp=1454231377871, value=doc001 visit001 column=visitinfo:visitdocname, timestamp=1454230997776, value=Dr. Yang visit001 column=visitinfo:visitid, timestamp=1454230932806, value=visit001 visit001 column=visitinfo:visittime, timestamp=1454230971848, value=2015-07-25 10:10:00 visit002 column=personinfo:address, timestamp=1454231323278, value=beijing visit002 column=personinfo:empi, timestamp=1454231239104, value=empi002 visit002 column=personinfo:name, timestamp=1454231253067, value=lisi visit002 column=personinfo:patid, timestamp=1454231282131, value=pat002 visit002 column=personinfo:sex, timestamp=1454231269942, value=male visit002 column=visitinfo:visitdocid, timestamp=1454231371494, value=doc001 visit002 column=visitinfo:visitdocname, timestamp=1454231389655, value=Dr. Yang visit002 column=visitinfo:visitid, timestamp=1454231405071, value=visit002 visit002 column=visitinfo:visittime, timestamp=1454231427285, value=2015-07-26 11:11:00 visit003 column=personinfo:address, timestamp=1454232027650, value=guangzhou visit003 column=personinfo:empi, timestamp=1454231518425, value=empi003 visit003 column=personinfo:name, timestamp=1454231527200, value=wangwu visit003 column=personinfo:patid, timestamp=1454231549310, value=pat002 visit003 column=personinfo:sex, timestamp=1454231537129, value=female visit003 column=visitinfo:visitdocid, timestamp=1454231491395, value=doc002 visit003 column=visitinfo:visitdocname, timestamp=1454231479591, value=Dr. Li visit003 column=visitinfo:visitid, timestamp=1454231462038, value=visit003 visit003 column=visitinfo:visittime, timestamp=1454231439570, value=2015-07-27 13:13:00 3 row(s) in 0.1660 seconds hbase(main):008:0> scan 'patientvisit',COLUMNS=>'personinfo' ROW COLUMN+CELL visit001 column=personinfo:address, timestamp=1454230894972, value=shanghai xxx road visit001 column=personinfo:birthday, timestamp=1454227896430, value=1999-12-31 visit001 column=personinfo:empi, timestamp=1454227855358, value=empi001 visit001 column=personinfo:name, timestamp=1454227867312, value=zhangsan visit001 column=personinfo:patid, timestamp=1454230911137, value=pat001 visit001 column=personinfo:sex, timestamp=1454227875809, value=male visit002 column=personinfo:address, timestamp=1454231323278, value=beijing visit002 column=personinfo:empi, timestamp=1454231239104, value=empi002 visit002 column=personinfo:name, timestamp=1454231253067, value=lisi visit002 column=personinfo:patid, timestamp=1454231282131, value=pat002 visit002 column=personinfo:sex, timestamp=1454231269942, value=male visit003 column=personinfo:address, timestamp=1454232027650, value=guangzhou visit003 column=personinfo:empi, timestamp=1454231518425, value=empi003 visit003 column=personinfo:name, timestamp=1454231527200, value=wangwu visit003 column=personinfo:patid, timestamp=1454231549310, value=pat002 visit003 column=personinfo:sex, timestamp=1454231537129, value=female 3 row(s) in 0.0610 seconds hbase(main):011:0> scan 'patientvisit',COLUMNS=>'personinfo:name' ROW COLUMN+CELL visit001 column=personinfo:name, timestamp=1454227867312, value=zhangsan visit002 column=personinfo:name, timestamp=1454231253067, value=lisi visit003 column=personinfo:name, timestamp=1454231527200, value=wangwu 3 row(s) in 0.0240 seconds hbase(main):012:0> scan 'patientvisit',COLUMNS=>['personinfo:name','visitinfo:visitdocname'] ROW COLUMN+CELL visit001 column=personinfo:name, timestamp=1454227867312, value=zhangsan visit001 column=visitinfo:visitdocname, timestamp=1454230997776, value=Dr. Yang visit002 column=personinfo:name, timestamp=1454231253067, value=lisi visit002 column=visitinfo:visitdocname, timestamp=1454231389655, value=Dr. Yang visit003 column=personinfo:name, timestamp=1454231527200, value=wangwu visit003 column=visitinfo:visitdocname, timestamp=1454231479591, value=Dr. Li 3 row(s) in 0.0230 seconds