【HBase】1009-HBase的协处理器(coprocessor)统计行数
来源:互联网 发布:知乎大家都用真名吗 编辑:程序博客网 时间:2024/05/18 20:04
引入Hbase中的Coprocessor 的原因
HBase作为列族数据库无法建立“二级索引”,难以执行求和、计数、排序等操作。为解决这些问题,HBase0.92 之后引入协处理器(Coprocessor),实现一些新特性,能够轻易建立二次索引、复杂过滤器、以及访问控制。
参考: http://blog.csdn.net/lifuxiangcaohui/article/details/39991183
协处理器两个插件
(1)观察者(observer)
提供三种观察者接口:
RegionObserver:提供客户端的数据操纵事件钩子:Get、Put、Delete、Scan等。
WALObserver:提供WAL相关操作钩子。
MasterObserver:提供DDL-类型的操作钩子。如创建、删除、修改数据表等。
(2)终端(endpoint)
EndPoint协处理器
(1)ObServer协处理器:允许集群在正常的客户端操作过程中可以有不同的行表现!
(2)EndPoint协处理器:允许你扩展集群能力,对客户端应用开放新的运行命令,在RegionServer上执行
HBase的协处理器(coprocessor)统计函数
(1)在使用HBase的协处理器(coprocessor)之前,需要启动协处理器,有两种方案。
方案1:启动全局aggregation,能过操纵所有的表上的数据。通过修改hbase-site.xml这个文件来实现
方案2:启用表aggregation,只对特定的表生效。通过HBase Shell 来实现
create 'stu', {NAME => 'info', VERSIONS => 5}
1、disable指定表。
hbase> disable 'stu'
2、添加aggregation
hbase>alter 'stu', METHOD => 'table_att','coprocessor'=>'|org.apache.hadoop.hbase.coprocessor.AggregateImplementation||'
3、重启指定表
hbase> enable 'stu'
(2)JAVA代码统计表中列族的行数
HBase的协处理器案例
协处理器其中的一个作用是使用Observer创建二级索引
(1)在使用HBase的协处理器(coprocessor)之前,需要启动协处理器,有两种方案。
方案1:启动全局aggregation,能过操纵所有的表上的数据。通过修改hbase-site.xml这个文件来实现
<property> <name>hbase.coprocessor.user.region.classes</name> <value>org.apache.hadoop.hbase.coprocessor.AggregateImplementation</value></property>
方案2:启用表aggregation,只对特定的表生效。通过HBase Shell 来实现
create 'stu', {NAME => 'info', VERSIONS => 5}
1、disable指定表。
hbase> disable 'stu'
2、添加aggregation
hbase>alter 'stu', METHOD => 'table_att','coprocessor'=>'|org.apache.hadoop.hbase.coprocessor.AggregateImplementation||'
3、重启指定表
hbase> enable 'stu'
(2)JAVA代码统计表中列族的行数
public class MyAggregationClient { public static void main(String[] args) throws Throwable { Configuration customConf = new Configuration(); customConf.set("hbase.rootdir", "hdfs://mycluster:8020/hbase"); customConf.setStrings("hbase.zookeeper.quorum", "mycluster:2181"); // 提高RPC通信时长 customConf.setLong("hbase.rpc.timeout", 600000); // 设置Scan缓存 customConf.setLong("hbase.client.scanner.caching", 1000); // 默认为9000毫秒 customConf.set("zookeeper.session.timeout", "180000"); Configuration configuration = HBaseConfiguration.create(customConf); AggregationClient aggregationClient = new AggregationClient(configuration); Scan scan = new Scan(); // 指定扫描列族,唯一值 scan.addFamily(Bytes.toBytes("info")); long rowCount = aggregationClient.rowCount(TableName.valueOf("stu"),new LongColumnInterpreter(), scan); System.out.println("row count is " + rowCount); }}
HBase的协处理器案例
协处理器其中的一个作用是使用Observer创建二级索引
0 0
- 【HBase】1009-HBase的协处理器(coprocessor)统计行数
- HBase学习之三: hbase filter(过滤器)和coprocessor(协处理器)统计行数的简单应用
- hbase协处理器coprocessor 统计行数量 案例
- hbase filter(过滤器)和coprocessor(协处理器)统计行数的简单应用
- Hbase协处理器(Coprocessor)
- HBase--Coprocessor协处理器
- HBase Coprocessor 协处理器
- Hbase 协处理器 Coprocessor
- Hbase协处理器coprocessor
- HBase 协处理器统计行数
- 使用HBase Coprocessor协处理器
- org.apache.hadoop.hbase.coprocessor.AggregateImplementation 来统计hbase表的行数
- org.apache.hadoop.hbase.coprocessor.AggregateImplementation 来统计表的行数
- org.apache.hadoop.hbase.coprocessor.AggregateImplementation 来统计表的行数
- HBase Coprocessor的分析
- hbase coprocessor的分析
- hbase的coprocessor使用
- HBASE coprocessor 的分析
- PAT 1021 个位数统计
- 查看SQLSERVER当前正在执行的sql信息
- Notepad++ 使用技巧
- 动态规划0-1背包问题
- ubuntu 14.04 安装交叉编译工具链arm-none-linux-gnueabi
- 【HBase】1009-HBase的协处理器(coprocessor)统计行数
- ImageView加载gif图片
- 关于php集成环境mysql wamp 修改密码后phpMyAdmin拒绝访问解决办法
- Android-《第一行代码》阅读收获
- 工厂模式之DAO设计
- PyTagcloud工具使用——显示中文词云
- JS代码的window.location属性详解
- OC 内存管理概念以及范围
- 开启另一个Activity