根据hbase的key值范围查询:
for key,data in table.scan(row_start=vin+'_'+str(int(start_t)),row_stop=vin+'_'+str(int(end_t)),revers=False,limit=10000,batch_size=1000);#根据时间戳的范围取值
d = data['cf:point']
hbase读写操作:
import time
import json
import happybase
conn=happybase.Connection(host='',port=9090,timeout=None)
def read_hbase():
connection=happybase.Connection(host='',port=9090,timeout=None)
table=connection.table('table_name')
#row_key='20180727111642_1532661402' #根据key读value
#info= table.row(row_key)
#print info
dic={} #存放到字典里
for key,value in table.scan():
dic[key]=value
print len(dic)
send_hbase(dic)
def send_hbase(dic):
table=conn.table('OBD_WIRED_LOC_2018')
tab=table.batch() #创建batch
for key in dic:
tab.put(key,{'cf:point':json.dumps(dic[key])}) #在字典里取值
tab.send() #发送
print 'finish'
read_hbase()