Haquetã®Parquet
ãã¡ã€ã«ã®ããŒã¿ã¹ãã¬ãŒãžã«é¢ããæ
å ±ã¯ããŸããªãããã
WrikeãSparkãšçµã¿åãããŠå®è£
ããçµéšã«ã€ããŠã®ã¹ããŒãªãŒã圹ç«ã€ããšãé¡ã£ãŠããŸãã
ç¹ã«ããã®èšäºã§ã¯æ¬¡ã®ããšãåŠã³ãŸãã
-ãªããå¯æšçŽ°å·¥ããå¿
èŠãªã®ã§ããã
-ä»çµã¿
-ãã€äœ¿çšãããã
-ãã®å ŽåãããŸã䟿å©ã§ã¯ãããŸããã
ããããã質åããå§ãã䟡å€ããããŸããäºåéèšã®ä»£ããã«ããŒã¿ãä¿åããçµæãããŒã¿ããŒã¹ã«ä¿åããæ°ããæ¹æ³ãæ¢ãå§ããã®ã¯ãªãã§ããã決å®ãäžãéã«ã©ã®ãããªåºæºãç§ãã¡ãå°ããŸãããïŒ
Wrikeåæéšéã§ã¯ãããã°ããŒã¿ãæäœããããã®ã¹ã±ãŒã©ãã«ã§æé·äžã®ããŒã«ã§ãã
Apache Sparkã䜿çšããŸãïŒçä¿¡ããŒã¿ãšã€ãã³ãã®ããŸããŸãªãã°ããã®ä»ã®ã¹ããªãŒã ããããŸãïŒã
以åã« Sparkãã©ã®ããã«æ©èœããã
ã«ã€ããŠè©±ããŸãã ã
æåã¯ãã€ã³ãã©ã¹ãã©ã¯ãã£ãããŸãæŽç·Žããã«ã·ã¹ãã ãè¿
éã«ãããã€ãããã£ãã®ã§ãã¹ã¿ã³ãã¢ãã³Sparkã®ã¯ã©ã¹ã¿ãŒãããŒãžã£ãŒãšJsonãèšè¿°ãããããã¹ããã¡ã€ã«ã«éå®ããããšã«ããŸããã åœæã倧ããªå
¥åããŒã¿ã¹ããªãŒã ã¯ãªãã£ãããã
hadoopãªã©ããããã€ã
ãŸã ã æå³ããããŸããã§ããã
åæ段éã§ã©ã®ãããªç»åããã£ããã«ã€ããŠïŒ- æå°éã®ãã¯ãããžãŒã¹ã¿ãã¯ã§å¯ŸåŠããã·ã¹ãã ãã§ããéãã·ã³ãã«ã«ããããšãããããããã«Sparkãhadoopã Cassandra ãMongoDBãããã³ç¹å¥ãªç®¡çãå¿
èŠãªãã®ä»ã®ã¹ãã¬ãŒãžã¡ãœããã®äžã«çœ®ããŸããã ç§ãã¡ã®ãã£ã¹ã¯ã¯éåžžã«æ©æã§ãããŒã¿ãããŒã«ããŸã察å¿ããŠããŸããããã«ãã¯ã©ã¹ã¿ãŒå
ã®ãã·ã³ã¯äºãã«è¿ãã«ããã匷åãªãããã¯ãŒã¯ã€ã³ã¿ãŒãã§ãŒã¹ã§æ¥ç¶ãããŠããŸãã
- å
¥åããŒã¿ã®æ§é ãäžååã ã£ããããæ®éçãªã¹ããŒã ãéžæããããšã¯å°é£ã§ããã
- æ°ããã€ãã³ããåžžã«è¿œå ãããŠãŒã¶ãŒã¢ã¯ãã£ããã£ã®è¿œè·¡ãæ¹åãããããã¹ããŒã ã¯æ¥éã«é²åããŸããããã®ãããããŒã¿åœ¢åŒãšããŠjsonãéžæãããã¬ãŒã³ããã¹ããã¡ã€ã«ã«å
¥ããŸããã
- ã€ãã³ãããŒã¹ã®åæã«è¿ã¥ããããšããŸããã ãŸãããã®å Žåãåã€ãã³ãã¯ãçµåæäœã®æ°ãæå°éã«æããããã«ãå¯èœãªéãæ
å ±ãå
å®ãããå¿
èŠããããŸãã å®éã«ã¯ãããŒã¿ãšã³ãªããã¡ã³ãã«ãããåè·¯å
ã®åããŸããŸãçæãããŸãïŒããã¯éèŠãªãã€ã³ãã§ãããããã«æ»ããŸãïŒã ããã«ãå®å
šã«ç°ãªãçš®é¡ã®å€æ°ã®ã€ãã³ããçžäºæ¥ç¶ãããããŸããŸãªãã©ã¡ãŒã¿ãŒã«ãã£ãŠç¹åŸŽä»ããããŠãããããåè·¯ãå€æ°ã®åãååŸããæ
å ±ã¯å®å
šã«æŸé»ãããŸããã
- ç§ãã¡ã¯äžå€ã®ããŒã¿ã§äœæ¥ããŸãããèšé²ããŠããããã èªã¿ãŸããã
æ°é±éã®äœæ¥ã®åŸãjsonããŒã¿ã®æäœã¯äžäŸ¿ã§æéããããããšã«æ°ä»ããŸãããããã«ãèªã¿åããé
ããããã«å€æ°ã®ãã¹ããªã¯ãšã¹ãããããããSparkãæåã«ãã¡ã€ã«ãèªã¿åã£ãŠã¹ããŒã ã決å®ãããã®åŸã§ãªã¯ãšã¹ãèªäœã«çŽæ¥ã¢ã¯ã»ã¹ããå¿
èŠããããŸãã ãã¡ãããäºåã«ã¹ããŒã ãæå®ããããšã§Sparkã®ãã¹ãçãããããšãã§ããŸãããæ¯åãã®è¿œå äœæ¥ãè¡ããããããŸããã§ããã
Sparkã調ã¹ãŠã¿ããšã圌èªèº«ãå¯ãæšçŽ°å·¥ã®åœ¢åŒãç©æ¥µçã«äœ¿çšããŠããããšãããããŸããã
å¯æšçŽ°å·¥ãšã¯
Parquetã¯ãããšããšhadoopãšã³ã·ã¹ãã çšã«äœæããããã€ããªã®åæåã®ããŒã¿ã¹ãã¬ãŒãžåœ¢åŒã§ãã éçºè
ã¯ããã®ã¹ãã¬ãŒãžåœ¢åŒãããã°ããŒã¿ïŒäžå€ïŒã«æé©ã§ãããšäž»åŒµããŠããŸãã
æåã®å°è±¡ã¯æ声ã§ãããSparkã§äœæ¥ããã®ããããã䟿å©ã«ãªããŸãããçãè¿ã£ãã°ããã§ãããäžæè°ãªããšã«ãäºæãã¬åé¡ãçºçããŸããã å®éãå¯ãæšåŒµãã¯äžå€ã®ããŒãã«ãŸãã¯ããŒã¿ããŒã¹ã®ããã«åäœããŸãã ãã®ãããåã«å¯ŸããŠåãå®çŸ©ãããŠãããè€éãªããŒã¿åïŒãã¹ããããjsonãªã©ïŒãšåçŽãªïŒéåžžã®æååå€ïŒãçªç¶çµã¿åããããšãã·ã¹ãã å
šäœã厩å£ããŸãã ããšãã°ã2ã€ã®ã€ãã³ããååŸããJson圢åŒã§æžã蟌ã¿ãŸãã
{
âevent_nameâ: âevent 1â,
âvalueâ: âthis is first valueâ,
}
{
âevent_nameâ: âevent 2â,
âvalueâ: {âreasonâ: âOkâ}
}
æåã®ã±ãŒã¹ã«ã¯æååãããã2çªç®ã®ã±ãŒã¹ã«ã¯è€ååããããããããããå¯æšçŽ°å·¥ã®ãã¡ã€ã«ã«æžã蟌ãããšã¯ã§ããŸããã ããã«æªãããšã«ãã·ã¹ãã ãå
¥åããŒã¿ã¹ããªãŒã ããã¡ã€ã«ã«æžã蟌ãå Žåãããšãã°1æéããšã«ã æåã®1æéã¯æååå€ãæã€ã€ãã³ããçºçãã2çªç®ã®æéã«ã¯è€ååã®åœ¢åŒã§ã€ãã³ããçºçããŸãã ãã®çµæããã¡ããå¯æšçŽ°å·¥ã®ãã¡ã€ã«ãäœæããããšã¯å¯èœã§ãããã¹ããŒãã®ããŒãžæäœäžã«åã®éäºææ§ãšã©ãŒãçºçããŸãã
ãã®åé¡ã解決ããã«ã¯ãå°ã劥åããå¿
èŠããããŸããã æ
å ±ã®äžéšã«ã€ããŠãããŒã¿ãããã€ããŒã¹ããŒã ã«ãã£ãŠããç¥ããä¿èšŒãããŠãããã®ã決å®ããæ®ãã¯äžäœã¬ãã«ã®ããŒã®ã¿ãååŸããŸããã åæã«ãäžèšã®äŸã®å ŽåãããŒã¿èªäœã¯ããã¹ãïŒå€ãã®å ŽåãjsonïŒãšããŠèšé²ãããã»ã«ã«ä¿åãããŸããïŒåŸã§ãåçŽãªmap-reduceæäœã®å©ããåããŠã䟿å©ãªDataFrameã«ãªããŸããïŒã Ok "} 'turns into'" value "ïŒ" {\â reason \âïŒ\â Ok \â}â ' ãŸããããŒã¿ãSparkã®ããŒãã«åå²ããæ©èœã«ãééããŸããã
Parquetãã¡ã€ã«æ§é ã¯ã©ã®ããã«èŠããŸãã
å¯æšçŽ°å·¥ã¯ãjsonãå
éšã«å«ãåãããã¹ããã¡ã€ã«ãšæ¯èŒãããšãããªãè€éãªåœ¢åŒã§ãã
ãã®ãã©ãŒãããã¯ãGoogleã®éçºãã€ãŸãDremelãšåŒã°ãããããžã§ã¯ã
ã§ãå®çããããšã¯æ³šç®ã«å€ããŸã-ããã¯
Habréã§ãã§ã«
èšåãããŠããŸãã ãDremelã®èéã«ã¯å
¥ããŸããã誰ã§ãããã§èªãããšãã§ããŸãïŒ
research.google.com /pubs/pub36632.htmlèŠããã«ãParquetã¯
ãå®çŸ©ã¬ãã«ããš
ãç¹°ãè¿ãã¬ãã«ãã«åºã¥ããã¢ãŒããã¯ãã£ã䜿çšããŠãããããããŒã¿ã®éåžžã«å¹ççãªã³ãŒãã£ã³ã°ãå¯èœã«ãªããã¹ããŒã ã«é¢ããæ
å ±ãå¥ã®ã¡ã¿ããŒã¿ã«è»¢éãããŸãã
ãã®å Žåã空ã®å€ãæé©ã«ä¿åãããŸãã
å¯æšçŽ°å·¥ã®ãã¡ã€ã«ã®æ§é ã¯
ãããã¥ã¡ã³ãã§è©³ãã説æã
ããŠããŸã ã
ãã¡ã€ã«ã¯ããã€ãã®ã¬ãã«ã«åå²ãããŠããããã®äžã§éåžžã«å¹æçãªæäœã®äžŠåå®è¡ãå¯èœã§ãã
è¡ã°ã«ãŒãã¯ãMap-Reduceã¬ãã«ã§äžŠè¡ããŠããŒã¿ãæäœã§ããããŒãã£ã·ã§ã³ã§ã
åãã£ã³ã¯ -IOæäœãåæ£ã§ããåã¬ãã«ã®ããŒãã£ã·ã§ã³
ããŒãž -åã®ããŒãžåå²ãã³ãŒãã£ã³ã°ãšå§çž®ã®äœæ¥ãåæ£ã§ããŸã
éåžžã®ãã¡ã€ã«ã·ã¹ãã ã䜿çšããŠå¯æšçŽ°å·¥ã®ãã¡ã€ã«ã®ããŒã¿ããã£ã¹ã¯ã«ä¿åãããšããã¡ã€ã«ã®ä»£ããã«ããã¡ã€ã«ã®ã³ã¬ã¯ã·ã§ã³å
šäœãå«ããã£ã¬ã¯ããªãäœæãããããšãããããŸãã ãããã®äžéšã¯ã¡ã¿æ
å ±ã§ããããã€ã¢ã°ã©ã ã§ã¯ãèŠæ±ã«å¿ããŠå¿
èŠãªããŒã¿ãããã¯ã®ã¿ãèªã¿åãããšãã§ããéšåã€ã³ããã¯ã¹ãå«ãããŸããŸãªãªãŒããŒãããæ
å ±ã§ãã æ®ãã®éšåãã€ãŸãããŒãã£ã·ã§ã³ã¯ãè¡ã°ã«ãŒãã§ãã
çŽæçã«ç解ã§ããããã«ã
è¡ã°ã«ãŒãã¯å
±éã®æ
å ±ã§çµåããããã¡ã€ã«ã®ã»ãããšèŠãªããŸãã ãšããã§ãHDFSã¯ãã®ããŒãã£ã·ã§ã³ã䜿çšããŠãã¯ã©ã¹ã¿ãŒå
ã®åããŒãããã£ã¹ã¯äžã«çŽæ¥é
眮ãããŠããããŒã¿ãèªã¿åãããšãã§ããå ŽåãããŒã¿ã®å±ææ§ãå®è£
ããŸãã ããã«ãè¡ã°ã«ãŒãã¯Map ReduceãŠããããšããŠæ©èœããSparkã®åmap-reduceã¿ã¹ã¯ã¯ç¬èªã®è¡ã°ã«ãŒãã§åäœããŸãã ãã®ãããã¯ãŒã«ãŒã¯è¡ã®ã°ã«ãŒããã¡ã¢ãªã«é
眮ããå¿
èŠããããã°ã«ãŒãã®ãµã€ãºãèšå®ãããšãã¯ãæã匱ãããŒãã®ã¿ã¹ã¯ã«å²ãåœãŠãããæå°ã¡ã¢ãªéãèæ
®ããå¿
èŠããããŸããããããªããšãOOMã«ã€ãŸãããŸãã
ç§ãã¡ã®å Žåãç¹å®ã®æ¡ä»¶äžã§ããã¹ããã¡ã€ã«ãèªã¿åãSparkã1ã€ã®ããŒãã£ã·ã§ã³ã®ã¿ã圢æãããšããäºå®ã«çŽé¢ããŸããããã®ãããããŒã¿å€æã¯1ã€ã®ã³ã¢ã§ã®ã¿å®è¡ãããŸããããã¯ããã«å€ãã®ãªãœãŒã¹ãå©çšã§ããŸããã rddã®åããŒãã£ã·ã§ã³æäœã䜿çšããŠãå
¥åãå£ããããã€ãã®è¡ã°ã«ãŒããäœæããåé¡ã¯ãªããªããŸããã
åãã£ã³ã¯ ïŒåã¬ãã«ã§ã®ããŒãã£ã·ã§ã³åå²ïŒ-ãã£ã¹ã¯ã§ã®äœæ¥ãæé©åããŸãã ããŒã¿ãè¡šãšããŠè¡šç€ºããå Žåãè¡ã§ã¯ãªãåã«èšé²ãããŸãã
ããŒãã«ãæ³åããŠãã ããïŒæ¬¡ã«ãcsvãªã©ã®ããã¹ããã¡ã€ã«ã«ã次ã®ããã«ããŒã¿ããã£ã¹ã¯ã«ä¿åããŸãã
å¯æšçŽ°å·¥ã®å ŽåïŒ
ããã«ãããå¿
èŠãªåã®ã¿ãèªã¿åãããšãã§ããŸãã
å®éãããŸããŸãªåã®ãã¡ãç¹å®ã®æç¹ã§åæã«å¿
èŠãªã®ã¯ãããããã§ãããã»ãšãã©ã®åã¯ç©ºã®ãŸãŸã§ãã Parquetã¯ãããŒã¿ãåŠçããããã»ã¹ãææå éããŸããããã«ããã®ãããªæ
å ±ã®æ§é åã¯ããã®å質æ§ãšé¡äŒŒæ§ã«ãããããŒã¿ã®å§çž®ãšãšã³ã³ãŒããç°¡çŽ åããŸãã
ååã¯
Pagesã«åå²ãããŸããPagââesã«ã¯ãDremelãããžã§ã¯ãã®ã¢ãŒããã¯ãã£ã®ååã«åŸã£ãŠãšã³ã³ãŒããããã¡ã¿æ
å ±ãšããŒã¿ãå«ãŸããŠããŸãã ããã«ãããããªãå¹ççã§é«éãªã³ãŒãã£ã³ã°ãå®çŸããŸãã ããã«ãå§çž®ã¯ãã®ã¬ãã«ã§å®è¡ãããŸãïŒæ§æãããŠããå ŽåïŒã çŸåšå©çšå¯èœãª
snappyãgzipãlzoã³ãŒããã¯ã
èœãšãç©Žã¯ãããŸããïŒ
ããŒã¿ã®ãå¯æšçŽ°å·¥ãã®çµç¹ã®ãããã¹ããªãŒãã³ã°ãæ§æããããšã¯å°é£ã§ããããŒã¿ã転éãããšãã°ã«ãŒãå
šäœãå®å
šã«æ§æãããŸãã ãŸããã¡ã¿æ
å ±ã倱ã£ãããããŒã¿ããŒãžã®ãã§ãã¯ãµã ãå€æŽããããããšãããŒãžå
šäœã倱ãããŸãïŒåã°ã«ãŒãã®å Žåãè¡ã°ã«ãŒãã®å Žåãåæ§ã«ãã°ã«ãŒãã倱ãããŸãïŒã ãã§ãã¯ãµã ã¯ããŒãã£ã·ã§ã³ã®åã¬ãã«ã§äœæãããããããã¡ã€ã«ã·ã¹ãã ã¬ãã«ã§èšç®ããªãã«ããŠããã©ãŒãã³ã¹ãåäžãããããšãã§ããŸãã
çµè«ïŒ
Parquetã®ããŒã¿ã¹ãã¬ãŒãžã®å©ç¹ïŒ- hdfsçšã«èšèšãããŠããŸãããããŒã¿ã¯GlusterFsãªã©ã®ä»ã®ãã¡ã€ã«ã·ã¹ãã ãŸãã¯NFSã®äžã«ä¿åã§ããŸã
- æ¬è³ªçã«ããããã¯åãªããã¡ã€ã«ã§ããã€ãŸããäœæ¥ã移åãããã¯ã¢ãããè€è£œãç°¡åã§ãã
- åãã¥ãŒã§ã¯ããã¹ãŠã®åãäžåºŠã«å¿
èŠãšããªãå Žåã«ã¢ããªã¹ãã®äœæ¥ã倧å¹
ã«å éã§ããŸãã
- Sparkã®æšæºãµããŒãã«ããããã¡ã€ã«ãç°¡åã«ååŸããŠãæ°ã«å
¥ãã®ã¹ãã¬ãŒãžã«ä¿åã§ããŸãã
- ã¹ãã¬ãŒãžã¹ããŒã¹ã®èŠ³ç¹ããå¹ççãªã¹ãã¬ãŒãžã
- å®è·µã瀺ãããã«ãä»ã®ãã¡ã€ã«åœ¢åŒã䜿çšããå Žåãšæ¯èŒããŠãæéã®èªã¿åãããã©ãŒãã³ã¹ãæäŸããã®ã¯ãã®æ¹æ³ã§ãã
çæïŒ- åãã¥ãŒã«ãããã¹ããŒã ãšããŒã¿åã«ã€ããŠèããããšãã§ããŸãã
- Sparkãé€ããŠãParquetã¯åžžã«ä»ã®è£œåã§ãã€ãã£ããµããŒããããŠããããã§ã¯ãããŸããã
- ããŒã¿ã®å€æŽãšã¹ããŒãã®é²åã¯ãµããŒãããŠããŸããã ãã¡ãããSparkã¯æéã®çµéãšãšãã«ã¹ããŒã ãå€æŽããå Žåãã¹ããŒã ãããŒãžã§ããŸãïŒãã®ãããèªã¿åãæã«ç¹å¥ãªãªãã·ã§ã³ãæå®ããå¿
èŠããããŸãïŒããæ¢åã®ãã¡ã€ã«ã®äœããå€æŽããã«ã¯ãæ°ããåãè¿œå ã§ããªãéããäžæžãããã«è¡ãããšã¯ã§ããŸããã
- ãã©ã³ã¶ã¯ã·ã§ã³ã¯éåžžã®ãã¡ã€ã«ã§ãããããŒã¿ããŒã¹ã§ã¯ãªãããããã©ã³ã¶ã¯ã·ã§ã³ã¯ãµããŒããããŠããŸããã
Wrikeã§ã¯ãå¯ãéãã®ã€ãã³ãããŒã¿ã®æ ŒçŽå ŽæãšããŠé·ãéå¯æšçŽ°å·¥ã®ãã¡ã€ã«ã䜿çšããŠãããã¢ããªã¹ãã¯æ¯æ¥éåžžã«å€ãã®ãªã¯ãšã¹ããéä¿¡ããŠããŸãããã®æè¡ã䜿çšããããã®ç¹å¥ãªãã¯ããã¯ãéçºããã®ã§ãè©ŠããŠã¿ãã人ãšçµéšãå
±æã§ããŸãå¯ãæšçŽ°å·¥ã䜿çšããŠãã³ã¡ã³ãã®ãã¹ãŠã®è³ªåã«çããŸãã
PSãã¡ãããåŸã§ããŒã¿ã¹ãã¬ãŒãžã®åœ¢åŒã«é¢ããèŠè§£ãç¹°ãè¿ãæ¹èšããŸãããããšãã°ãããäžè¬çãªAvro圢åŒã«ã€ããŠã¯ã¢ããã€ã¹ãåããŸããããä»ã®ãšããäœãå€æŽããç·æ¥ã®å¿
èŠã¯ãããŸããã
è¡æåããŒã¿ãšåæåããŒã¿ã®éãããŸã ç解ããŠããªã人ã®ããã«ã
Clouderaã®åªãããããªããããŸãã
åæçšã®ããŒã¿ã¹ãã¬ãŒãžåœ¢åŒã«é¢ããããé¢çœã
ãã¬ãŒã³ããŒã·ã§ã³ããããŸãã