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. ...
随机推荐
- js中常用的对象—Array的属性和方法
今天说一下,js中常用的内置对象——Array对象 Array常用属性: length prototype :给系统对象添加属性和方法 Array常用方法: Array.prototype.sum = ...
- POJ 3040 贪心
贪心好题 ---. 思路: 从大到小凑C 如果不够 再从小到大补满(超过)C //By SiriusRen #include <cstdio> #include <cstring&g ...
- notepad++go语法高亮文件
notepad++go语法高亮文件 下载 右键另存为下载后在语言栏中的自定义面板中直接导入,重启即可
- Block Manager
在Spark中,将数据抽象为Block(不论是shuffle数据,还是节点本身存储的数据),而每个driver/executor中的block都是由`BlockManager`这个类来负责管理的.对于 ...
- bash命令集---文件的操作
git bash命令集: clear:清除窗口中的内容 ls touch cat more head tail mv cp rm diff chmod gzip gunzip gzcat lpr lp ...
- Spring模块作用
0.模块整理 Spring模块整理(http://www.kuqin.com/shuoit/20150805/347434.html) 模块名 作用 资料 aop spring的面向切面编程,提供A ...
- 【Django】序列化
Django中序列化主要应用于将数据库中检索的数据返回给客户端用户,特别是Ajax请求一般返回为Json格式. * 1.from django.core import serializers** fr ...
- KnockOut下的离开检测
<input type="text" class="form-control" data-bind="event:{ blur:$root.ch ...
- [ReasonML] Named & optional params
// ::country is named param // ::country=?: which make it optional // because we make ::country=? op ...
- 【开卷故意】JAVA正則表達式模版
专业既然是机器学习.那工作肯定也是继续和数据打交道,那么问题来了,非常多时候推荐算法和数据挖掘算法都是现成可用的,平台初建,重点还在数据过滤和抽取.如何高效的抽取数据? 利用往常算法比赛中经常使用的字 ...
