{"id":1510,"date":"2017-01-29T20:08:09","date_gmt":"2017-01-29T20:08:09","guid":{"rendered":"http:\/\/62.131.51.129\/?p=1510"},"modified":"2017-01-29T20:08:09","modified_gmt":"2017-01-29T20:08:09","slug":"scala","status":"publish","type":"post","link":"http:\/\/archief.van-maanen.com\/?p=1510","title":{"rendered":"Scala"},"content":{"rendered":"<p>Scala is a language that is used for general purposes. One may use it as a statistical tool, a tool to undertake pattern matching etc. Just like any other programming tool like Java, C++, Fortran might do. But on top of that, Scala is used as a means to steer Big Data on a Hadoop platform. For me, being interested in Big Data, Scala is a worthwhile investment.<br \/>\nLet me first show a screenshot on Scala:<\/p>\n<p><a href=\"http:\/\/62.131.51.129\/wp-content\/uploads\/2017\/01\/Untitled-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1514\" src=\"http:\/\/62.131.51.129\/wp-content\/uploads\/2017\/01\/Untitled-1.png\" alt=\"\" width=\"575\" height=\"217\" \/><\/a><\/p>\n<p>The programme is quite straightforward. A function is defined with a name codeer. It receives one variable. When this variable is an &#8216;a&#8217; or &#8216;b&#8217;, it will be translated into a &#8216;1&#8217;or &#8216;2&#8217;. In all other cases, it won&#8217;t be translated. The variable &#8216;kijk&#8217; that contains the resulting character is returned. Subsequently, one may use this function.<\/p>\n<p>In the Big Data environment, one may start Scala by the command &#8220;spark-shell&#8221;. If everything is well installed, one sees something like:<\/p>\n<p><a href=\"http:\/\/62.131.51.129\/wp-content\/uploads\/2017\/01\/Untitled-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1516\" src=\"http:\/\/62.131.51.129\/wp-content\/uploads\/2017\/01\/Untitled-2.png\" alt=\"\" width=\"627\" height=\"175\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>It is then clear that the integration between the Big Data environment and Scala is strong in this environment. When the environment is started, one sees that a context variable is created that allows to access the Spark environment:<\/p>\n<p><a href=\"http:\/\/62.131.51.129\/wp-content\/uploads\/2017\/01\/Untitled-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1517\" src=\"http:\/\/62.131.51.129\/wp-content\/uploads\/2017\/01\/Untitled-3.png\" alt=\"\" width=\"642\" height=\"37\" \/><\/a><\/p>\n<p>This then allows to retrieve a Big Data dataset as an object in Scala:<\/p>\n<p>val rawblocks = sc.textFile(&#8220;linkage&#8221;)<\/p>\n<p>The nice thing is that we may grab all files that are in directory &#8220;linkage&#8221; and access then as one object that is called rawblocks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Scala is a language that is used for general purposes. One may use it as a statistical tool, a tool to undertake pattern matching etc. Just like any other programming tool like Java, C++, Fortran might do. But on top of that, Scala is used as a means to steer Big Data on a Hadoop [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1511,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1510","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts\/1510","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1510"}],"version-history":[{"count":0,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts\/1510\/revisions"}],"wp:attachment":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1510"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}