MapReduceã®ããä¸ã¤ã®ä½¿ãæ¹
MapReduceã¨ããã¨éè¨ã«ä½¿ãã¢ãã¨ãã人ãå¤ãã¨æãã
ãªãã¨ãªãã°ãMapReduceï¼Hadoopï¼ã¯ã¼ãã«ã¦ã³ãã®å³å¼ã«ãªã£ã¦ããããã ã
å®éãHadoopã触ã£ã¦ã¿ããã¨ãã人ã®ã»ã¨ãã©ã¯exampleã¨ãã¦ã¯ã¼ãã«ã¦ã³ãã使ãã¯ãããã®è¾ºã«è½ã¡ã¦ãã·ã§ã¼ã¯ã¹ãã¢ã®ãã°ã§Hadoopã®exampleãåããã人ããããã¯ãã
ã¨ãããå®éã«æ¥åãããçãªå¦çãè¡ãã¨ãã«ãMapReduceã®å¹æçãªä½¿ãæ¹ã¯å¥ã«ããããå人çã¯ããæ¬å½ã®MapReduceã®ä½¿ããããã¯ãã£ã¡ã ã¨æãããªãã¨ãããã¨ã¯ãªãã¦ãçµã¿åããè¨ç®ãé«éã«è¡ããã ããã種ã®è¨ç®ã§ã¯ãé åºå¦çã§ã®ãã¢ãããã¦ãã¾ãã±ã¼ã¹ã®ä¸ã¤ã«çµã¿åããã®è¨ç®ããã
Node{ List<Node> nodeList value(){ hasNodeList() ? nodeList.traverse(value()) : process() -> upperNode() } }
ã¿ãããªã¢ãã«ã«ããã¦
process(ALL.Node.value());
ãå®è¡ãããããªã±ã¼ã¹ã ã
ããã¯RDBMSã§ã¯ç ´å£çã«ç¸æ§ãæªãã
Né層ãã«ãJoinã«ãªããå
¨é¨ã¡ã¢ãªã¼ã«ä¹ãåãã°åæã§ããããã©ã
éçãè¶
ããç¬éãDBã¯ã¢ããªã¹ã®ããã«é»ããå°ããªãã¼ã¿ã§è©¦ãã¦ããéé·ï¼ã§ãã¾ããï¼è¶
ãKã£ãï¼å®ç§ã£ãï¼ãã£ã¦æã£ã¦ãã人ãããã©åãæªãã£ãã®ã§ãåå¼ãã¦ãã ããããé¡ããã¾ãã
ãã¼ã¿æ§é çã«ã¯å¤§ããªã°ã©ããå½¢æãã¦ããã¨æãã°ãããã°ã©ãæ§é ã¨ããã¨å¼ãã¦ãã¾ã人ãããã¨æããã©ã話é¡ã®ã½ã¼ã·ã£ã«ãªããã¯å¤§æµã¯ã°ã©ãæ§é ãªã®ã§ãä»å¾ã¯é¿ãã¦éããªãã¨æãã
MapReduceããã¨ã©ããªããï¼ã£ã¦è©±ã ãã©ã»ã»ã»
Mapper{ List<Node> list list.map(process() -> Tuple<Key, UpperNode>) emit list<Tuple> }
ã°ãã¾ããNodeã§ä¸æã«è¨ç®ãã¦ããã®ä¸ä½ã®Nodeã®ãã¼ã¿ãæãã¦
Nodeã®ãªã¹ãã¤ããReducerã«ãããã
Reducer{ SortedList<Tuple> list list.fold(summerize() -> Node) emit Node }
Reducerã¯ããã£ãNodeãªã¹ãï¼MapReduceã®ãç´æã§ããã¯ã½ã¼ãããã¦ããï¼ãåãåã£ã¦ãNodeåä½ã§éè¨ããã
ãã¨ã¯MapâReduceã®ç¹°ãè¿ãã«ãªã
å°ãMapã«Reducerããå¦çã渡ãæã¯List
ãã®ã¢ãã«ã§ã¯å¤§æµã¯ããããStripesãã¿ã¼ã³ã使ã
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.169.6896&rep=rep1&type=pdf
ã®3ç« ããããåèã
ãã®Mapreduceã®ç¹å¾´ã¯ããã¤ã³ãã¯2ã¤ãã£ã¦ãä¸ã¤ã¯ä¸¦åå¦çãã§ããã¨ãããã¨ãåè¿°ã®å ´åã¯ãprocessï¼ALL.Node.value())ã¯
ã·ã¼ã±ã³ã¹ã«å¦çããããã¨ãå¤ããNodeãä¸åã¥ã¤å¦çããæãã§ãããããã§ã¯é
ãã§ããMapreduceã§ã¯åºæ¬çã«ä¸¦åã§å¦çãã§ãã¾ãã
ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã¨ã¾ããããã¾ã§ã¯æ®éã«æç§æ¸çãªè©±ã
ããã²ã¨ã¤ã¯
å®éã«æ¥åç³»ã§å©ç¨ããå ´åã«ãä¸å®ã®Nodeã§å¦çãã¹ãè¨ç®ãè¨ç®å¯è½ãã©ããå¤æããå¿
è¦ãããã¨ãããã¨ã§ãã
ä¾ãã°ãNodeã®è¨ç®ãåç §ãã¦ããå ã®Nodeã®ç¹å®ã®å¤ãéè¨ããå ´åãèãã¦ã¿ãããå¦çãè¡ãã¹ãNodeã®è¨ç®èªä½ã¯ãåç §å ã®Nodeããã®ãã¼ã¿ãåç §ãã¦æ¼ç®ãè¡ãããã®ã¨ããåç §å ã®Nodeã®è¨ç®ãçµäºãã¦ãããã¨ãæã¾ããã
ä»®ã«ãåç §å ã®Nodeã®è¨ç®ãã¾ã å®äºãã¦ããªã段éã§èªèº«ã®è¨ç®ãå®è¡ãã¦ãããã¯éä¸çµéã§ãããªãããã¹ã¦ã®ãã¼ãã®è¨ç®ã®çµæãå®äºããã¾ã§ç¹°ãè¿ãèªèº«ã®è¨ç®ãç¹°ãè¿ããã¨ã«ãªããã ãããèªèº«ã®è¨ç®ãå¯è½ãã©ããã®å¤æåå²ããè¨è¿°ãã¦ããå¿ è¦ãããã
å¿è«ãç¹°ãè¿ãè¨ç®ãã¦ãåé¡ããªãå ´åããããç¹ã«ã°ã©ãã®åç
§ã循ç°ãã¦ããå¯è½æ§ãé«ãå ´åã¯ãéã«ç¹°ãè¿ãè¨ç®ããã¦ãåé¡ããªãããã«ãã¶ã¤ã³ãã¦ããå¿
è¦ãããããã®ãããªå ´åã¯ãå¤ãä¸å®ã«ãªã£ã段éã§åæããã¨ãã風ã«èãããã¨ãå¤ãã
ï¼Googleã®PageRankã®è¨ç®ãªããã¯ä»£è¡¨ä¾ï¼
ãããã«ãããããç¨åº¦æ§é ãã¿ããã¢ãã§ããã°ãããã¯ç¡é§ãªè¨ç®ã«ãªãã注ç®ãã¹ãç¹ã¯ããã®ãããç¨åº¦æ§é ãè¦ããã¢ããã§ãããã©ããã®å¤æã ãç·ãã¦ããã¨ãå²ã¨ãã¼ã¿ã®é£ä¿ãã©ã³ãã ã¸ã£ã³ãã«è¿ãWebç³»ã®ãã¼ã¿ã¨éã£ã¦ãåºå¹¹ç³»ã®ãã¼ã¿æ§é ã¯ãæ§é ãæ´çããã¦ãããã®ãå¤ãã
ãã¤ãæ¥åç³»ã®å¦çã§ã¯ç¹°ãè¿ãè¨ç®ãã§ããªããããªã±ã¼ã¹ãå¤ããã¨ãããã»ã¨ãã©ã§ããä¾ãã°ãå¨åº«å¼å½ã®é£éå¦çã¨ããè¯ãä¾ã ã
å¨åº«ãã¼ãã®è¨ç®é åºã§å¼å½å¦çã®å
容ãå¤ããããã§ã¯ãããã«åé¡ã«ãªãã
ç¹°ãè¿ãã®è¨ç®ãã§ããªããããªå ´åï¼ããªãã¡è¨ç®çµæãå¤ãã£ã¦ãã¾ããããªï¼ã¯è¨ç®éå§æ¡ä»¶ãå ¥ããå¿ è¦ãããã
Mapper{ List<Node> list list.map(canProcess()? process() -> Tuple<Key, UpperNode> : skip()) emit list<Tuple> }
ã¨ãã風ã«ãè¨ç®éå§æ¡ä»¶ãè¨å®ãããã¨ãå¿
è¦ã«ãªãã
è¨ç®ãå®äºãã段éã§ãèªèº«ãEndNodeã¨è¨å®ãã¦ãä¸ä½ã«ä¼æãããã
ããã«ããåä¸ã®ãã¼ãã§ã®è¨ç®ã¯ä¸åã§æ¸ããï¼ãã ãããæ¨å¯ã®ã¨ãããç¹å®ã«Nodeã«çµç·ãéä¸ãããããªã°ã©ãæ§é ã®å ´åã¯ãã®Nodeã確å®ã«ããã«ããã¯ã«ãªããããã¯è¦æ³¨æããã®å ´åã¯ãããã並åæ§ãä½ãã®ã§MapReduceèªä½ã®æ¡ç¨ãåæ¤è¨ããæ¹ãããï¼
canProcess()ãéå§æ¡ä»¶ã«ãªããã©ãä¸çªç¢ºå®ãªã®ã¯ãä¸ä½ã®Nodeåä½ã§è¨ç®çµæãåå¨ããã確èªãã¦ããã¨ãããã¨ã ãã
canProcess(nodeList.traverse(isEnded)))
ã¿ãããªæãã§ãè¯ãããNodeããçµç·ã«ãã¹ã¦ãã©ã°ãè¨å®ãã¦ããã¦ãããã
注æç¹ã¯2ç¹ãã£ã¦
ã²ã¨ã¤ã¯ãè¨ç®ãå®äºãããã©ãããã®å®ç¾©ãæ確ã«ãã¦ãããã¨ãããã¯è¨ç®ãããå¿
è¦ããªããã¨ãããã¨ãæ示çã«è¨ç®å®äºã¨åãã«ãã¦ãããªãã¨ãã¤ã¾ã§ãã£ã¦ãä¸ä½ã®è¨ç®ãå§ã¾ããªãã¨ãããã¨ã«ãªã£ã¦ãã¾ãã
ãµãã¤ãã¯æ¬å½ã«éå§æ¡ä»¶ãå¿ è¦ãããã®ãã¯ãåå³ããæ¹ãè¯ãã¨ãããã¨åãã¼ãã®ãã¼ã¿ã«ç¬ç«ãã¦è¨ç®ã¦ããå ´åã¯ãæ¡ä»¶ã¯å ¥ããªãæ¹ããããã¨ãå¤ãããã¯ã³ã¼ãèªä½ã¯ã·ã³ãã«ã«ãã¦ãã§ããéãåæã§å¦çãããæ¹ãããã¨ãããã¨ãæå³ãã¦ããã
çµé¨çã«ã¯åºå¹¹å¦çç³»ã®ã°ã©ããã¼ã¿ã¢ãã«ã§ã¯éå§æ¡ä»¶ãå²ã¨æ確ã«
åãã¼ãã«å²ãå½ã¦ãäºãå¯è½ã§ããã®ã§ããã®ææ³ã¯å²ã¨æå¹ã§ããã
ã½ã¼ã·ã£ã«ã°ã©ãã®ãããªãä¸å®ã®ã°ã©ãæ§é ãæ³å®ã§ããªããããªå ´åã¯éå§æ¡ä»¶ã¯å ¥ãããã¨ãã§ããªãã®ã§ããããè¨ç®ããã¼ãé åºã«ä¾åããªããã¸ãã¯ãçå®ããæ¹ãããã