{"id":268851,"date":"2015-11-24T09:50:03","date_gmt":"2015-11-24T06:50:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=268851"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=268851","title":{"rendered":"Apache Spark \u043a\u0430\u043a \u044f\u0434\u0440\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0427\u0430\u0441\u0442\u044c 1"},"content":{"rendered":"<p>       \u041f\u0440\u0438\u0432\u0435\u0442 \u043a\u043e\u043b\u043b\u0435\u0433\u0438. <br \/>  \u0421 \u043d\u0435\u0434\u0430\u0432\u043d\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0443 \u043d\u0430\u0441 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f Spark. \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0435\u0439, \u0438 \u0443\u0437\u043d\u0430\u0451\u043c \u043c\u043d\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e. \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0437\u043d\u0430\u043d\u0438\u044f, \u0438 \u0437\u0430 \u043e\u0434\u043d\u043e \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0438\u043c\u0438 \u0441 \u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0438\u043c\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0446\u0438\u043a\u043b \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Apache Spark. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0435\u0440\u0432\u0430\u044f, \u0438 \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u0432\u043e\u0434\u043d\u043e\u0439.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0418 \u0442\u0430\u043a, \u043f\u0440\u043e \u0441\u0430\u043c Spark \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0443\u0436\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0425\u0430\u0431\u0440\u0435 <a href=\"http:\/\/habrahabr.ru\/company\/mlclass\/blog\/250811\/\">\u0440\u0430\u0437<\/a> \u0438 <a href=\"http:\/\/habrahabr.ru\/post\/251507\/\">\u0434\u0432\u0430<\/a>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c\u0441\u044f.<br \/>  Apache Spark \u2014 \u044d\u0442\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u043e \u0441\u0432\u043e\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b Spark \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 API \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0445\u043e\u0434\u044f\u0442: \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430, \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435, \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044f, \u043f\u043b\u044e\u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0441\u044f\u043a\u0438\u0445 \u043c\u0435\u043b\u043e\u0447\u0435\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432 \u0446\u0435\u043b\u044f\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u043a\u043e\u0434\u0430.<br \/>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, Spark \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041e\u043d \u0441\u0430\u043c \u0440\u0430\u0441\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 \u0432\u0430\u0448 \u043a\u043e\u0434 \u043f\u043e \u0432\u0441\u0435\u043c \u0443\u0437\u043b\u0430\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430, \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442 \u043d\u0430 \u043f\u043e\u0434\u0437\u0430\u0434\u0430\u0447\u0438, \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043f\u043b\u0430\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438 \u0441\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0441\u0442\u044c\u044e. \u0415\u0441\u043b\u0438 \u043d\u0430 \u043a\u0430\u043a\u043e\u043c \u043b\u0438\u0431\u043e \u0443\u0437\u043b\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u043b \u0441\u0431\u043e\u0439, \u0438 \u043a\u0430\u043a\u0430\u044f \u0442\u043e \u043f\u043e\u0434\u0437\u0430\u0434\u0430\u0447\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0430\u0441\u044c \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u043e\u043d\u0430 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435-\u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430.<br \/>  \u0413\u0438\u0431\u043a\u043e\u0441\u0442\u044c Spark \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u0438 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0430\u0448\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b \u043f\u043e\u0434 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0440\u0430\u0437\u043d\u044b\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c:<\/p>\n<ul>\n<li><b>Stand-alone mode<\/b>. \u0412 \u044d\u0442\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 Spark, \u043e\u043d \u0441\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0441\u0435\u043c\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430, \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432\u0430\u0448\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/li>\n<li><b>Yarn<\/b>. \u042d\u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u0432\u0445\u043e\u0434\u044f\u0449\u0430\u044f \u0432 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0443 Hadoop. \u0412\u0430\u0448\u0435 spark-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e \u043d\u0430 Hadoop \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435, \u043f\u043e\u0434 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b.<\/li>\n<li><b>Mesos<\/b>. \u0415\u0449\u0435 \u043e\u0434\u043d\u0430, \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430. <\/li>\n<li><b>Local mode<\/b>. \u041b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c, \u0441\u043e\u0437\u0434\u0430\u043d \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0438, \u0447\u0442\u043e \u0431\u044b \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u0441 \u0432\u0430\u043c\u0438 \u0436\u0438\u0437\u043d\u044c. <\/li>\n<\/ul>\n<p>  \u0423 \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u0437\u0430\u0434\u0430\u0447 \u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 Spark \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u21161?<\/h3>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u043f\u043e\u0447\u0435\u043c\u0443 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c Spark \u0440\u0430\u0441\u0442\u0435\u0442, \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u043e\u043d \u0441\u0442\u0430\u043b \u0432\u044b\u0442\u0435\u0441\u043d\u044f\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u0434\u043e\u0431\u0440\u044b\u0439 Hadoop MapReduce (\u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e MR).<br \/>  \u0412\u0441\u0451 \u0434\u0435\u043b\u043e \u0432 \u043d\u043e\u0432\u043e\u043c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0443 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 MR \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u0414\u0435\u043b\u043e \u0442\u0443\u0442 \u0432\u043e\u0442 \u0432 \u0447\u0435\u043c: MR \u043d\u0430\u0447\u0438\u043d\u0430\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 2000-\u0445 \u0433\u043e\u0434\u0430\u0445, \u043a\u043e\u0434\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u0441\u0442\u043e\u0438\u043b\u0430 \u0434\u043e\u0440\u043e\u0433\u043e, \u0438 64-\u0445 \u0431\u0438\u0442\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0435\u0449\u0435 \u043d\u0435 \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u043b\u0438 \u043c\u0438\u0440. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043f\u043e\u0448\u043b\u0438 \u0442\u043e\u0433\u0434\u0430 \u043f\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u0435\u0440\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043e\u0431\u043c\u0435\u043d \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 \u0436\u0435\u0441\u0442\u043a\u0438\u0439 \u0434\u0438\u0441\u043a (\u0438\u043b\u0438 \u0435\u0441\u043b\u0438 \u0431\u044b\u0442\u044c \u0442\u043e\u0447\u043d\u044b\u043c, \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 HDFS). \u0422.\u0435 \u0432\u0441\u0435 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 Map \u0438 Reduce \u0444\u0430\u0437\u0430\u043c\u0438, \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u0432 HDFS. \u041a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0442\u0440\u0430\u0442\u0438\u043b\u043e\u0441\u044c \u043d\u0430 \u0434\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0432\u0432\u043e\u0434\/\u0432\u044b\u0432\u043e\u0434 \u0438 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438 Hadoop \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430. <br \/>  Spark \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043f\u043e\u0437\u0436\u0435, \u0438 \u0443\u0436\u0435 \u0432 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0438 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u043e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0442\u044c, \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439. \u0421\u0442\u043e\u0438\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0447\u0442\u043e \u0434\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0432\u0432\u043e\u0434\/\u0432\u044b\u0432\u043e\u0434 \u0432\u0441\u0451 \u0442\u0430\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f (\u043d\u0430 \u044d\u0442\u0430\u043f\u0435 shuffle). \u041d\u043e \u0435\u0433\u043e \u0438\u043d\u0442\u0435\u043d\u0441\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435.<br \/>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0437\u0430\u043f\u0443\u0441\u043a \u0437\u0430\u0434\u0430\u0447 Spark \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u043c\u043d\u043e\u0433\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0437\u0430 \u0441\u0447\u0435\u0442 JVM \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439. \u041capReduce \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u043e\u0432\u0443\u044e JVM, \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0432\u044b\u0442\u0435\u043a\u0430\u044e\u0449\u0438\u043c\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f\u043c\u0438 (\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0432\u0441\u0435\u0445 JAR \u0444\u0430\u0439\u043b\u043e\u0432, JIT \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f, \u0438\u0442\u0434), \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a Spark \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0443\u0437\u043b\u0435 \u0434\u0435\u0440\u0436\u0438\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u0443\u044e JVM, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u0437\u0430\u0434\u0430\u0447 \u0447\u0435\u0440\u0435\u0437 RPC \u0432\u044b\u0437\u043e\u0432\u044b.<br \/>  \u041d\u0443 \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 Spark \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u0442 RDD \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f\u043c\u0438 (Remote Distributed Dataset), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u043e\u043b\u0435\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b \u0447\u0435\u043c MapReduce. \u0425\u043e\u0442\u044f \u0434\u043b\u044f \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e\u0441\u0442\u0438 \u043d\u0430\u0434\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0435\u0441\u0442\u044c Cascading. \u042d\u0442\u043e \u043e\u0431\u0432\u0435\u0440\u0442\u043a\u0430 \u043d\u0430\u0434 MR, \u043f\u0440\u0438\u0437\u0432\u0430\u043d\u043d\u0430\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438.<br \/>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u043d\u043e, \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e\u0435 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u2014 Spark \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447 \u043f\u0430\u043a\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (batch processing), \u043d\u043e \u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (stream processing). \u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0435\u0434\u0438\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u0438 \u0435\u0434\u0438\u043d\u043e\u0435 API (\u043f\u0440\u0430\u0432\u0434\u0430 \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f\u043c\u0438).<\/p>\n<h3>\u0410 \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u043a\u043e\u0434\u0435?<\/h3>\n<p>  Spark API \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u043d\u0430 <a href=\"http:\/\/spark.apache.org\/docs\/latest\/programming-guide.html\">\u043e\u0444. \u0441\u0430\u0439\u0442\u0435<\/a>, \u043d\u043e \u0434\u043b\u044f \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043a\u0440\u0430\u0442\u043a\u043e \u0441 \u043d\u0438\u043c \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0443 \u0441\u0435\u0431\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e:<br \/>  \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u044b\u0445 \u0438\u043c \u0441\u0430\u0439\u0442\u043e\u0432. \u0418 \u0432\u0435\u0440\u043d\u0435\u043c Top 10, \u0432 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e \u0432\u0438\u0434\u0435.<\/p>\n<pre><code class=\"java\">public class UsersActivities {      public static void main( String[] args ) {          final JavaSparkContext sc = new JavaSparkContext(                 new SparkConf()                         .setAppName(&quot;Spark user-activity&quot;)                         .setMaster(&quot;local[2]&quot;)            \/\/local - \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435.                         .set(&quot;spark.driver.host&quot;, &quot;localhost&quot;)    \/\/\u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430         );          \/\/\u0417\u0434\u0435\u0441\u044c \u043c\u043e\u0433\u043b\u0430 \u0431\u044b\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 sc.textFile(&quot;users-visits.log&quot;);         \/\/\u041d\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043a \u0432\u0445\u043e\u0434\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434 parallelize(); \u0414\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438          List&lt;String&gt; visitsLog = Arrays.asList(                 &quot;user_id:0000, habrahabr.ru&quot;,                 &quot;user_id:0001, habrahabr.ru&quot;,                 &quot;user_id:0002, habrahabr.ru&quot;,                 &quot;user_id:0000, abc.ru&quot;,                 &quot;user_id:0000, yxz.ru&quot;,                 &quot;user_id:0002, qwe.ru&quot;,                 &quot;user_id:0002, zxc.ru&quot;,                 &quot;user_id:0001, qwe.ru&quot;                 \/\/\u0438\u0442\u0434, \u0434\u043e\u0444\u0430\u043d\u0442\u0430\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u0434\u0430\u043b\u044c\u0448\u0435 \u0441\u0430\u043c\u0438 :)         );          JavaRDD&lt;String&gt; visits = sc.parallelize(visitsLog);          \/\/\u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0430\u0440\u044b: \u043a\u043b\u044e\u0447 (user_id), \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (1 - \u043a\u0430\u043a \u0444\u0430\u043a\u0442 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u044f)         \/\/ (user_id:0000 : 1)         JavaPairRDD&lt;String, Integer&gt; pairs = visits.mapToPair(             (String s) -&gt; {                 String[] kv = s.split(&quot;,&quot;);                 return new Tuple2&lt;&gt;(kv[0], 1);             }         );          \/\/\u0441\u0443\u043c\u043c\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u043a\u0442\u044b \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e user_id         JavaPairRDD&lt;String, Integer&gt; counts = pairs.reduceByKey(             (Integer a, Integer b) -&gt; a + b         );          \/\/\u0441\u0438\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u043e Value \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0435 10 \u0437\u0430\u043f\u0441\u0438\u0441\u0435\u0439         List&lt;Tuple2&lt;String, Integer&gt;&gt; top10 = counts.takeOrdered(                 10,                 new CountComparator()         );          System.out.println(top10);     }      \/\/\u0422\u0430\u043a\u0438\u0435 \u0434\u0435\u043b\u0430, \u043a\u043e\u043c\u043f\u0430\u0440\u0430\u0442\u043e\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c Serializable. \u0418\u043d\u0430\u0447\u0435 (\u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430), \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435     \/\/SparkException: Task not serializable     \/\/http:\/\/stackoverflow.com\/questions\/29301704\/apache-spark-simple-word-count-gets-sparkexception-task-not-serializable     public static class CountComparator implements Comparator&lt;Tuple2&lt;String, Integer&gt;&gt;, Serializable {          @Override         public int compare(Tuple2&lt;String, Integer&gt; o1, Tuple2&lt;String, Integer&gt; o2) {              return o2._2()-o1._2();         }     } } <\/code><\/pre>\n<p>  \u0414\u0430, \u0441\u0442\u043e\u0438\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e Spark API \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0434\u043b\u044f Scala, Java \u0438 Python. \u041d\u043e \u0432\u0441\u0451 \u0442\u0430\u043a\u0438 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u043d\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0434 Scala. \u041a\u0430\u043a \u0431\u044b \u0442\u0430\u043c \u043d\u0438 \u0431\u044b\u043b\u043e, \u0443 \u043d\u0430\u0441 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Java 8 \u0438 \u0432 \u0446\u0435\u043b\u043e\u043c \u043c\u044b \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u044b. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u0441\u043a\u0430\u043b\u0443 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0432\u0438\u0434\u0435\u043c \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430.<\/p>\n<p>  \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c stream processing, \u0437\u0430\u0447\u0435\u043c \u043e\u043d \u043d\u0443\u0436\u0435\u043d, \u043a\u0430\u043a \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0443 \u043d\u0430\u0441 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0438 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 SparkSQL               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/271375\/\"> http:\/\/habrahabr.ru\/post\/271375\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u041f\u0440\u0438\u0432\u0435\u0442 \u043a\u043e\u043b\u043b\u0435\u0433\u0438. <br \/>  \u0421 \u043d\u0435\u0434\u0430\u0432\u043d\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0443 \u043d\u0430\u0441 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f Spark. \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0435\u0439, \u0438 \u0443\u0437\u043d\u0430\u0451\u043c \u043c\u043d\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e. \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0437\u043d\u0430\u043d\u0438\u044f, \u0438 \u0437\u0430 \u043e\u0434\u043d\u043e \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0438\u043c\u0438 \u0441 \u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0438\u043c\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0446\u0438\u043a\u043b \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Apache Spark. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0435\u0440\u0432\u0430\u044f, \u0438 \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u0432\u043e\u0434\u043d\u043e\u0439.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-268851","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/268851","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=268851"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/268851\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=268851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=268851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=268851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}