RHive:集成R和Hive
2012-04-20 11:55
316 查看
https://github.com/nexr/RHive/wiki/UserGuides
RHive是一个R包,在R环境中集成hive。通过使用RHive可以在R环境中写HQL(HiveQL),将R的对象传入hive中,在hive中进行计算。在rHive中
小数据集在R中执行,大数据集在hive中运行。
越来越多的企业收集了海量细节数据,需要TB或者PB级的数据存储以及从海量数据中发现知识。目前,人们主要关注R统计分析程序,并且越来越熟悉R开发。但是,R对于海量数据处理存在一些弊端。一些人,通过抽样技术来处理海量数据,这样很有可能导致丢失数据信息。Hadoop可以处理这样的海量数据,而数据分析师缺少使用hadoop开发能力。然而,数据分析师一般都很熟悉SQL,进行数据处理。正是基于此种情况,Rhive作为大数据的一种解决方案,应运而生,在R和Hive之间建立桥梁。
RHive架构
![](http://s14.sinaimg.cn/middle/61c463094bdb04895c5bd&690)
API
Rhive API for R
rhive.connect : connect to hive 连接hive
rhive.query : execute hive query in R 在R中执行hive查询
rhive.export : export only R function to cluster Rserve
rhive.exportAll : export all R functions and R objects to cluster Rserve
rhive.close : close hive connection
rhive.list.table : get hive table list
rhive.desc.table : get Hive table information
rhive.load.table : retrieve table data from hive to R
RHive UDF、UDAF for hive
通过R函数处理hdfs
R : R is UDF. For every record, this function from Hive calls an exported R function.
RA : RA is UDAF. This function uses exported R and hive query to aggregate data.
unfold : unfold is UDTF. This function takes return data of R and unfolds them into several columns.
expand : expand is UDTF.
实例
rhive.connect(hive-hostip)
rhive.query("select * from emp")
coefficient <- 1.1
scoring <- function(sal) {
coefficient * sal
}
rhive.export('scoring')
rhive.query("select R('scoring',col_sal,0.0) from emp")
hsum <- function(prev,sal) {
c(prev[1] + sal[1])
}
hsum.partial <- function(agg_sal) {
agg_sal
}
hsum.merge <- function(prev, agg_sal) {
c(prev[1] + agg_sal[1])
}
hsum.terminate <- function(agg_sal) {
agg_sal
}
rhive.exportAll('hsum',rserve-list)
rhive.query(”select RA('hsum',col_sal) from emp group by empno")
emp <- rhive.desc.table(emp)
colnames(emp)
RHive是一个R包,在R环境中集成hive。通过使用RHive可以在R环境中写HQL(HiveQL),将R的对象传入hive中,在hive中进行计算。在rHive中
小数据集在R中执行,大数据集在hive中运行。
越来越多的企业收集了海量细节数据,需要TB或者PB级的数据存储以及从海量数据中发现知识。目前,人们主要关注R统计分析程序,并且越来越熟悉R开发。但是,R对于海量数据处理存在一些弊端。一些人,通过抽样技术来处理海量数据,这样很有可能导致丢失数据信息。Hadoop可以处理这样的海量数据,而数据分析师缺少使用hadoop开发能力。然而,数据分析师一般都很熟悉SQL,进行数据处理。正是基于此种情况,Rhive作为大数据的一种解决方案,应运而生,在R和Hive之间建立桥梁。
RHive架构
API
Rhive API for R
rhive.connect : connect to hive 连接hive
rhive.query : execute hive query in R 在R中执行hive查询
rhive.export : export only R function to cluster Rserve
rhive.exportAll : export all R functions and R objects to cluster Rserve
rhive.close : close hive connection
rhive.list.table : get hive table list
rhive.desc.table : get Hive table information
rhive.load.table : retrieve table data from hive to R
RHive UDF、UDAF for hive
通过R函数处理hdfs
R : R is UDF. For every record, this function from Hive calls an exported R function.
RA : RA is UDAF. This function uses exported R and hive query to aggregate data.
unfold : unfold is UDTF. This function takes return data of R and unfolds them into several columns.
expand : expand is UDTF.
实例
rhive.connect(hive-hostip)
rhive.query("select * from emp")
coefficient <- 1.1
scoring <- function(sal) {
coefficient * sal
}
rhive.export('scoring')
rhive.query("select R('scoring',col_sal,0.0) from emp")
hsum <- function(prev,sal) {
c(prev[1] + sal[1])
}
hsum.partial <- function(agg_sal) {
agg_sal
}
hsum.merge <- function(prev, agg_sal) {
c(prev[1] + agg_sal[1])
}
hsum.terminate <- function(agg_sal) {
agg_sal
}
rhive.exportAll('hsum',rserve-list)
rhive.query(”select RA('hsum',col_sal) from emp group by empno")
emp <- rhive.desc.table(emp)
colnames(emp)
相关文章推荐
- 如何使用Hive集成Solr?
- 伪分布式环境下,Hive0.8.1与HBase0.92.0集成的配置说明
- hive和hbase集成
- Hive与HBase集成
- hue3.9 集成 hive1.1.0
- hive集成kerberos问题1
- 配置安全的Hive集群集成Sentry
- Spark 2.2.1 集成Hive数据仓库的案例与解读
- Centos 安装R 集成 Hadoop、RHive 配置安装手册
- 如何使用Hive集成Solr?
- Hive集成Mysql作为元数据
- SparkSQL与Hive的集成实践(69)
- spark-sql(spark sql cli)客户端集成hive
- hive集成MySql数据库
- hive与hbase集成
- Hive集成HBase(二)
- 如何使用Hive集成Solr?
- Hive与HBase集成及常见问题解决
- Hive2.1.0集成Tez
- 高可用Hadoop平台-集成Hive HAProxy