`
jack_boy
  • 浏览: 135410 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

happybase访问Hbase

阅读更多
Java以为的语言访问Hbase都是通过thrift进行访问的,因此需要在Hbase上开启thrift服务
如果用
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"



参考:
http://hbase.apache.org/book/thrift.html#example-filter-strings
https://github.com/wbolster/happybase/blob/master/tests/test_api.py
0
5
分享到:
评论

相关推荐

    happybase查询hbase

    博客配套文件,详细演示了python通过happybase查询hbase的代码使用。

    Python访问Hbase的库文件

    Hbase.py 和 ttypes.py 用来替换原有的 hbase包里的文件,解决 from hbase import Hbase 报错问题。

    java api 访问hbase demo(Maven)

    java api 访问hbase demo(Maven) 详情请看:http://blog.csdn.net/wild46cat/article/details/53288537

    java访问hbase所需的jar包

    hbase所需的jar包,HBase是建立在Hadoop文件系统之上的分布式面向列的数据库。它是一个横向扩展的开源项目。它提供对数据的随机实时读/写访问,并作为Hadoop文件系统的一部分。

    java访问Hbase数据库Demo

    java访问Hbase数据库实用小例子,增删改查创建表,教你轻松解决hbase

    通过thrift使用c++访问hbase

    本文档详细说明了Linux和windows系统下配置thrift环境和hbaseC++客户端的使用。

    go thrift访问hbase

    博客配套文件,详细演示了go通过thrift1和thrift2接口访问hbase的方法,并给出了批量访问的简单封装接口。

    C# Rest方式访问Hbase

    C# 使用Microsoft.HBase.Client类库以Rest方式访问HBase数据库。实现了基本的增、删、改、查操作。方便新手入门学习。同时提供了Microsoft.HBase.Client源码。这源码是微软提供的,微软已经拥抱开源。

    python通过thrift访问hbase.docx

    python通过thrift访问hbase.docx

    spark访问hbase

    spark本地模式访问hbase表进行map reduce操作

    java 访问Hbase 使用的jar包 和 hbase-0.20.6 api

    Java Hbase jar api hbase-0.20.6.jar hadoop-core-0.20.1.jar commons-logging-1.1.1.jar zookeeper-3.3.0.jar log4j-1.2.91.jar

    HBase使用的jar包

    这是hadoop项目中,使用Hbase进行明细查询所需要的jar包

    HbaseTemplate 操作hbase

    java 利用 sping-data-hadoop HbaseTemplate 操作hbase find get execute 等方法 可以直接运行

    centos thrift2 c++ 访问hbase(2.2.3版本)

    通过thrift2方式调用hbase的c++代码,包含Makefile、DemoClient.cpp以及gen-cpp编译好的。直接make生成DemoClient程序,执行./DemoClient master(域名) 9090(默认端口号)

    Hbase权威指南(HBase: The Definitive Guide)

     ■使用本地java客户端,或者通过提供了rest、avro和thrift应用编程接口的网关服务器来访问hbase  ■了解hbase架构的细节,包括存储格式、预写日志、后台进程等等  ■在hbase中集成用于海量并行数据处理任务的...

    pinpoint的hbase初始化脚本hbase-create.hbase

    搭建pinpoint需要的hbase初始化脚本hbase-create.hbase

    HBase(hbase-2.4.9-bin.tar.gz)

    HBase(hbase-2.4.9-bin.tar.gz)是一个分布式的、面向列的开源数据库,该技术来源于 Fay Chang 所撰写的Google论文“Bigtable:一个结构化数据的分布式存储系统”。就像Bigtable利用了Google文件系统(File System...

    HBase数据库设计.doc

    1. HBase有哪些基本的特征? 1 HBase特征: 1 2. HBase相对于关系数据库能解决的问题是什么? 2 HBase与关系数据的区别? 2 HBase与RDBMS的区别? 2 3. HBase的数据模式是怎么样的?即有哪些元素?如何存储?等 3 1...

    HBase权威指南

    使用本地java客户端,或者通过提供了rest、avro和thrift应用编程接口的网关服务器来访问hbase;了解hbase架构的细节,包括存储格式、预写日志、后台进程等;在hbase中集成mapreduce框架;了解如何调节集群、设计模式...

Global site tag (gtag.js) - Google Analytics