Understanding Cubert Concepts(一)Partitioned Blocks
Understanding Cubert Concepts(一)Partitioned Blocks
Cubert Concepts
对于Cubert,我们要理解其核心的一些概念,比方BLOCK。这些概念也是差别于传统的关系型范式(Pig。Hive)等数据处理流程并使得Cubert在大规模数据下JOIN和Aggregation中取胜的关键因素。
(自己測下来,CUBE的计算效率比Hive高好多倍。
)
BLOCK
Cubert定义了一个BLOCK的概念。分为两种:Partitioned Blocks
& Co-ParitionedBlocks
Hubert将这些Block存储为特殊的格式。叫做Rubix Format
Partitioned Blocks
从字面上来看,叫做分区块。
比方说有一个pageviews
表,有三个列,分别为:memberId(int)
,pagekey(string)
,timestamp(long)
通常在HDFS中,这些数据会被切分为一个个的文件(part-00000.avro, part-00001.avro, etc)
,然后置于某一个文件夹下,这些数据默认是没有被分区
和排序
的。
然而,在Cubert的世界里,我们鼓舞数据
能被更加结构化的存储。
更确切的来说,我们希望数据
能够依据一些分区键
来进行分区成一些数据单元
。这些数据单元
就是Cubert中的Partitioned Blocks, 并且我们希望在每一个Block
中的数据能够在某些列上是有序
的。
PS:这里面涉及到2个概念:PartitionKeys
和 SortKeys
。相应于上述的分区键
和排序键
。
BLOCKGEN
将Raw data
转化为partitioned
和sorted
的data units
的过程称为BLOCKGEN
。
这个是Cubert语法里一个很重要的操作符。
这张图告诉我们:
1. 我们有一个table。2列,JK
和GK
2. BLOCKGEN的过程就是选择一个partitionKey
为JK
,依据这个分区键来对数据块分区。然后对分区后的数据块内部选择GK
作为排序键,来对分区后的数据块
排序。
3. 这样原始数据划分称为了2个partitionedBlocks即BLOCK#1
,BLOCK#2
BLOCKGEN Checklist
作为一个Cubert的开发人员,我们须要遵从4个规范:
1.定义PartitionKeys
从这个数据集的列中选择要依据哪几个列进行分区。
举个来说:
对于pageviews
这个表:
假设指定分区键为memberId
,那么我们能够确定的是。全部memberId=1234
的数据Row
都会被分区到一个partitionedBlock
中去.
2.定义SortKeys(可选)
从这个数据集的列中选择要依据哪几个列进行排序,假设不指定,默认和分区键同样。
Note:这个排序操作不是全局排序,仅仅是在每一个已经分区好的block内部进行局部排序。
举个来说:
还是pageviews
这个表:
我们分区后的数据。能够依据timestamp
这个时间字段。在对block内部
的rows
进行排序。
3.定义代价函数CostFunction
前面一直提到分区。详细怎样来划分block呢?这时候cost function
起到了作用:
- BY ROW 依据数据行数来划分。每一个block中最多油多少行记录。假设超出阀值。则新生成一个
block
。 - BY PARTITION KEYS 依据分区键来划分。每一个block要有指定数目的
partition keys
。假设partition keys
是主键的话,那么和BY ROW
这个cost function
效果相似。 - BY SIZE 依据数据块的大小来划分。单位bytes。
超过指定阀值。就会新建一个block。
4.存储结果数据格式(必须)为RUBIX格式
RUBIX是一种特殊的数据格式。它存储了数据的一些索引细信息
和BLOCKGEN过程须要的一些metadata
Creating Partitioned Blocks(Demo)
Note: BLOCKGEN是一个shuffle command
该程序的分区键:memberId
排序键:timestamp
JOB "our first BLOCKGEN"
REDUCERS 10;
MAP {
data = LOAD "/path/to/data" USING AVRO();
}
// Create blocks that are (a) partitioned on memberId, (b) sorted on timestamp, and
// (c) have a size of 1000 rows
BLOCKGEN data BY ROW 1000 PARTITIONED ON memberId SORTED ON timestamp;
// ALWAYS store BLOCKGEN data using RUBIX file format!
STORE data INTO "/path/to/output" USING RUBIX();
END
因为我们设定了reducer的个数为10,那么将会有10个part-xxx.rbx
文件,e.g.:(part-r-00000.rbx through part-r-00009.rbx
)
Note:每一个rbx文件里能够包括>=1
个block
。
所以不用操心会生产太多的file.
參考
Ps:本文的写作是基于对Cubert官方文档的翻译
和个人对Cubert的理解
综合完毕 :)
原创文章。转载请注明:
转载自:OopsOutOfMemory盛利的Blog, 作者: OopsOutOfMemory
本文链接地址:
注:本文基于署名-非商业性使用-禁止演绎 2.5 中国大陆(CC BY-NC-ND 2.5 CN)协议,欢迎转载、转发和评论。可是请保留本文作者署名和文章链接。
如若须要用于商业目的或者与授权方面的协商。请联系我。
Understanding Cubert Concepts(一)Partitioned Blocks的更多相关文章
- LinkedIn Cubert 实践指南
· LinkedIn Cubert安装指南 · Understanding Cubert Concepts(一)Partitioned Blocks · Understanding Cubert Co ...
- (二)Basic Concepts 基本概念
Basic Concepts There are a few concepts that are core to Elasticsearch. Understanding these concepts ...
- Elasticsearch-->Get Started-->Basic concepts
https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started-concepts.html There ...
- Log4j – Configuring Log4j 2 - Log4j 2的配置
Configuration Inserting log requests into the application code requires a fair amount of planning an ...
- rxjs 入门--环境配置
原文: https://codingthesmartway.com/getting-started-with-rxjs-part-1-setting-up-the-development-enviro ...
- .Net元编程【Metaprogramming in NET】 序-翻译
最近在看这本书,比较实用.抽点时间把公开的部分内容简单的翻译了一下,下文是序部分. 书的具体地址为: http://www.amazon.cn/Metaprogramming-in-NET-Hazza ...
- Gumshoe - Microsoft Code Coverage Test Toolset
Gumshoe - Microsoft Code Coverage Test Toolset 2014-07-17 What is Gumshoe? How to instrument a binar ...
- Speeding up AngularJS apps with simple optimizations
AngularJS is a huge framework with that already has many performance enhancements built in, but they ...
- spring Transaction Management --官方
原文链接:http://docs.spring.io/spring/docs/current/spring-framework-reference/html/transaction.html 12. ...
随机推荐
- cap理论理解
一个分布式系统里面,节点组成的网络本来应该是连通的.然而可能因为一些故障,使得有些节点之间不连通了,整个网络就分成了几块区域.数据就散布在了这些不连通的区域中.这就叫分区. 当你一个数据项只在一个节点 ...
- HDU 4696 Answers 水题
http://acm.hdu.edu.cn/showproblem.php?pid=4696 由题意可知 1<=Ci<=2 而且图上一定有环 那么我们可以得出: 只要存在奇环(即Ci=1) ...
- FZU 1608 Huge Mission
Huge Mission Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on FZU. Original I ...
- lighttpd启动不了,libssl.so.4&libcrypto.so.4 缺失
lighttd的出错日志在 log/out_lighttpd 里,当lighttd启动不了时候,这里文件中会说明原因. 今天的报错是 error while loading shared librar ...
- php实现遍历文件目录
php实现遍历文件目录 一.总结 1.熟悉简单:很经典的例子,多看,然后发现熟悉了很简单 二.php实现遍历目录 php实现遍历目录 代码一: //遍历目录 function iteral($path ...
- UDP 打洞示例 包含 服务器 客户端
客户端示例: #include "Net.h" #include "../p2pInfo.h" int main() { CUdp udp; if (0!=u ...
- 【Codeforces Round #453 (Div. 2) B】Coloring a Tree
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 从根节点开始. 显然它是什么颜色.就要改成对应的颜色.(如果上面已经有某个点传了值就不用改 然后往下传值. [代码] #includ ...
- PatentTips - Supporting address translation in a virtual machine environment
BACKGROUND A conventional virtual-machine monitor (VMM) typically runs on a computer and presents to ...
- CORS原理
http://blog.csdn.net/renfufei/article/details/51675148 https://html.spec.whatwg.org/multipage/infras ...
- 数学定理证明机械化的中国学派(II)
所谓"学派"是指:存在一帮人,具有同样或接近的学术观点或学术立场,採用某种特定的"方法"(或途径),在一个学术方向上共同开展工作.而且做出了相当有迎影响的学术成 ...