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个概念:PartitionKeysSortKeys。相应于上述的分区键排序键

BLOCKGEN

Raw data转化为partitionedsorteddata units的过程称为BLOCKGEN

这个是Cubert语法里一个很重要的操作符。

这张图告诉我们:

1. 我们有一个table。2列,JKGK

2. BLOCKGEN的过程就是选择一个partitionKeyJK,依据这个分区键来对数据块分区。然后对分区后的数据块内部选择GK作为排序键,来对分区后的数据块排序。

3. 这样原始数据划分称为了2个partitionedBlocks即BLOCK#1BLOCK#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文件里能够包括>=1block

所以不用操心会生产太多的file.

參考

Cubert官方文档blocks

Ps:本文的写作是基于对Cubert官方文档的翻译个人对Cubert的理解综合完毕 :)

原创文章。转载请注明:

转载自:OopsOutOfMemory盛利的Blog, 作者: OopsOutOfMemory

本文链接地址:

注:本文基于署名-非商业性使用-禁止演绎 2.5 中国大陆(CC BY-NC-ND 2.5 CN)协议,欢迎转载、转发和评论。可是请保留本文作者署名和文章链接。

如若须要用于商业目的或者与授权方面的协商。请联系我。

Understanding Cubert Concepts(一)Partitioned Blocks的更多相关文章

  1. LinkedIn Cubert 实践指南

    · LinkedIn Cubert安装指南 · Understanding Cubert Concepts(一)Partitioned Blocks · Understanding Cubert Co ...

  2. (二)Basic Concepts 基本概念

    Basic Concepts There are a few concepts that are core to Elasticsearch. Understanding these concepts ...

  3. Elasticsearch-->Get Started-->Basic concepts

    https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started-concepts.html There ...

  4. Log4j – Configuring Log4j 2 - Log4j 2的配置

    Configuration Inserting log requests into the application code requires a fair amount of planning an ...

  5. rxjs 入门--环境配置

    原文: https://codingthesmartway.com/getting-started-with-rxjs-part-1-setting-up-the-development-enviro ...

  6. .Net元编程【Metaprogramming in NET】 序-翻译

    最近在看这本书,比较实用.抽点时间把公开的部分内容简单的翻译了一下,下文是序部分. 书的具体地址为: http://www.amazon.cn/Metaprogramming-in-NET-Hazza ...

  7. Gumshoe - Microsoft Code Coverage Test Toolset

    Gumshoe - Microsoft Code Coverage Test Toolset 2014-07-17 What is Gumshoe? How to instrument a binar ...

  8. Speeding up AngularJS apps with simple optimizations

    AngularJS is a huge framework with that already has many performance enhancements built in, but they ...

  9. spring Transaction Management --官方

    原文链接:http://docs.spring.io/spring/docs/current/spring-framework-reference/html/transaction.html 12.  ...

随机推荐

  1. 73.node.js开发错误——TypeError: Cannot set property 'XXX' of undefined

    转自:https://blog.csdn.net/fd214333890/article/details/53467429

  2. linux 下find---xargs以及find--- -exec结合使用

    例:删除/home/raven下,包括子目录里所有名为abc.txt的文件: find /home/raven -name abc.txt | xargs rm -rf 如果不使用xargs,则为: ...

  3. echo---打印变量或输出字符串

    cho命令用于在shell中打印shell变量的值,或者直接输出指定的字符串.linux的echo命令,在shell编程中极为常用, 在终端下打印变量value的时候也是常常用到的,因此有必要了解下e ...

  4. 【Codeforces Round #427 (Div. 2) C】Star sky

    [Link]:http://codeforces.com/contest/835/problem/C [Description] 给你n个星星的坐标(xi,yi); 第i个星星在第t秒,闪烁值变为(s ...

  5. 【Codeforces Round #426 (Div. 2) A】The Useless Toy

    [Link]:http://codeforces.com/contest/834/problem/A [Description] [Solution] 开个大小为4的常量字符数组; +n然后余4,-n ...

  6. Spring3 整合MyBatis3 配置多数据源 动态选择SqlSessionFactory(转)

    1. Spring整合MyBatis切换SqlSessionFactory有两种方法,第一. 继承SqlSessionDaoSupport,重写获取SqlSessionFactory的方法.第二.继承 ...

  7. 洛谷 P1217 [USACO1.5]回文质数 Prime Palindromes

    P1217 [USACO1.5]回文质数 Prime Palindromes 题目描述 因为151既是一个质数又是一个回文数(从左到右和从右到左是看一样的),所以 151 是回文质数. 写一个程序来找 ...

  8. 微软推送Win10致全球网络负担增大,中国网友表示毫无压力

        7月29日晚间,微软的Windows10操作系统正式上市发行.微软将面向全球190个国家地区进行windows10的免费升级推送. 眼下, Windows 10 正以疯狂的速度登陆全球各类设备 ...

  9. Intent调用系统拍照程序,返回图片太小的问题

    之前採用的方式(返回的照片会被压缩,不能达到预期效果): Intent intent = new Intent(); Intent intent_camera = getPackageManager( ...

  10. php excel文件导出之phpExcel扩展库

    php Excel  文件导出 phpExcel 官网 http://phpexcel.codeplex.com/ /** * 导出特定文件 * 依据详细情况而定 */ public function ...