ðŒãã³ãéã®æ¬ ç¹ãšå©ç¹ðŒ
é¢æ±ã§ã¯å°é¢šæ¥æ¥ã§ããã
颚éšãåãã£ããã©ãä»ã¯äžäŒã¿ãªæãã§ãã
ãããŠè¡šé¡ããããPandasãã§ãã
åé¡ã¯æ¬äœãã®ãã®ã ããããªããã§ããã©ãããã€ãã®ã©ã€ãã©ãªã£ãŠãããã°ã ããã§ãããã
ãããªæžãåºãããå§ãŸã£ãŠããŸãããååã®æçš¿ã®çŽæéãã§è«žã åæ£ååŠçãœãªã¥ãŒã·ã§ã³ãè©Šããããšã§ãã³ãéã§ãããåŠçããã«åœãã£ãŠãåºæ¥ãäºãããåºæ¥ãªãäºããããããªããŸããã
å
ãã¯ãäœæ
ãããã£ãã¢ãããŒããèããã«è³ã£ããïŒã§ããã©ãããããä»ã®ãµã³ãã«ããŒã¿ããç¹åŸŽéãç®åºã«åœãã£ãŠãå°æ¹ç«¶éŠ¬ã¯ã幎éã¬ãŒã¹åºèµ°éŠ¬ãšããŠ13äžïœ14äžä»¶ãã®èšç®ãããªããã°ãªããªãèš³ã§ãã
äœãèšããããïŒã§ãããç¹åŸŽéã®äžã€ãšããŠããéå¬ã¬ãŒã¹æ¯ã®çé ãšãèµ°ç Žã¿ã€ã ãã®å·®åïŒãŸãåçŽã«ç³ããšç§çå·®ãªdiffã§ãïŒãåãå¿
èŠããããŸãã
ãã®ã¬ãŒã¹ïŒçé ããšã®å·®åããŒã¿ãšèšãæ±ããããããŒã¿ã¯ãã®ç§ç差以å€ã«2ã€ãéœåã§3çš®é¡ãç·æ°ãšããŠ13ïœ14äžä»¶ã§è¡ãå¿
èŠããããŸãã
åçŽèšç®ã§è¡ããšã3åãããšåŠçç·æ°ã¯40äžä»¶è¶
ãšãªããŸãã
ããŠãããããªã®ã¬ãŒã¹æ¯ã§group byããŠðŒã®diffã©ã€ãã©ãªã§ç®åºããã°ç°¡åãããïŒããšæãã§ãããïŒïŒ
ããã以åã話ãããããã®ã©ã€ãã©ãªã®ãååŸå·®åè£å®ãã°ãã®ããã§1çãšæäžäœã®å·®åã«NULLïŒèŠã¯ç©ºçœå€ïŒã代å
¥ããããšãããããŒã¿åæã§ã¯æããŸãããç²æ«ãªä»æ§ãå€æããèš³ã§ã(ÂŽ;Ï;ïœ)
åœç¶ãè£å®ããçºã«ã€ãã©ãã«åŠçã§2è¡ç®-1è¡ç®ãã¬ãŒã¹æ¯ã§æžç®åŠçãšããŠè¡ããŸãããïŒïŒ
ã¯ãããã®ã€ãã¬ãŒã·ã§ã³ã§ãããã13äžä»¶ã®åŠçãšãªããšãã¡ããã£æéãæãããèš³ã§ãã
æ£ã«ããã«ããã¯ã
ãªã®ã§ã以äžã®æœçãèããŸããã
ïŒïŒå°ããªãã£ã³ã¯ã«åŠçãåããïŒåŠçãå°åãã«ãããïŒ
ïŒïŒåŠçãã®ãã®ããã«ãã¹ã¬ããããŠäžŠååãã
ïŒïŒãã«ãããã»ãã·ã³ã°ã§3èŠçŽ ãåããŠåŠçãè¡ãã
å¿è«ãåŠçã¯ã¬ãŒã¹IDã®åŠçãåãåããšãªãçºã«ãã¿ã¹ã¯ããšã®æä»åŠçã§ããlockã掻çšããããšã«ããŸããã
ãã§ããã®ðŒã
ããšåæ£åã«æŒããŠé£ããèšç®åŠçãç©åãèŠæã®ããã§ããåäžèŠçŽ ã§ã®ã€ãã¬ãŒã·ã§ã³ã§ã¯åé¡ãªãåããŸãã
ããããããã§ã¯çé ãã¬ãŒã¹éã®èšç®ãããã¡ãæ··ããªå·®åèšç®ãããããšã«ãªããæå³ããããŸããã
ãã³ãééã©ãã¯åŠçåæ£ã«éãããgroup byèŠçŽ ãå¢ãããããªæšªäž²åŠçãšãè¡ã«å¯Ÿãã瞊䞲åŠçããæãããšããå®å
šã«çã£ãèšç®ãè¡ãèš³ã§ãã
ãã£ã³ã¯ïŒlockâéè€åºãŸããããããããlockããæå³ãæããªãâåŽäž
ãã«ãã¹ã¬ããïŒããã€ãlockããŠãŠéè€ã§ãŸããâåŽäž
ãã«ãããã»ãã·ã³ã°ïŒrace_idã£ãŠããããïŒindexããïŒïŒ
ãããããããããããåãã€ã³ããªãªãŒããã³ããªã³ã°ã§è¯ãã§ããïŒ
ãããããããããããrace_id:1åŠçå®è¡ïŒå·®åã®å€ã¯0代å
¥ïŒïŒ
ãããããããããããããççŸã ãïŒã»ãªã¹ã¿ãã¯ãã¬ãŒã¹åºããïŒ
ãããããããããããâ䜿ãããã°ã£ãããâââãªåŽäž
ããã€ãæ¬åœæããæã£ãŠåŠçã®ä»æ¹ããã«æãã ãªïŒæïŒ
Dask䜿ã£ãã倧èŠæš¡ãããããããã ããïœâåŠçæ¢ãŸãã
ãããããðŒãšã¯äžç·ç»ã軜ããRayãã§äžŠååã ïŒïŒ
ããããã°âŠããããã§èããŠãã¿ãïŒïŒ
æ ¹æ¬çãªã€ãã¬ãŒã·ã§ã³ã¯ãðŒã¡ããåŠçã§ããã©ããã(ÂŽ;Ï;ïœ)
ãããè©°ãã ïŒèŠç¬ïŒ
ãã¯ããçµäºïœïœïœïœïŒïŒã
æ ¹æ¬ã§ããããããäœãããðŒèµ·å ãªãã§ãã
å¿ã
ããðŒééå
±ãããããšããèš³ã§åæ£åããŠããã«ããã¯è§£æ¶æ¡ã¯
çµå±è«ŠããŸããã
ãã°æ¹ä¿®ããåŠçæ¹æ³ãå€ããããããããããäžã€ãã€æœ°ããŠãããšççãªæéãæããããã®éã«åŠçã¯åæã«çµãã£ãŠãã
èŠã¯ãã®ðŒéã¯ãè€éãªèšç®åŠçïŒå€§èŠæš¡åŠçããïŒæ¬¡å
çèšç®ã®ããã«çµã¿åããããšçŽãã«ããããã¢ãŠããããšããäœãšã䜿ããªãå±éºèŠçŽ ãåãã ããã«ãŠã§ã¢ãªã®ã§ããããã¯numpy䜿ã£ãŠãŠãã§ãïŒïŒïŒâ次ã®æçš¿ãã芧ãã ãã<(_ _)>ïŒ
ãããã䜿ããªãç¹ããšããæ以ã§ããããŸãã
ã§ãããã®ðŒãããŽããœãªããŒã¿ãåŒã£åŒµã£ãŠããã®ã«ããã®ã€ã³ããã¯ã¹åŠçãšããåé¡ç¹ãéã«åããŠæ¥œãªãã§ããïŒ
ãããåãã䜿ããç¹ããªã®ã§ãã
ãã£ã¡ãåãã°ããã£ã¡ãåããªããããšããç§ã®æ¬²ããèšç®åŠçã®åçŸæ§ãðŒäœ¿ããšã·ã³ã°ã«ããã»ã¹ã§ããåããªããšããäºã«è³ã£ãããã§ãã
ãããªç¹ç°äœè³ªãæã€ãã®ðŒãããæŽã«æŽ»èºã§ããã䜿ããç¹ãããããŸãã
ãã®ã€ã³ããã¯ã¹åŠçãšèšãã®ãããœã§ãã
ããã¯éžå°çšãšèšããåäžåŠçç¹ååã¶ã¯ãªæãã§ãããäœãšãããç©åãåãçºæ®ããã®ã§ãã
ãããåãŠã®ãã¬ãŒã ãªã¬ãŒã®ãªãŒã«ããã¯ãããžãCOBOLã¿ãããªååž°åŠçã深淵èšç®ãå€ããããåŠçã«ã¯æé«ãªããã«ãŠã§ã¢ã ã£ããããŸãã
ç§ãååž°åŠçã極ããŠå€ãã2äžè¡ã®åå²èšç®åŠçããå®è¡ã³ãã³ãäžçºrunããªãœãŒã¹ã³ãŒããäœã£ãŠèµ°ãããŠãããŸãã
ããã¯é ãäžãããŸããããã®åŠçèšç®ã¯ðŒããæãåŸãŸããã
å¿è«ãªã®ã§ããååž°åæ°ã«ã¯éçãããã®ã§ã調æŽããªããåŠçããããŸãããïœã
ãããäžçŽéçºè ã®ä»¥äžã®æ¹ã ãªãã解ãããšåããŸããããã®ã«ã¿ã«ã·ã¹ã«ãã£ãŠèŠäºãã®ç¬éãæµåããåŠçãåšã£ããšããäºã§ãã
éåæåŠçã¯ä»¥åèªã£ãéãã§ãããã¹ã¯ã¬ã€ãã³ã°åŠçããã«ã¯éåžžã«åããŠããŸãã
ãã ããã§ãidã®éè€ãç¡ãããã«æä»åŠçãªlockãæããŠã¿ã¹ã¯ããšã®åæ£ååŠçãèšèšããããšããå§ãããŸãã
ããã§ã¯ãåã§ãïŒïŒ