• Apache Drill


    HBase作为Nosql的常用系统之一,在很多大数据应用/平台中广泛使用。例如通过Spark统计后将结果存放到HBase中。通常统计结果还需要进一步和元数据或者字典表关联从而得到最终结果显示,这意味着可能需要将HBase数据跟RDBMS关联查询。
    有两种方案:

    • 通过后台服务分别调用HBase和数据库的数据,通过程序做关联;
    • 或者通过现成的查询引擎用SQL对HBase和数据库数据做Join。
      后一方案使用SQL查询更为通用。SQL-on-HADOOP有很多选择,例如Presto,Phoenix,Drill。目前看下来Presto不支持HBase,Phoenix只支持HBase,只有Drill可作为备选方案。

    Drill连接HBase的issue

    http://blog.sina.com.cn/s/blog_76923bd80102wp99.html

    下载HBASE Shaded Client 替换即可,下载地址: http://mvnrepository.com/artifact/org.apache.hbase/hbase-shaded-client/1.2.3
    hbase-annotations-1.1.3.jar
    hbase-client-1.1.3.jar
    hbase-common-1.1.3.jar
    hbase-protocol-1.1.3.jar
    替换成
    hbase-shaded-client-1.2.3.jar

    HBase表

    hbase(main):001:0> scan 'test'
    ROW                                                   COLUMN+CELL                                                                                                                                                  
     x00001|2018-09-18 12|platform|android                column=f:value, timestamp=1538038106882, value=12                                                                                                            
     x00001|2018-09-18 13|platform|android                column=f:value, timestamp=1538038118094, value=22                                                                                                            
     x00001|2018-09-18 14|platform|android                column=f:value, timestamp=1538038123616, value=22                                                                                                            
     x00001|2018-09-18 15|platform|android                column=f:value, timestamp=1538038134952, value=6                                                                                                             
     x00001|2018-09-18 16|platform|android                column=f:value, timestamp=1538038143047, value=10                                                                                                            
     x00001|2018-09-18 17|platform|android                column=f:value, timestamp=1538038153844, value=30                                                                                                            
    6 row(s) in 0.0390 seconds
    

    postgres

    下载postgres驱动postgresql-9.4.1212.jre7.jar到jars/3rdparty/
    创建新的storage:

    {
      "type": "jdbc",
      "driver": "org.postgresql.Driver",
      "url": "jdbc:postgresql://localhost/postgres",
      "username": "postgres",
      "password": "111111",
      "enabled": true
    }
    

    创建测试表:

    select * from platform
    name    |description    |
    --------|---------------|
    android |google android |
    

    Drill join

    0: jdbc:drill:zk=local> select SPLIT(CONVERT_FROM(t.row_key, 'UTF8'), '|')[0] AS appk,
    . . . . . . . . . . . > SPLIT(CONVERT_FROM(t.row_key, 'UTF8'), '|')[1] AS `hour`,
    . . . . . . . . . . . > SPLIT(CONVERT_FROM(t.row_key, 'UTF8'), '|')[3] AS platform,
    . . . . . . . . . . . > p.`description`,
    . . . . . . . . . . . > cast(t.f.`value` as INT) as x FROM hbase.test t
    . . . . . . . . . . . > inner join pg.test.platform p
    . . . . . . . . . . . > on SPLIT(CONVERT_FROM(t.row_key, 'UTF8'), '|')[3] =  p.`name`;
    +---------+----------------+-----------+-----------------+-----+
    |  appk   |      hour      | platform  |   description   |  x  |
    +---------+----------------+-----------+-----------------+-----+
    | x00001  | 2018-09-18 12  | android   | google android  | 12  |
    | x00001  | 2018-09-18 17  | android   | google android  | 30  |
    | x00001  | 2018-09-18 16  | android   | google android  | 10  |
    | x00001  | 2018-09-18 15  | android   | google android  | 6   |
    | x00001  | 2018-09-18 14  | android   | google android  | 22  |
    | x00001  | 2018-09-18 13  | android   | google android  | 22  |
    +---------+----------------+-----------+-----------------+-----+
    

    性能测试(todo)

  • 相关阅读:
    tomcat 配置ssi
    oracle exp imp 导入 正在跳过表 plsql 导入表 成功终止 数据 被导入
    oracle 创建数据表空间和用户
    移动端开发来个总结吧
    ssl四次握手
    面试-布局
    typeof的原理?
    马上面试了就,复习一下排序
    关于webview无法设置页面标题
    关于let的生命提升
  • 原文地址:https://www.cnblogs.com/luweiseu/p/9715958.html
Copyright © 2020-2023  润新知