
{"id":1123,"date":"2013-01-07T00:49:17","date_gmt":"2013-01-06T15:49:17","guid":{"rendered":"http:\/\/a23187.yorozuyah.com\/blog\/?p=1123"},"modified":"2013-01-21T20:32:57","modified_gmt":"2013-01-21T11:32:57","slug":"treasure-data%e3%81%a7dbt3%e3%82%92%e8%a9%a6%e3%81%9b%e3%82%8b%e3%81%8b%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/a23187.yorozuyah.com\/blog\/?p=1123","title":{"rendered":"Treasure Data\u306bDBT3\u306e\u30c7\u30fc\u30bf\u3092\u30ed\u30fc\u30c9\u3057\u3066\u307f\u308b"},"content":{"rendered":"<p>\u6700\u8fd1\u306f\u5642\u306e\u30d3\u30c3\u30b0\u30c7\u30fc\u30bf\u7684\u306a\u30b7\u30b9\u30c6\u30e0\u306e\u30a4\u30f3\u30d5\u30e9\u95a2\u9023\u306b\u3082\u624b\u3092\u51fa\u3057\u3064\u3064\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u6c17\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u304cTreasure Data\u306a\u306e\u3067\u3059\u3002<\/p>\n<p>\u4f55\u3068\u8a00\u3063\u3066\u3082500GB\u307e\u3067\u3001\u7121\u6599\u3067\u30af\u30e9\u30a6\u30c9\u578b\u306eHadoop\u304c\u4f7f\u3048\u308b\u3068\u3044\u3046\u306e\u304c\u304a\u8a66\u3057\u306b\u306f\u6700\u9069\u3002<\/p>\n<p>\u3055\u3089\u306b\u3001fluentd\u7528\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3082\u3042\u308a\u306e\u3001Hive\u3082\u4f7f\u3048\u308b\u306e\u3067\u3059\u3050\u5229\u7528\u3067\u304d\u308b\u72b6\u614b\u306b\u3042\u308a\u306e\u3001\u9b45\u529b\u304c\u305f\u304f\u3055\u3093\u3002<\/p>\n<p>\u307e\u305a\u306f\u30b5\u30a4\u30f3\u30a2\u30c3\u30d7\u306a\u306e\u3067\u3059\u304c\u3053\u3053\u3044\u3044\u306d\uff01<\/p>\n<div class=\"command\">\n<p><em>Let\u2019s get started with Treasure Data! Treasure Data is a Hadoop-based Cloud Data Warehousing service. Forget about the servers, storage, and infrastructure needed to store your billions of records and focus on analyzing your data instead.<\/em><\/p>\n<\/div>\n<p>\u7c21\u5358\u306b\u8a00\u3046\u3068\u3001\u300c\u30a4\u30f3\u30d5\u30e9\u5468\u308a\u306e\u3053\u3068\u6c17\u306b\u3057\u306a\u3044\u3067\u89e3\u6790\u3060\u3051\u306b\u96c6\u4e2d\u3057\u3066\u304f\u3060\u3055\u3044\uff01\u300d\u3066\u3068\u3053\u308d\u3067\u3057\u3087\u3046\u304b\u3002<br \/>\n\u30a4\u30f3\u30d5\u30e9\u3092\u62c5\u5f53\u3059\u308b\u3082\u306e\u3068\u3057\u3066\u306f\u3042\u308a\u304c\u305f\u3044\u304a\u8a00\u8449(T_T)<\/p>\n<p>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u306fCentOS\u4f7f\u3063\u3066\u307e\u3059\u304c\u3001\u914d\u5e03\u3055\u308c\u3066\u3044\u308b\u30b7\u30a7\u30eb\u3067\u4e00\u767a\u3067\u3059\u3002<br \/>\n\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5f8c\u306ftd\u30b3\u30de\u30f3\u30c9\u3067\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u64cd\u4f5c\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u65e9\u901f\u306a\u306e\u3067\u3059\u304c\u3001DBT3\u3067\u3082\u8a66\u3057\u3066\u307f\u3088\u3046\u304b\u3068\u601d\u3044\u3001\u30c7\u30fc\u30bf\u3092\u30ed\u30fc\u30c9(import)\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<br \/>\n\u65e2\u306bDBT3\u74b0\u5883\u306e\u30c7\u30fc\u30bf\u304c\u3042\u308a\u307e\u3057\u305f\u306e\u3067\u305d\u308c\u3092\u6d41\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u30c6\u30fc\u30d6\u30eb\u4f5c\u6210\u306f\u3053\u3093\u306a\u611f\u3058\u3067\u4e00\u77ac\u3067\u3002<\/p>\n<div class=\"command\">\n<p>$ td account -f<\/p>\n<p>$ td db:create dbt3<\/p>\n<p>$ td table:create dbt3 supplier<br \/>\n$ td table:create dbt3 customer<br \/>\n$ td table:create dbt3 orders<br \/>\n$ td table:create dbt3 lineitem<br \/>\n$ td table:create dbt3 part<br \/>\n$ td table:create dbt3 partsupp<br \/>\ntd table:create dbt3 nation<br \/>\ntd table:create dbt3 region<\/p>\n<p>$ td table:list dbt3<br \/>\n+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8211;+<br \/>\n| Database | Table    | Type | Count | Size   | Schema |<br \/>\n+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8211;+<br \/>\n| dbt3     | customer | log  | 0     | 0.0 GB |        |<br \/>\n| dbt3     | lineitem | log  | 0     | 0.0 GB |        |<br \/>\n| dbt3     | nation   | log  | 0     | 0.0 GB |        |<br \/>\n| dbt3     | orders   | log  | 0     | 0.0 GB |        |<br \/>\n| dbt3     | part     | log  | 0     | 0.0 GB |        |<br \/>\n| dbt3     | partsupp | log  | 0     | 0.0 GB |        |<br \/>\n| dbt3     | region   | log  | 0     | 0.0 GB |        |<br \/>\n| dbt3     | supplier | log  | 0     | 0.0 GB |        |<br \/>\n+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8211;+<br \/>\n8 rows in set<\/p>\n<\/div>\n<p>\u7c21\u5358\u3059\u304e\u308b\u30fb\u30fb\u30fb\u30ab\u30e9\u30e0\u5b9a\u7fa9\u3092\u3057\u306a\u304f\u3066\u826f\u3044\u306e\u306f\u5f53\u305f\u308a\u524d\u3060\u3051\u3069\u697d\u3002<\/p>\n<p>\u3055\u3066\u3001dbt3\u306e\u30c7\u30fc\u30bf\u30ed\u30fc\u30c9\u3067\u3059\u304c\u3001\u3055\u304f\u3089VPS\u304b\u3089\u30ed\u30fc\u30c9\u3059\u308b\u306e\u3067\u3001\u30ed\u30fc\u30ab\u30eb\u306b\u306f\u5927\u304d\u306a\u30d5\u30a1\u30a4\u30eb\u306f\u7f6e\u304d\u305f\u304f\u306a\u3044\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u5727\u7e2e\u3057\u3066\u304a\u3044\u305ftbl\u30c7\u30fc\u30bf\u3092FIFO\u3067\u6d41\u3057\u8fbc\u3080\u3053\u3068\u306b\u3002<\/p>\n<p>\u305d\u306e\u524d\u306b\u30fb\u30fb\u30fbCSV\u306f\u305d\u306e\u307e\u307e\u3067\u306fimport\u304c\u3067\u304d\u306a\u3044\u3053\u3068\u304c\u5224\u660e\u3002\u3002\u3002<\/p>\n<p>msgpack\u304bjson\u3067\u306a\u3044\u3068\u3060\u3081\u3068\u306e\u3053\u3068\u3002\uff08\u305d\u3082\u305d\u3082msgpack\u3066\u306a\u306b\u304b\u3057\u3089\u306a\u3044\u30fb\u30fb\uff1f\uff1f\uff09<\/p>\n<p>\u7279\u306b\u65b0\u305f\u306a\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306a\u3069\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u306e\u5fc5\u8981\u304c\u306a\u3044\u3001awk\u3067\u5b9f\u884c\u3059\u308b\u3053\u3068\u306b\u3002<\/p>\n<p>\u3053\u3093\u306a\u611f\u3058\u306b<br \/>\n\u2192<a href=\"https:\/\/a23187.yorozuyah.com\/blog\/?p=1147\">awk\u3067csv\u3092json\u306b\u5909\u63db\u3057\u3066\u307f\u308b<\/a><\/p>\n<p>\u4e0a\u306e\u4f8b\u306f\u3001dbt3\u306elineitem\u306e\u4f8b\u3067\u3059\u304c\u3001\u4ed6\u306e\u30c6\u30fc\u30d6\u30eb\u3082\u30ab\u30e9\u30e0\u540d\u3068\u6570\u3092\u5909\u3048\u3066\u6d41\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u3001FIFO\u304b\u3089\u306eimport\u306e\u624b\u9806\u3067\u3059\u3002<br \/>\n\u3042\u3089\u304b\u3058\u3081\u4f5c\u3063\u3066\u5727\u7e2e\u3057\u3066\u3042\u3063\u305fdbt3\u7528\u306e\u30c6\u30fc\u30d6\u30eb\u30c7\u30fc\u30bf\u3092\u3001csv\u304b\u3089json\u306b\u5909\u63db\u3057\u306a\u304c\u3089import\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<div class=\"command\">\n<p>#!\/bin\/sh<\/p>\n<p>for TABLE in customer nation part partsupp region supplier<br \/>\ndo<\/p>\n<p>echo &#8220;${TABLE} import start `date`&#8221;<\/p>\n<p># fifo\u306e\u4f5c\u6210<br \/>\nmkfifo ${TABLE}.fifo<\/p>\n<p># \u5148\u306bimport\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c<br \/>\ntd table:import dbt3 ${TABLE} &#8211;json -t CREATED ${TABLE}.fifo &#038;<\/p>\n<p># \u30c6\u30fc\u30d6\u30eb\u30c7\u30fc\u30bf\u3092zcat\u3067\u5c55\u958b\u3057\u306a\u304c\u3089\u3001\u5404\u30c6\u30fc\u30d6\u30eb\u3054\u3068\u306b\u4f5c\u6210\u3057\u305fawk\u30b9\u30af\u30ea\u30d7\u30c8\u3092fifo\u306b\u6d41\u3057\u8fbc\u3080<br \/>\nzcat ${TABLE}.tbl.gz | awk -f csvTojson_${TABLE}.awk >  ${TABLE}.fifo<\/p>\n<p># \u30ec\u30b3\u30fc\u30c9\u4ef6\u6570\u3092\u8abf\u3079\u3066\u7d42\u308f\u308a\uff08Hive\u4fbf\u5229\uff01\uff09<br \/>\necho &#8220;${TABLE} count `date`&#8221;<br \/>\ntd query -d dbt3 -w &#8220;select count(*) from ${TABLE}&#8221;<\/p>\n<p>rm -f ${TABLE}.fifo<\/p>\n<p>echo &#8220;${TABLE} import done `date`&#8221;<\/p>\n<p>done<\/p>\n<\/div>\n<p>\u203blineitem\u3068orders\u306f\u5c65\u6b74\u3063\u307d\u3044\u306e\u3067\u5225\u306e\u7d61\u3080\u3092-t\u3067\u6307\u5b9a\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>lineitem\u3000\u2192\u3000L_SHIPDATE<br \/>\norders\u3000\u2192\u3000 O_ORDERDATE<\/p>\n<p>\u30ed\u30fc\u30c9\u5f8c\u306b\u30c6\u30fc\u30d6\u30eb\u30c7\u30fc\u30bf\u3092\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<div class=\"command\">\n<p>$ td table:list dbt3<br \/>\n+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+<br \/>\n| Database | Table    | Type | Count     | Size    | Schema |<br \/>\n+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+<br \/>\n| dbt3     | customer | log  | 4500000   | 0.2 GB  |        |<br \/>\n| dbt3     | lineitem | log  | 179998372 | 3.0 GB  |        |<br \/>\n| dbt3     | nation   | log  | 25        | 0.0 GB  |        |<br \/>\n| dbt3     | orders   | log  | 45000000  | 1.2 GB  |        |<br \/>\n| dbt3     | part     | log  | 6000000   | 0.1 GB  |        |<br \/>\n| dbt3     | partsupp | log  | 24000000  | 0.7 GB  |        |<br \/>\n| dbt3     | region   | log  | 5         | 0.0 GB  |        |<br \/>\n| dbt3     | supplier | log  | 300000    | 0.01 GB |        |<br \/>\n+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+<br \/>\n8 rows in set<\/p>\n<p>\u78ba\u304b\u306b\u30c7\u30fc\u30bf\u91cf\u304c\u5897\u3048\u3066\u3044\u307e\u3059\u3002<br \/>\ncount(*)\u3057\u306a\u304f\u3066\u3082\u5143\u3005\u8a18\u9332\u3055\u308c\u3066\u308b\u3093\u3067\u3059\u306d\uff01\u77e5\u3089\u306a\u304b\u3063\u305f\u3002\u3002\u3002<\/p>\n<\/div>\n<p>\u4ee5\u4e0a\u3067\u3068\u308a\u3042\u3048\u305a\u306eimport\u306f\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n<p>\u3042\u3068\u306fDBT3\u306e\u30af\u30a8\u30ea\u3092\u79fb\u690d\u3057\u3066\u3001\u5b9f\u884c\u6642\u9593\u306e\u78ba\u8a8d\u3067\u3059\u306d\u3002<br \/>\nHive\u306a\u306e\u3067\u3001\u4fee\u6b63\u3057\u306a\u304f\u3066\u3082\u305d\u308c\u306a\u308a\u306b\u52d5\u304f\u3068\u306f\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u3061\u3089\u306e\u30d6\u30ed\u30b0\u3092\u53c2\u8003\u306b\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3057\u305f\u3002<br \/>\n\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\u3002<br \/>\n<a href=\"http:\/\/engineering.crocos.jp\/post\/26888868079\/treasure-data\">Treasure Data \u3067\u30e2\u30c6\u30e2\u30c6<\/a><br \/>\n<a href=\"http:\/\/doryokujin.hatenablog.jp\/entry\/2012\/06\/28\/011526\">Treasure Data Analytics \u7b2c3\u56de \u301c\u30d6\u30c3\u30af\u30ec\u30d3\u30e5\u30fc\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306b\u3088\u308b\u30c7\u30fc\u30bf\u89e3\u6790\u5165\u9580\uff08\u6e96\u5099\u7de8\uff09\u301c<\/a><br \/>\n\u2192\u3000\u3053\u3061\u3089\u4e2d\u306e\u65b9\u3067\u3059\u306d\uff01\uff1f<\/p>\n<p>\uff08\u8ffd\u8a181\uff09<br \/>\nimport\u6642\u306b\u3053\u3093\u306a\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u3053\u3068\u304c\u3002\u3053\u308c\u306f\u6539\u884c\u306e\u307f\u306e\u30ec\u30b3\u30fc\u30c9\u3067\u767a\u751f\u3057\u3066\u3044\u308b\u6a21\u69d8\u3002<br \/>\nJSON\u306f\u5c11\u306a\u304f\u3068\u3082\u5404\u30ec\u30b3\u30fc\u30c9\u304c16byte\u4ee5\u4e0a\u5fc5\u8981\u3068\u3044\u3046\u3053\u3068\u304b\u306a\uff1f<\/p>\n<div class=\"command\">\n<p>  skipped: A JSON text must at least contain two octets!: &#8220;\\n&#8221;<\/p>\n<\/div>\n<p>\uff08\u8ffd\u8a182\uff09<br \/>\n\u30ec\u30b3\u30fc\u30c9\u306eimport\u304c\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u3067\u5931\u6557\u3057\u3066\u3044\u305f\u306e\u3067\u3001\u8abf\u3079\u3066\u307f\u305f\u3068\u3053\u308d\u3001import\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u306e\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u306e\u9805\u76ee\u304cUNIXTIME\u3060\u3063\u305f\u306e\u304c\u99c4\u76ee\u3060\u3063\u305f\u307f\u305f\u3044\u3002awk\u3067\u300cstrftime(&#8220;%Y\/%m\/%d %H:%M:%S&#8221;, systime())\u300d\u306e\u6642\u9593\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3057\u3001\u305d\u3053\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u89e3\u6d88\u3057\u307e\u3057\u305f\u3002<\/p>\n<div class=\"command\">\n<p>  skipped: argument out of range<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u306f\u5642\u306e\u30d3\u30c3\u30b0\u30c7\u30fc\u30bf\u7684\u306a\u30b7\u30b9\u30c6\u30e0\u306e\u30a4\u30f3\u30d5\u30e9\u95a2\u9023\u306b\u3082\u624b\u3092\u51fa\u3057\u3064\u3064\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u6c17\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u304cTreasure Data\u306a\u306e\u3067\u3059\u3002 \u4f55\u3068\u8a00\u3063\u3066\u3082500GB\u307e\u3067\u3001\u7121\u6599\u3067\u30af\u30e9\u30a6\u30c9\u578b\u306eHadoop\u304c\u4f7f\u3048\u308b\u3068\u3044\u3046\u306e\u304c\u304a\u8a66\u3057\u306b\u306f&hellip;&nbsp;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","footnotes":""},"categories":[24,22,8,1],"tags":[42],"_links":{"self":[{"href":"https:\/\/a23187.yorozuyah.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1123"}],"collection":[{"href":"https:\/\/a23187.yorozuyah.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/a23187.yorozuyah.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/a23187.yorozuyah.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/a23187.yorozuyah.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1123"}],"version-history":[{"count":37,"href":"https:\/\/a23187.yorozuyah.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1123\/revisions"}],"predecessor-version":[{"id":1202,"href":"https:\/\/a23187.yorozuyah.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1123\/revisions\/1202"}],"wp:attachment":[{"href":"https:\/\/a23187.yorozuyah.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/a23187.yorozuyah.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/a23187.yorozuyah.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}