标签:
问题导读:
01
02
03
04
05
06
07
08
09
10
11
12
13
|
$hbase
shell Version
0.92.0, r1231986, Mon Nov 16 13:16:35 UTC 2015 $hbase(main):001:0
>create ‘prodFocus‘
, ‘degeeInfo‘ 0
row(s) in
0.1200 seconds hbase(main):008:0>
describe ‘prodFocus‘ DESCRIPTION
ENABLED ‘prodFocus‘ ,
{NAME => ‘cf‘ ,
DATA_BLOCK_ENCODING => true ‘NONE‘ ,
BLOOMFILTER => ‘ROW‘ ,
REPLICATION_SCOPE => ‘0‘ ,
VERSIONS => ‘1‘ ,
COMPRESSION => ‘NONE‘ ,
MIN_VE RSIONS
=> ‘0‘ ,
TTL => ‘2147483647‘ ,
KEEP_DELETED_CE LLS
=> ‘false‘ ,
BLOCKSIZE => ‘65536‘ ,
IN_MEMORY => ‘false‘ ,
BLOCKCACHE => ‘true‘ }
1
row(s) in
0.0740 seconds |
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
|
static
{ Configuration
HBASE_CONFIG = new Configuration(); HBASE_CONFIG. set (“hbase.zookeeper.quorum”,“192.168.2.6”);
HBASE_CONFIG. set (“hbase.zookeeper.property.clientPort”,“2181”);
cfg
= new HBaseConfiguration(HBASE_CONFIG); } HTablePool
pool = new HTablePool(); HTableInterface
prodTable = pool.getTable(“prodFocus”); Scan
a = new Scan(); a.addFamily(Bytes.toBytes(“degreeInfo”)); a.setStartRow(Bytes.toBytes(“QQ121102645”)); ResultScanner
results = prodTable.getScanner(a); List<KeyValue>
list = result.list(); List<String>
followGamess = new ArrayList<String>(); for (Result
r:results){ KeyValue
kv = iter.next();; String
game =kv.get(1]; followGames.add(user); } |
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
|
HTablePool
pool = new HTablePool(); HTableInterface
prodTable = pool.getTable(“prodFocus”); Scan
a = new Scan(); a.addFamily(Bytes.toBytes(“degreeInfo”)); a.setStartRow(Bytes.toBytes(“QQ121102645”)); ResultScanner
results = prodTable.getScanner(a); List<Integer>
degrees = new ArrayList<Integer>(); List<KeyValue>
list = results.list(); Iterator<KeyValue>
iter = list.iterator(); String
gameNm =“3CountryBattle”; while (iter.hasNext()){ KeyValue
kv = iter.next(); if (gameNm.equals(Bytes.toString(kv.getKey()))){ return
true ; } } prodTable.close(); |
01
02
03
04
05
06
07
08
09
10
11
|
HTablePool
pool = new HTablePool(); HTableInterface
prodTable = pool.getTable(“prodFocusV2”); String
userNm =“QQ121102645”; String
gameNm =“3CountryBattles”; Get
g = new Get(Bytes.toBytes(userNm+”$”+gameNm)); g.addFamily(Bytes.toBytes(“degreeInfo”)); Result
r = prodTable.get(g); if (!r.isEmpty()){ return
true ; } table.close(); |
在 developerWorks 大数据和分析专区,了解关于大数据的更多信息,获取技术文档、how-to 文章、培训、下载、产品信息以及其他资源。
标签:
原文地址:http://blog.csdn.net/zhongqi2513/article/details/52866949