不理解 Hbase Python API 中的行键
Not understanding the row-key in Python API of Hbase
我有一个 hbase table (customers
),格式如下:
hbase(main):004:0> scan 'customers'
ROW COLUMN+CELL
4000001 column=customers_data:age, timestamp=1424123059769, value=55
4000001 column=customers_data:firstname, timestamp=1424123059769, value=Kristina
4000001 column=customers_data:lastname, timestamp=1424123059769, value=Chung
4000001 column=customers_data:profession, timestamp=1424123059769, value=Pilot
我尝试使用 python API http://happybase.readthedocs.org/en/latest/:
提取这些数据
import happybase
connection = happybase.Connection('localhost',autoconnect=False)
connection.open()
table = connection.table('customers')
print table.families()
row = table.row('ROW')
print row
它将 table.families()
打印为:
{'customers_data': {'block_cache_enabled': True,
'bloom_filter_nb_hashes': 0,
'bloom_filter_type': 'ROW',
'bloom_filter_vector_size': 0,
'compression': 'NONE',
'in_memory': False,
'max_versions': 1,
'name': 'customers_data:',
'time_to_live': 2147483647}}
但是它在行中打印了 {},什么也没有。我只是对我对 hbase table 中的行键值的理解感到困惑。对如何使用 python API 从 hbase table 获取数据有什么建议吗?谢谢。
您的 rowkey 是“4000001”而不是 "ROW"。
我有一个 hbase table (customers
),格式如下:
hbase(main):004:0> scan 'customers'
ROW COLUMN+CELL
4000001 column=customers_data:age, timestamp=1424123059769, value=55
4000001 column=customers_data:firstname, timestamp=1424123059769, value=Kristina
4000001 column=customers_data:lastname, timestamp=1424123059769, value=Chung
4000001 column=customers_data:profession, timestamp=1424123059769, value=Pilot
我尝试使用 python API http://happybase.readthedocs.org/en/latest/:
提取这些数据import happybase
connection = happybase.Connection('localhost',autoconnect=False)
connection.open()
table = connection.table('customers')
print table.families()
row = table.row('ROW')
print row
它将 table.families()
打印为:
{'customers_data': {'block_cache_enabled': True,
'bloom_filter_nb_hashes': 0,
'bloom_filter_type': 'ROW',
'bloom_filter_vector_size': 0,
'compression': 'NONE',
'in_memory': False,
'max_versions': 1,
'name': 'customers_data:',
'time_to_live': 2147483647}}
但是它在行中打印了 {},什么也没有。我只是对我对 hbase table 中的行键值的理解感到困惑。对如何使用 python API 从 hbase table 获取数据有什么建议吗?谢谢。
您的 rowkey 是“4000001”而不是 "ROW"。