- 浏览: 139751 次
- 性别:
- 来自: 北京
-
文章分类
最新评论
-
h416373073:
正遇到了此问题不知如何解决, 多谢分享
solr + Tomcat安装 -
jack_boy:
blackproof 写道原来也用过es,超费内存,不如sol ...
ElasticSearch中文分词ik安装 -
blackproof:
原来也用过es,超费内存,不如solar好用
ElasticSearch中文分词ik安装
Java以为的语言访问Hbase都是通过thrift进行访问的,因此需要在Hbase上开启thrift服务
如果用
启动服务,默认用的是thrift2,在用happybase的时候会出现版本不兼容的问题,因此用thrift来启动
happybase使用很简单,与hbase shell 用法类似
主要的用法都很简单,在其官方网站happybase上都有。
这里主要记录一个错误。
源代码:
改为:
g = table.scan(filter="SingleColumnValueFilter('f', 'id', =, 'substring:852223')", limit=10)
程序正确运行,输出结果
参考:
http://hbase.apache.org/book/thrift.html#example-filter-strings
https://github.com/wbolster/happybase/blob/master/tests/test_api.py
如果用
hbase-deamon.sh start
启动服务,默认用的是thrift2,在用happybase的时候会出现版本不兼容的问题,因此用thrift来启动
hbase thrift -p 9090 start
happybase使用很简单,与hbase shell 用法类似
主要的用法都很简单,在其官方网站happybase上都有。
这里主要记录一个错误。
File "test.py", line 21, in <module> for k, d in g: File "/home/jack_boy/product/lib/python2.6/site-packages/happybase/table.py", line 374, in scan self.name, scan, {}) File "/home/jack_boy/product/lib/python2.6/site-packages/happybase/hbase/Hbase.py", line 1919, in scannerOpenWithScan return self.recv_scannerOpenWithScan() File "/home/jack_boy/product/lib/python2.6/site-packages/happybase/hbase/Hbase.py", line 1937, in recv_scannerOpenWithScan raise x thrift.Thrift.TApplicationException: Internal error processing scannerOpenWithScan
源代码:
import happybase import sys #reload(sys) #sys.setdefaultencoding('utf-8') connection = happybase.Connection('192.168.1.110') #connection.open() #print connection.tables() table = connection.table('testTable') g = table.scan(filter="SingleColumnValueFilter('f', 'id', =, '852223')", limit=10) for k, d in g: print k, d
改为:
g = table.scan(filter="SingleColumnValueFilter('f', 'id', =, 'substring:852223')", limit=10)
程序正确运行,输出结果
引用
The general syntax of a comparator is: ComparatorType:ComparatorValue
The ComparatorType for the various comparators is as follows:
BinaryComparator - binary
BinaryPrefixComparator - binaryprefix
RegexStringComparator - regexstring
SubStringComparator - substring
The ComparatorValue can be any value.
Example 12.3. Example 1
>, 'binary:abc' will match everything that is lexicographically greater than "abc"
Example 12.4. Example 2
=, 'binaryprefix:abc' will match everything whose first 3 characters are lexicographically equal to "abc"
Example 12.5. Example 3
!=, 'regexstring:ab*yz' will match everything that doesn't begin with "ab" and ends with "yz"
Example 12.6. Example 4
=, 'substring:abc123' will match everything that begins with the substring "abc123"
The ComparatorType for the various comparators is as follows:
BinaryComparator - binary
BinaryPrefixComparator - binaryprefix
RegexStringComparator - regexstring
SubStringComparator - substring
The ComparatorValue can be any value.
Example 12.3. Example 1
>, 'binary:abc' will match everything that is lexicographically greater than "abc"
Example 12.4. Example 2
=, 'binaryprefix:abc' will match everything whose first 3 characters are lexicographically equal to "abc"
Example 12.5. Example 3
!=, 'regexstring:ab*yz' will match everything that doesn't begin with "ab" and ends with "yz"
Example 12.6. Example 4
=, 'substring:abc123' will match everything that begins with the substring "abc123"
参考:
http://hbase.apache.org/book/thrift.html#example-filter-strings
https://github.com/wbolster/happybase/blob/master/tests/test_api.py
发表评论
-
fedora live use
2015-11-29 09:42 543vesamenu.c32:not a COM32R image ... -
远程拷贝文件
2015-05-08 09:57 482把机器上指定后缀名的代码,一股脑拷贝的别的机器上,lbin是主 ... -
Hive去重复数据
2015-03-23 15:33 7760Hive数据去重 insert overwrite table ... -
Mongodb C++ driver中的逻辑操作“或”
2015-01-28 15:17 2895Mongodb中的查询操作比 ... -
python中的生成器
2015-01-11 10:47 1191Python中的生成器 1. 什 ... -
ElasticSearch中文分词ik安装
2015-01-02 22:59 20206http://www.elasticsearch.org/ov ... -
ssh 无密码登陆
2014-12-26 14:03 722用$ssh-keygen -t rsa生成密钥与公钥 将.ss ... -
vim 非贪婪匹配
2014-11-13 15:14 2962vim的模式匹配使用正则表达式 .*是贪婪匹配,会匹配最多的字 ... -
[转]vim-airline in xshell or putty or MobaXterm
2014-11-11 13:36 6448windows下使用Xshell,putty或者是MobaXt ... -
跟踪同一个系统中不同进程的系统调用
2014-09-24 14:16 1262跟踪同一个系统中不同进程的系统调用 在编写多线程的程序时,偶 ... -
easy_install 报错
2013-11-26 10:32 1106easy_install -U distribute 后执行 ... -
python中的@
2013-11-15 11:31 0python中的@符号 在python中有一个@符号,起到装 ... -
LVS+keepalived配置备忘
2013-07-18 14:47 2920LVS + keepalived实现负载均衡的文档很多,这里不 ... -
Structs in ruby
2012-12-11 14:33 1225Ruby中的Struct是一个特殊的类,只(仅仅只)用来存取数 ... -
ruby mix-in
2012-12-10 16:49 1812Ruby mix-in Ruby 是一门面向对象的语言,所有一 ... -
gnome-shell安装
2012-09-04 12:54 15551. 安装gnome3 tweak tool工具,用于gnom ... -
源码编译安装mysql
2012-08-30 14:52 1480由于开发环境中的mysql有别的用处,为了不影响开发换进需要源 ... -
Linux网络参数优化
2012-08-21 18:47 2163net.ipv4.tcp_tw_reuse = 1 表示开启重 ... -
typedef定字符串数组类型
2012-07-24 14:06 1156typedef char char_array[1024]; ... -
tmux使用(程序员适用)
2012-07-12 16:53 32707tmux基本使用 tmux是一个优秀的终端复用软件,即 ...
相关推荐
标题:"Python访问Hbase的库文件:Hbase.py与ttypes.py的替代解决方案" 在大数据处理的世界里,Apache HBase是一种分布式的、面向列的NoSQL数据库系统,特别适合于存储大量半结构化数据。HBase的分布式特性使其在...
`happybase`是一个基于`thriftpy`的HBase Python客户端,提供了简单易用的API。使用`happybase`,我们可以创建连接、创建表、插入数据、查询数据等。 例如,一个简单的`conn_happy.py`脚本可能包含以下内容: ```...
HBase是Apache Hadoop生态系统中的一个分布式、面向列的数据库,它提供实时访问大数据的能力。它支持海量数据存储,同时提供了快速随机读取性能,非常适合处理半结构化的数据。 Python连接HBase的过程主要分为以下...
在使用Python访问HBase之前,我们需要安装必要的Python库。主要的依赖库包括`happybase`,它是Python的HBase Thrift客户端。你可以使用pip进行安装: ``` pip install happybase ``` 2. **连接HBase** 连接...
7. **安全与权限**:如果需要,可以配置HBase的安全机制,如Kerberos,以确保数据访问的安全性。 通过WhaleAI的自动化部署方案,开发者可以更专注于人工智能和大数据应用的开发,而不是花费大量时间在基础架构的...
HBase是一个分布式的、面向列的NoSQL数据库,它构建在Hadoop之上,提供实时访问大规模数据集的能力。然而,由于HBase主要是为Java设计的,非Java语言如Python需要通过特定的接口来实现连接,这就是Thrift接口的作用...
**HBase**:Apache HBase是一个开源的、分布式的、版本化的NoSQL数据库,它建在Hadoop文件系统(HDFS)之上,提供高吞吐量的数据访问。HBase适合于存储非结构化或半结构化的松散数据,例如日志和时间序列数据。 **...
Python提供了诸如`psycopg2`库用于与PostgreSQL交互,`happybase`库则用于连接和操作HBase。这些库可以帮助开发人员方便地构建数据管道,将数据从PostgreSQL的热存储迁移到HBase的冷存储,或者根据业务需求进行数据...