最近没什么可写的。换工作后开发语言由Java+Shell变成了Scala+Python。
最初的不适期过后,觉得scala和python异常好用。作为一个python新手,纪录下最近常用的3个库。
redis
大部分方法和redis客户端的方法名一样。文档:https://pypi.python.org/pypi/redis
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import redis record_file = open('/home/root/detail.txt', 'a') r = redis.Redis(host='localhost', port=6379) i = 0 for key in r.keys('4fd80*'): i += 1 for device_toke in r.smembers(key): line = key+'\t'+device_toke+'\n' record_file.write(line) if i % 5000 == 0: print i record_file.flush() print i record_file.close() |
happybase
python与hbase交互的库,其原理就是对thrift接口的一层封装。文档:http://happybase.readthedocs.org/en/latest/index.html
官方文档有的地方不太详细,可以参考hbase thrift文档。
初步测试貌似对hbase:meta表的row_prefix以及start_row、end_row属性无法支持,也就是对hbase:meta表只能全表扫描。应该是个bug。
(更多…)