SlideShare uma empresa Scribd logo
1 de 10
Baixar para ler offline
PowerDrill列存储底层设计
梁智超
liangzhichao@chinamobile.com
PowerDrill列存储设计思想
• PowerDrill以交互的方式针对大数据提供Ad hoc
查询,用户可以选择任意维度、任意度量标准、
任意计算结果值进行数据的分组和过滤!
示例:查询从昨天中午起在Google上使用了包含“auto”这个搜索词进行
搜索的所有德国人!

• 预先聚集或者对数据进行索引是没用的,只能
直接查询原始数据!

• 为了加快查询速度,在查询过程中尽可能过滤
掉与查询无关的数据!
PowerDrill列存储分区
• 为了在查询过程中略过无关数据,对数据进行
分区是必要的!
• PowerDrill主要处理Group by和Order by,所以
选择混合范围分区!
EMP
Name

Age

Dept

Salary

Bob

25

Math

10K

Bill

24

EECS

20K

Jill

24

Biology

10K

Tom

25

DB

30K

Mary

24

EECS

20K

Poter

25

Math

30K

Bill

24

EECS

20K

Jill

24

Biology

10K

Mary

24

EECS

20K

Bob

25

Math

10K

Tom

25

DB

30K

Age

Poter

25

Math

30K

Salary

首先根据Age字段进行范围分区

由用户或
领域专家
选择的用
于实现混
合分区的
属性组
PowerDrill列存储分区
然后再根据Salary字段
进行范围分区

通过分区可以
快速定位与查
询相关的数据
和与查询不相
关的数据,减
少数据的扫描

Jill

24

Biology

10K

Bob

25

Math

10K

Bill

24

EECS

20K

Tom

25

DB

30K

Mary

24

EECS

20K

Poter

25

Math

30K

EMP
Name

Age

Dept

Salary

Bob

25

Math

10K

Bill

24

EECS

20K

Jill

24

Biology

10K

Tom

25

DB

30K

Mary

24

EECS

20K

Poter

25

Math

30K

Bill

24

EECS

20K

Jill

24

Biology

10K

Mary

24

EECS

20K

Bob

25

Math

10K

Tom

25

DB

30K

Age

Poter

25

Math

30K

Salary

首先根据Age字段进行范围分区

由用户或
领域专家
选择的用
于实现混
合分区的
属性组
PowerDrill列存数据压缩算法
• PowerDrill中的处理数据假定可以全部放进内
存,为了减少数据对内存的占用,需要对数据
进行压缩!
• 此外压缩后的数据必须利于判断数据分区是否
与查询相关!
• PowerDrill列存针对每个属性列使用字典压缩
算法,将数据中较长的字符串转化为32位整型
值!
• 全局字典表+分区字典表!
PowerDrill列存数据压缩算法(cont.)
gobal-dictionary dict

全局字典表用于存储存储列中所有的distinct字符串,按字典顺
序排序,且每个字符串均对应一个全局id,譬如amazon的全局
id就是1,通过这种方式,字符串就转化成了全局id!

id

search string

0

ab in den Urlaub

1

amazon

Chunk 0

2

cheap tickets

3

chaussures

chunk-dict
ch0.dict

4

cheap flights

chunk-id

global-id

5

ebay

6

faschingskostume

7

immobilienscout

8

karnevalskostume

0
1
2
3
4

1
2
3
5
12

9

la redoute

10

pages jaunes

11

voyages snfc

12

yellow pages

elements
ch0.elements
3
2
0
4
0
0
2
1
3
2

分区字典表与全局字
典表类似,用于存储
本分区中所有distinct
字符串,且每个字符
串均对应了一个分区
id,但是因为通过全
局字典所有字符串已
经转化成了全局id,
所以在分区字典表中
直接存储全局id!
通过全局字典表和分
区字典表,字符串可
以映射到分区id,所以
列中只存储字符串对
应的分区id!
PowerDrill列存数据压缩算法(cont.)
Chunk 1

Chunk 2

chunk-dict
ch1.dict

elements
ch0.elements

chunk-id

global-id

0
1
2
3
4
5

0
1
5
6
7
8

chunk-dict
ch2.dict

elements
ch0.elements

chunk-id
5
2
1
4
3
0
0
1
5
5

分区字典表按照全局id排序,
查询时采用二分查找

global-id

0
1
2
3
4

1
3
5
10
11

0
0
2
4
3
4
4
1
2
1

列中之所以存储分区id而不是全局id是因为单个
分区中的distinct字符串个数要远小于整个列中的
distinct字符串个数,所以分区id会是个很小的整
型,存储分区id会节省更多的空间!
PowerDrill列存数据压缩算法(cont.)
gobal-dictionary dict

SELECT search_string, COUNT(*) as c FROM data
WHERE search_string IN (“la redoute”, “voyages sncf”)
GROUP BY search_string ORDER BY c DESC LIMIT 10;

id

search string

0

ab in den Urlaub

1

amazon

Chunk 2

2

cheap tickets

3

chaussures

chunk-dict
ch2.dict

4

cheap flights

chunk-id

global-id

5

ebay

6

faschingskostume

7

immobilienscout

8

karnevalskostume

0
1
2
3
4

1
3
5
10
11

9

la redoute

10

pages jaunes

11

voyages snfc

12

yellow pages

elements
ch0.elements
0
0
2
4
3
4
4
1
2
1

通过查询语句中的
WHERE查询条件查询
全局字典表可以知道
要查询的两个字符串
的全局id分别是9和11,
通过查询三个分区的
分区字典表可以知道
没有任何分区包含9这
个全局id,仅有chunk
2包含了11这个全局id,
其对应的分区id是4,
所以本次查询只需读
取chunk 2的数据,计
算出elements中分区id
为4的个数即可!
PowerDrill列存数据压缩算法(cont.)
• PowerDrill列存中使用的压缩算法不仅可以将
列中字符串转化为整数,而且可快速确定与查
询相关的分区!
• 此外,基于二级字典表压缩算法还可以使用其
他压缩算法进行多次压缩!
Chunk 1

gobal-dictionary dict
id

search string

0

ab in den Urlaub

1

amazon

2

cheap tickets

3

chaussures

对全局字
典表中的
字符串使
用tries
(前缀树)
算法进行
压缩

chunk-dict
ch1.dict

elements
ch0.elements

chunk-id

global-id

0
1
2
3
4

0
1
5
6
7

5
2
1
4
3

根据分区id
的大小使
用1、2、4、
8、16、32
不同位数
的整数来
表示,减
少分区id的
空间占用
PowerDrill列存基本性能
• 因为数据能够全部放入内存且利用了高效的压
缩算法,所以PowerDrill列存设计在处理性能
和内存占用上均存在优势!
测试用例:包含了三种针对不同
列属性的查询语句

测试结果:Basic指PowerDrill列
存,包含了与CSV、rec-io和
Dremel三种不同存储方法的对比,
无论是性能还是存储空间上,
PowerDrill列存均有优势,其中
在存储空间上与Dremel相比差不
多,这是因为Dremel中也使用了
大量的压缩技术!

Mais conteúdo relacionado

Mais de Zhichao Liang

C store底层存储设计
C store底层存储设计C store底层存储设计
C store底层存储设计Zhichao Liang
 
Storage Class Memory: Technology Overview & System Impacts
Storage Class Memory: Technology Overview & System ImpactsStorage Class Memory: Technology Overview & System Impacts
Storage Class Memory: Technology Overview & System ImpactsZhichao Liang
 
A simple introduction to redis
A simple introduction to redisA simple introduction to redis
A simple introduction to redisZhichao Liang
 
Some key value stores using log-structure
Some key value stores using log-structureSome key value stores using log-structure
Some key value stores using log-structureZhichao Liang
 
A novel method to extend flash memory lifetime in flash based dbms
A novel method to extend flash memory lifetime in flash based dbmsA novel method to extend flash memory lifetime in flash based dbms
A novel method to extend flash memory lifetime in flash based dbmsZhichao Liang
 
Sub join a query optimization algorithm for flash-based database
Sub join a query optimization algorithm for flash-based databaseSub join a query optimization algorithm for flash-based database
Sub join a query optimization algorithm for flash-based databaseZhichao Liang
 
Hush…tell you something novel about flash memory
Hush…tell you something novel about flash memoryHush…tell you something novel about flash memory
Hush…tell you something novel about flash memoryZhichao Liang
 
Survey of distributed storage system
Survey of distributed storage systemSurvey of distributed storage system
Survey of distributed storage systemZhichao Liang
 

Mais de Zhichao Liang (9)

C store底层存储设计
C store底层存储设计C store底层存储设计
C store底层存储设计
 
Storage Class Memory: Technology Overview & System Impacts
Storage Class Memory: Technology Overview & System ImpactsStorage Class Memory: Technology Overview & System Impacts
Storage Class Memory: Technology Overview & System Impacts
 
A simple introduction to redis
A simple introduction to redisA simple introduction to redis
A simple introduction to redis
 
Memcached简介
Memcached简介Memcached简介
Memcached简介
 
Some key value stores using log-structure
Some key value stores using log-structureSome key value stores using log-structure
Some key value stores using log-structure
 
A novel method to extend flash memory lifetime in flash based dbms
A novel method to extend flash memory lifetime in flash based dbmsA novel method to extend flash memory lifetime in flash based dbms
A novel method to extend flash memory lifetime in flash based dbms
 
Sub join a query optimization algorithm for flash-based database
Sub join a query optimization algorithm for flash-based databaseSub join a query optimization algorithm for flash-based database
Sub join a query optimization algorithm for flash-based database
 
Hush…tell you something novel about flash memory
Hush…tell you something novel about flash memoryHush…tell you something novel about flash memory
Hush…tell you something novel about flash memory
 
Survey of distributed storage system
Survey of distributed storage systemSurvey of distributed storage system
Survey of distributed storage system
 

Power drill列存储底层设计