Phoenix 使用sql查询hbase

http://blog.csdn.net/morning_pig/article/details/8585088

Phoenix优势:

1.动态的将一个查询转换为多个scan并行执行,使用startRowKey和stopRowKey进行拆分;

2.使用hbase0.94版本及之后的coprocessor特性;

3.Filter。


1 Phoenix概览

         Phoenixis a SQL layer over HBase, delivered as a client-embedded JDBC driver, poweringthe HBase use cases at Salesforce.com. Phoenix targets low-latency queries(milliseconds), as opposed to batch operation via map/reduce. To see what'ssupported, go to our languagereference guide, and read more on ourwiki.

2 Phoenix安装

To install a pre-built phoenix, use these directions:

  • Download and expand the latest phoenix-[version]-install.tar from download page
  • Add the phoenix-[version].jar to the classpath of every HBase region server. An easy way to do this is to copy it into the HBase lib directory.
  • Restart all region servers.
  • Add the phoenix-[version]-client.jar to the classpath of any Phoenix client.

Alternatively, you can build it yourself using maven byfollowing these buildinstructions.

3 Phoenix测试

测试集群

        192.168.1.11

        192.168.1.12

测试版本

         HbaseVersion 0.94.2.21

         Phoenixv 1.0

sql语句

        CREATETABLE IF NOT EXISTS STOCK_SYMBOL (SYMBOL VARCHAR NOT NULL PRIMARY KEY, COMPANYVARCHAR);

        UPSERT INTOSTOCK_SYMBOL VALUES ('CRM','SalesForce.com');

        SELECT * FROMSTOCK_SYMBOL;

执行

        #java -jar phoenix-1.0-client.jar hadoopnode2.qyops.com test.sql

结果

         SYMBOL     COMPANY   

--------------------

CRM        SalesForce.com

表结构

hbase(main):036:0> describe 'STOCK_SYMBOL'

DESCRIPTION                                                      ENABLED                          

 {NAME => 'STOCK_SYMBOL',coprocessor$4 => 'phoenix.jar|com.sales true   

 force.phoenix.join.HashJoiningRegionObserver|1|',coprocessor$3        

 =>'phoenix.jar|com.salesforce.phoenix.coprocessor.GroupedAggreg       

 ateRegionObserver|1|',coprocessor$2 => 'phoenix.jar|com.salesfo       

 rce.phoenix.coprocessor.UngroupedAggregateRegionObserver|1|',co       

 processor$1 =>'phoenix.jar|com.salesforce.phoenix.coprocessor.S       

 canRegionObserver|1|',FAMILIES => [{NAME => '_0', DATA_BLOCK_EN       

 CODING => 'FAST_DIFF',BLOOMFILTER => 'NONE', REPLICATION_SCOPE        

 => '0', VERSIONS =>'3', COMPRESSION => 'NONE', MIN_VERSIONS =>        

 '0', TTL => '2147483647',KEEP_DELETED_CELLS => 'true', BLOCKSIZ       

 E => '65536', IN_MEMORY=> 'false', ENCODE_ON_DISK => 'true', BL       

 OCKCACHE => 'true'}]}                       

1 row(s) in 0.0400 seconds


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值