我正在运行一个map reduce作业,现在我想在hbase中输入值。我通过stdin流式传输map reduce作业中的值,并使用python脚本在happybase上插入(放置)行。
我遇到了不同类型的问题,从python中执行put。据我所知,最近的问题似乎与库兼容性问题有关。错误日志显示了itermitems的问题。happybase手册提到了排序查询所需的额外python库,从python 2.7版本开始(我运行的是2.7.6),这些库是不必要的
有人遇到过类似的问题吗?它们可以很容易地修复吗?或者你会建议使用不同的界面吗?
更多详细信息
我安装了hadoop(2.6.0)和hbase(0.98.10-2015年2月5日),并在单机配置中运行。他们被启动了。我可以通过shell与hbase接口,创建表,输入值,并扫描它们。
我可以通过happybase扫描和打印python中的表,这至少表明连接是有效的。但看跌期权总是失败。这个简短的例子说明了问题:
为了这个例子,我的表被称为test(在hbaseshell中创建)。它有一列f1。
hbase(main)> create 't1','f1'
hbase(main)> put 't1','1','f1','hello'
现在python:
>>> import happybase
>>> connection = happybase.Connection('localhost')
>>> table = connection.table('t1')
>>> print(table.row('1')) # {'f1:': 'hello'}
>>> table.put('2',{'f1','hey'}) # fails, see log
更多细节:
节俭正在运行。
# hbase thrift start -threadpool
hduser@box> hbase -version
java版本"1.8.0_31"Java(TM)SE运行时环境(版本1.8.0_31-b13)Java HotSpot(TM)64位服务器虚拟机(内部版本25.31-b07,混合模式)
错误日志:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-15-56dab4cd31ef> in <module>()
----> 1 table.put('2',{'f1','hey'})
/usr/local/lib/python2.7/dist-packages/happybase/table.pyc in put(self, row, data, timestamp, wal)
437 """
438 with self.batch(timestamp=timestamp, wal=wal) as batch:
--> 439 batch.put(row, data)
440
441 def delete(self, row, columns=None, timestamp=None, wal=True):
/usr/local/lib/python2.7/dist-packages/happybase/batch.pyc in put(self, row, data, wal)
81 value=value,
82 writeToWAL=wal)
---> 83 for column, value in data.iteritems())
84
85 self._mutation_count += len(data)
AttributeError: 'set' object has no attribute 'iteritems'
Happybase作者在这里。
代码中的这一行包含一个错误:
>>> table.put('2',{'f1','hey'}) # fails, see log
{'f1', 'hey'}
是一个集合文字,而您应该传递一个dict。我想你是这个意思吧?
>>> table.put('2',{'f1': 'hey'})
try:
table.put('2',{'f1:':'hey'})
如果你有f1的子列,比如col1,col2,你可以指定特定的子列也是
table.put('2',{'f1:col1':'hey'})
有关更多信息,请访问:
https://happybase.readthedocs.io/en/happybase-0.4/tutorial.html