[D15]...
-
Upload
insight-technology-inc -
Category
Technology
-
view
586 -
download
2
Transcript of [D15]...
最強にスケーラブルなカラムナーDBよ、 Hadoopとのタッグで
ビッグデータの地平を目指せ!
- Actian Matrix -
平間大輔 株式会社インサイトテクノロジー
Actian Analytics Platformの中核
Actian Analytics Platform™
Analyze
Act
Connect
Actian Analytics Accelerators
Actian DataFlow™
Actian Matrix™
Actian Vector™
Enterprise
Applications Data Warehouse
Social
Internet of Things
SaaS
WWW Machine Data
Mobile World-Class Risk
Management
Competitive Advantage
Customer Delight
Disruptive New Business Models
NoSQL Traditional
Actian Analytics Platform™
Accelerate Hadoop
Accelerate Analytics
Accelerate BI
Matrixとは?
Amazon RedshiftはMatrixを採用
“Actian has an industry leading solution and is rethinking database cloud – we’re excited to back such a strong team.”
- Jeff Blackburn, SVP of Business Development for Amazon
Amazon Redshift is the fastest growing service in their portfolio Selected after deep evaluation against all competitors based on price-performance value proposition of Actian’s platform Amazon Redshift service has over 1000 new customers since launch in Feb ’13 Actian complements Redshift with on-premise, high-scale analytics suite and support
Actian Analytics Platform Underpins AMAZON REDSHIFT Created New Cloud Service driving $50M+ revenue annually.
本当にスケールするの?
CentOS 6.4 64bit
Intel Xeon L5640
2.26GHz (2 cores only)
8GB
SATA SSD * 2
(RAID0 全ノード共有)
Actian Matrix 5.1
Virtual
Gigabit Ethernet
x N = ?
スケールアウト!
2nodes 4nodes 8nodes 16nodes
TPC-H 30GB
どうだ!
4nodes 8nodes 16nodes
TPC-H 100GB
スケールアウトの秘密を暴く Leader Node
Parser
Queries & Joins Non-Query Commands
Execution Planner & Optimizer
Code Generation
Queue & Workload Manager
Scheduler
Communication Layer
listener ODBC / JDBC / PSQL
データ処理の基本は「Slice」
Leader Node
Compute Node 1
Slice 1
1, 10, 20, 30, 40, 50, 60, 70….
5, 14, 24, 34, 44, 54, 64, 74….
Slice 2
2, 11, 21, 31, 41, 51, 61, 71….
6, 15, 25, 35, 45, 55, 65, 75….
Slice 3
3, 12, 22, 32, 42, 52, 62, 72....
7, 16, 26, 36, 46, 56,
66, 76…
Slice 4
4, 13, 33, 43, 53, 63,
73….
8, 17, 27, 37, 47, 57,
67, 77…
Compute Node 2
Slice 5
5, 14, 24, 34, 44, 54, 64, 74….
1, 10, 20, 30, 40, 50, 60, 70….
Slice 6
6, 15, 25, 35, 45, 55, 65, 75….
2, 11, 21, 31, 41, 51, 61, 71….
Slice 7
7, 16, 26, 36, 46, 56, 66, 76….
3, 12, 22, 32, 42, 52, 62, 72....
Slice 8
8, 17, 27, 37, 47, 57,
67, 77…
4, 13, 33, 43, 53, 63,
73….
Stream, Segment, Step
集計処理は2段階
Supplier
Nation AcctBal
S0---------
12448
S1---------
11778
S0---------
$5$10$12$15$30
S1---------
$10$11$15$5$8
S0Hash aggregate table
1 – $52 – $104 – $278 - $30
S1Hash aggregate table
1 – $217 – $208 - $8
S0-----------
11122
S1---------
44
S0---------
$5$21$15$10$7
S1---------
$27$1054
Aggr
Dist
Aggr
Supplier
Nation AcctBal
S2---------
1779
10
S3---------
24469
S2---------
$15$1
$12$10$3
S3---------
$7$1050
$4$10$2
S2Hash aggregate table
1 – $157 – $139 – $1010 - $3
S3Hash aggregate table
2 – $74 – $1054
6 – $109 = $2
S2-----------
677
S3---------
8899
10
S2---------
$10$20$13
S3---------
$30$8
$10$2$3
Node 2Node 1
... ...
Scan
S2Hash aggregate table
6 – $107 – $33
S3Hash aggregate table
8 – $389 – $1210 – $3
S0Hash aggregate table
1 – $412 – $17
S1Hash aggregate table
4 – $1081
select nation, sum(acctbal) from supplier group by nation;
create table supplier ( suppkey int4 not null distkey, name char(25) not null, address varchar(40) not null, nation int4 not null, phone char(15) not null, acctbal numeric(12,2) not null, comment varchar(101) not null ) sortkey (suppkey);
Queryの実行例 • TPC-H Q16
select p_brand, p_type, p_size, count(distinct ps_suppkey) as supplier_cnt from partsupp, part where p_partkey = ps_partkey and p_brand <> 'Brand#15' and p_type not like 'STANDARD POLISHED%' and p_size in (3, 8, 49, 19, 29, 9, 47, 32) and ps_suppkey not in ( select s_suppkey from supplier where s_comment like '%Customer%Complaints%' ) group by p_brand, p_type, p_size order by supplier_cnt desc, p_brand, p_type, p_size;
Queryの実行例 stm | seg | step | maxtime | avgtime | rows | bytes | label | slices
-----+-----+------+-----------------+-----------------+----------+------------+----------------------+--------
0 | 0 | 0 | 00:00:00.082427 | 00:00:00.047169 | 479 | 37414 | scan tblP =108506 | 32
0 | 0 | 2 | 00:00:00.082427 | 00:00:00.047169 | 479 | 1916 | bcast | 32
0 | 1 | 0 | 00:00:00.099844 | 00:00:00.094777 | 7664 | 30656 | scan fabric=67 | 32
0 | 1 | 2 | 00:00:00.099844 | 00:00:00.094777 | 7664 | 122624 | hash tblT =240 | 32
1 | 2 | 0 | 00:00:00.002559 | 00:00:00.001517 | 0 | 0 | scan tblP =108490 | 32
1 | 2 | 1 | 00:00:00.002559 | 00:00:00.001517 | 0 | 0 | sort tblT =242 | 32
2 | 3 | 0 | 00:00:00.002244 | 00:00:00.001048 | 0 | 0 | scan tblP =108514 | 32
2 | 3 | 1 | 00:00:00.002244 | 00:00:00.001048 | 0 | 0 | sort tblT =244 | 32
3 | 4 | 0 | 00:00:02.231598 | 00:00:01.725522 | 79999318 | 1279989088 | scan tblP =108514 | 32
3 | 4 | 1 | 00:00:02.231598 | 00:00:01.725522 | 0 | 0 | merge | 32
3 | 4 | 5 | 00:00:02.231598 | 00:00:01.725522 | 11885548 | 0 | mjoin tbl =239 | 32
3 | 4 | 8 | 00:00:02.231598 | 00:00:01.725522 | 11879878 | 0 | hjoin tblT =240 | 32
3 | 4 | 11 | 00:00:02.231598 | 00:00:01.725522 | 11879783 | 712462256 | aggr tblT =257 | 32
3 | 4 | 12 | 00:00:02.231598 | 00:00:01.725522 | 11879783 | 565281908 | dist | 32
3 | 5 | 0 | 00:00:02.426613 | 00:00:02.371618 | 11879783 | 569904860 | scan fabric=68 | 32
3 | 5 | 1 | 00:00:02.426613 | 00:00:02.371618 | 11877404 | 712319756 | aggr tblT =260 | 32
4 | 6 | 0 | 00:00:00.192183 | 00:00:00.133277 | 11877404 | 712319756 | scan tblT =260 | 32
4 | 6 | 5 | 00:00:00.192183 | 00:00:00.133277 | 890878 | 56991616 | aggr tblT =265 | 32
4 | 6 | 6 | 00:00:00.192183 | 00:00:00.133277 | 890878 | 45434532 | dist | 32
4 | 7 | 0 | 00:00:00.301407 | 00:00:00.292919 | 890878 | 49864592 | scan fabric=69 | 32
4 | 7 | 1 | 00:00:00.301407 | 00:00:00.292919 | 27840 | 1780992 | aggr tblT =268 | 32
5 | 8 | 0 | 00:00:00.001789 | 00:00:00.001143 | 27840 | 1780992 | scan tblT =268 | 32
5 | 8 | 3 | 00:00:00.001789 | 00:00:00.001143 | 27840 | 1558272 | sort tblT =238 | 32
6 | 9 | 0 | 00:00:00.000595 | 00:00:00.000336 | 27840 | 1558272 | scan tblT =238 | 32
6 | 9 | 1 | 00:00:00.000595 | 00:00:00.000336 | 27840 | 1419844 | return | 32
6 | 10 | 0 | 00:00:00.046609 | 00:00:00.046609 | 27840 | 0 | merge | 1
6 | 10 | 2 | 00:00:00.046609 | 00:00:00.046609 | 0 | 0 | return | 1
いぢめないで…
select l_partkey, l_extendedprice from lineitem order by 2, 1;
stm | seg | step | maxtime | avgtime | rows | bytes | label | slices
-----+-----+------+-----------------+-----------------+-----------+-------------+----------------------+--------
0 | 0 | 0 | 00:00:23.496729 | 00:00:19.806 | 600037902 | 12000758040 | scan tblP =108542 | 32
0 | 0 | 3 | 00:00:23.496729 | 00:00:19.806 | 600037902 | 9600606432 | sort tblT =238 | 32
1 | 1 | 0 | 00:08:29.514698 | 00:08:29.109248 | 600037902 | 9600606432 | scan tblT =238 | 32
1 | 1 | 1 | 00:08:29.514698 | 00:08:29.109248 | 600037902 | 9600474240 | return | 32
1 | 2 | 0 | 00:08:33.764077 | 00:08:33.764077 | 600037902 | 0 | merge | 1
1 | 2 | 2 | 00:08:33.764077 | 00:08:33.764077 | 0 | 0 | return | 1
データの持ち方も重要
分散キー (distkey)
catid
category
catgroup catname catdesc
distkey
Slice 0 Slice 1
catitem
catid
distkey itemid
ソートキー (sortkey)
Amazon Buffer Create Drive Enjoy
.
.
.
. Xbox You zone
Super Final high
VACUUM
カラムナーDBの十八番、圧縮 エンコード名 キーワード サポートされるデータ型 圧縮の特徴
Byte dictionary BYTEDICT VARCHARとBOOLEAN を除く全て
ブロックごとに最大255通りの値を辞書に持たせることで1カラム1バイトに圧縮。
Global dictionary
GLOBALDICT256, GLOBALDICT64K
BOOLEAN以外全て カラム全体で1つの辞書を持つ。256だと255通りの値を1バイトに、64Kだと65535通りの値を2バイトに圧縮。
Delta DELTA, DELTA32K
SMALLINT (DELTAのみ), INT, BIGINT, DATE, TIMESTAMP, DECIMAL
前の値との差分を格納。差分の値が元データ型のサイズよりも小さければ圧縮可能。
Run-length RUNLENGTH 全て ランレングス圧縮。同一のデータがいくつ連続するかを格納。連続した同一値には高い圧縮率。
LZ (Lempel-Ziv) DEFLATE BOOLEAN, REAL, DOUBLE PRECISION を除く全て
LZ法(ZIPなど一般的なファイル圧縮で使われているアルゴリズム)で圧縮。圧縮率は高いが圧縮・展開のCPU負荷も高い。
Mostly MOSTLY8 SMALLINT, INT, BIGINT, DECIMAL
カラム内の値が指定されたデータ型よりも小さいサイズで格納可能な場合、指定された(元のデータ型よりも小さい)サイズでデータを格納する。収まらない場合は元のサイズで格納。
MOSTLY16 INT, BIGINT, DECIMAL
MOSTLY32 BIGINT, DECIMAL
TEXT255, 32K TEXT255, TEXT32K
VARCHARのみ 辞書を使用した圧縮のVARCHAR版。245通りの単語まで辞書に登録可能。
上手に圧縮、サイズは1/2以下! create table lineitem (
l_orderkey int8 not null encode delta sortkey distkey,
l_partkey int4 not null,
l_suppkey int4 not null encode mostly16,
l_linenumber int4 not null encode mostly8,
l_quantity numeric(19,2) not null encode bytedict,
l_extendedprice numeric(19,2) not null encode mostly32,
l_discount numeric(19,2) not null encode mostly8,
l_tax numeric(19,2) not null encode mostly8,
l_returnflag char(1) not null encode runlength,
l_linestatus char(1) not null encode runlength,
l_shipdate date not null encode delta,
l_commitdate date not null encode delta,
l_receiptdate date not null encode delta,
l_shipinstruct char(25) not null encode bytedict,
l_shipmode char(10) not null encode bytedict,
l_comment varchar(44) not null
);
create table lineitem (
l_orderkey int8 not null sortkey distkey,
l_partkey int4 not null,
l_suppkey int4 not null,
l_linenumber int4 not null,
l_quantity numeric(19,2) not null,
l_extendedprice numeric(19,2) not null,
l_discount numeric(19,2) not null,
l_tax numeric(19,2) not null,
l_returnflag char(1) not null,
l_linestatus char(1) not null,
l_shipdate date not null,
l_commitdate date not null,
l_receiptdate date not null,
l_shipinstruct char(25) not null,
l_shipmode char(10) not null,
l_comment varchar(44) not null
);
行数: 600,037,902
40,204 MB 18,900 MB !
隠し味はUDF(ユーザー定義関数) • PL/pgSQLの例
CREATE OR REPLACE FUNCTION f_echo(_text varchar) RETURNS varchar AS $$ BEGIN return _text; END; $$ LANGUAGE plpgsql;
• C++の例 #include "padb_udf.hpp" PADB_UDF_VERSION(charcount); extern "C" { padb_udf::int_t charcount ( padb_udf::ScalarArg &aux, padb_udf::varchar_t *target, padb_udf::varchar_t *tst ) { padb_udf::int_t ret = 0; if ( tst->len != 1 ) { aux.throwError( __func__,"probe length must be = 1" ); } char ch = tst->str[0]; for ( padb_udf::len_t ix = 0; ix < target->len; ix++ ) { if ( target->str[ix] == ch ) { ret++; } } return aux.retIntVal( ret ); } }
CREATE OR REPLACE FUNCTION charcount (target_string varchar, search_character varchar) RETURNS int AS '/tmp/scalar_charcount.o' LANGUAGE C STABLE;
• ユーザーのビジネスロジック組み込み • サードパーティ製分析関数 • ODI(On-Demand Integration)の実現
ビッグなデータはHadoopから取り込め!
ビッグなデータはHadoopから取り込め!
DataNode
DataNode
DataNode
NameNode
Compute Node
Compute Node
Compute Node
LeaderNode
これでは遅い…
ビッグなデータはHadoopから取り込め!
DataNode
DataNode
DataNode
NameNode
Compute Node
Compute Node
Compute Node
LeaderNode
直接ロードしたい! 直接読み込みたい!
Google Booksで現れる単語を見てみよう
まずはHadoopでデータ加工だ! algorithm_PRON 1991 297 185 algorithm_PRON 1992 325 217 algorithm_PRON 1993 336 235 algorithm_PRON 1994 308 202 algorithm_PRON 1995 331 244 algorithm_PRON 1996 376 243 algorithm_PRON 1997 404 243 algorithm_PRON 1998 404 269 algorithm_PRON 1999 495 295 algorithm_PRON 2000 480 318
algorithm PRON 1991 297 185 algorithm PRON 1992 325 217 algorithm PRON 1993 336 235 algorithm PRON 1994 308 202 algorithm PRON 1995 331 244 algorithm PRON 1996 376 243 algorithm PRON 1997 404 243 algorithm PRON 1998 404 269 algorithm PRON 1999 495 295 algorithm PRON 2000 480 318
単語と品詞を分離したい
MapReduceだ!
ちょっとしたクエリはODIで
こんなクエリが書けちゃう
select word, sum(wordcount) from odi_hadoop_import(
with jobname('googlebooks_job')
masternode('hadoop01.com')
inputdir('/user/dhirama/googlebooksModifyDemo')
padb_schema('googlebooksWords')
delimiter('¥t')
)
where word like 'another%'
group by word;
ODIを実行だ!
がっつりロードするならDataFlow!
高速ロード、すぐに分析!
最強のタッグがBigDataの世界を変える!
無断転載を禁ず この文書はあくまでも参考資料であり、掲載されている情報は予告なしに変更されることがあります。
株式会社インサイトテクノロジーは本書の内容に関していかなる保証もしません。また、本書の内容に関連したいかなる損害についても責任を負いかねます。 本書で使用している製品やサービス名の名称は、各社の商標または登録商標です。