<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Apache Spark on Bharath's Blog</title><link>https://bharathbhushan1.github.io/blog/tags/apache-spark/</link><description>Recent content in Apache Spark on Bharath's Blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sat, 10 Dec 2016 10:00:00 +0000</lastBuildDate><atom:link href="https://bharathbhushan1.github.io/blog/tags/apache-spark/index.xml" rel="self" type="application/rss+xml"/><item><title>Spark memory management</title><link>https://bharathbhushan1.github.io/blog/posts/2016-12-10-spark-memory-management/</link><pubDate>Sat, 10 Dec 2016 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2016-12-10-spark-memory-management/</guid><description>&lt;p&gt;MemoryManager is the place where I started looking at spark’s memory management architecture. This class handles the split of the overall memory into four dynamic portions — onHeapStorage, onHeapExecution, offHeapStorage, offHeapExecution. Execution memory is transient (shuffle, join, aggregates, sorting) and storage memory is longer lived (cache, broadcast variables). MemoryManager depends on MemoryStore to actually allocate and free memory.&lt;/p&gt;
&lt;p&gt;There are two kinds of MemoryManagers — StaticMemoryManager and UnifiedMemoryManager. Unified allows execution and storage to borrow memory from each other while Static does not allow this.&lt;/p&gt;</description></item><item><title>Spark - QueryExecution</title><link>https://bharathbhushan1.github.io/blog/posts/2016-11-20-spark-queryexecution/</link><pubDate>Sun, 20 Nov 2016 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2016-11-20-spark-queryexecution/</guid><description>&lt;p&gt;Today I am going to talk about the &lt;strong&gt;QueryExecution&lt;/strong&gt; class in Spark. This class takes care of providing fine grained access to different stages of running a SparkSQL query. Basically the parsing, analysis, optimization and physical planning are all accessible via this class. It also handles inserting extra operations like extracting python UDFs, inserting shuffle stages, internal row format conversions etc.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;IncrementalExecution&lt;/strong&gt; is a derived class which allows the same query to be run repeatedly in an incremental fashion, with possible state save in between executions. This is used in Structured Streaming. It is also used to allow users to run their own optimization strategies which is very cool.&lt;/p&gt;</description></item><item><title>Trying out spark streaming</title><link>https://bharathbhushan1.github.io/blog/posts/2014-04-01-streaming-spark/</link><pubDate>Tue, 01 Apr 2014 12:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-04-01-streaming-spark/</guid><description>&lt;p&gt;I am playing with simple examples of spark streaming &lt;a href="https://github.com/manku-timma/spark/tree/master/5"&gt;here&lt;/a&gt; and &lt;a href="https://github.com/manku-timma/spark/tree/master/6"&gt;here&lt;/a&gt;.
The flexibility of creating any number of separate dstreams, and calling
&lt;code&gt;updateStateByKey&lt;/code&gt; on any dstream is really nice.&lt;/p&gt;
&lt;p&gt;Here is a &lt;a href="http://apache-spark-user-list.1001560.n3.nabble.com/Suppress-Log4j-on-SBT-tt2746.html"&gt;link&lt;/a&gt; to configure logging in a standalone spark program.&lt;/p&gt;</description></item><item><title>Running Apache Spark examples</title><link>https://bharathbhushan1.github.io/blog/posts/2014-03-28-running-spark-examples/</link><pubDate>Fri, 28 Mar 2014 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-03-28-running-spark-examples/</guid><description>&lt;p&gt;Apache Spark has a good set of examples to play with. But I could not figure
out how to rerun the test by recompiling only that test. An entire &lt;code&gt;sbt/sbt assembly&lt;/code&gt; will take ages and will preclude understanding modified examples
within this lifetime. So a shorter route was necessary. The obvious &lt;code&gt;sbt/sbt compile org.apache.spark.streaming.examples&lt;/code&gt; failed.&lt;/p&gt;
&lt;p&gt;Digging into the (slow as in molasses) output of &lt;code&gt;sbt/sbt help&lt;/code&gt; showed &lt;code&gt;sbt/sbt project&lt;/code&gt; to set the current project. &lt;em&gt;Sidenote&lt;/em&gt;: Leaving a JVM running
could not hurt the speed of sbt&amp;rsquo;s startup. &lt;em&gt;End of Sidenote&lt;/em&gt;. Trying to set
the current project to examples did not succeed. Wading through several
error messages which mentioned &amp;lsquo;/&amp;rsquo; as a special character did not help.&lt;/p&gt;</description></item><item><title>Apache spark use cases</title><link>https://bharathbhushan1.github.io/blog/posts/2014-03-26-spark-use-cases/</link><pubDate>Wed, 26 Mar 2014 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-03-26-spark-use-cases/</guid><description>&lt;p&gt;Here is a list of possible use cases for Apache spark.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Mining logs for interesting patterns&lt;/li&gt;
&lt;li&gt;Text search (also web search)&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Big data processing toy example - Part 2</title><link>https://bharathbhushan1.github.io/blog/posts/2014-03-25-big-data-processsing-part-2/</link><pubDate>Tue, 25 Mar 2014 12:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-03-25-big-data-processsing-part-2/</guid><description>&lt;p&gt;This is the second part of the blog series on big data processing. This will
focus on doing some simple processing on a large dataset stored in HDFS.&lt;/p&gt;
&lt;p&gt;I have 300000 random integers stored in HDFS as a single shard in
&lt;code&gt;/user/hduser/random4&lt;/code&gt; directory.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-scala" data-lang="scala"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;val&lt;/span&gt; &lt;span class="n"&gt;rdd4&lt;/span&gt; &lt;span class="k"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hadoopFile&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;hdfs://vagrant-ubuntu-precise-64/user/hduser/random4&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;rdd4&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;partitions&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br/&gt;
&lt;p&gt;###Problems encountered:
The above snippet throws an exception:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;java.lang.RuntimeException: java.lang.InstantiationException
at org.apache.hadoop.util.ReflectionUtils.newInstance
(ReflectionUtils.java:115)
at org.apache.spark.rdd.HadoopRDD.getInputFormat
(HadoopRDD.scala:141)
at org.apache.spark.rdd.HadoopRDD.getPartitions
(HadoopRDD.scala:154)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Checking the api reference for hadoopFile shows that some more arguments
might be needed. Switching to sc.textFile solved the problem.&lt;/p&gt;</description></item><item><title>Big data processing toy example - Part 1</title><link>https://bharathbhushan1.github.io/blog/posts/2014-03-25-big-data-processsing-part-1/</link><pubDate>Tue, 25 Mar 2014 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-03-25-big-data-processsing-part-1/</guid><description>&lt;p&gt;This is the first part of the blog series on big data processing. This will
focus on generating a large dataset. The idea is to generate a large dataset in
a distributed way and write it to HDFS. Below is scala-spark snippet to
generate lots of random integers and store them on HDFS.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-scala" data-lang="scala"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;util.Random&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;val&lt;/span&gt; &lt;span class="n"&gt;rdd&lt;/span&gt; &lt;span class="k"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parallelize&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Seq&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fill&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="o"&gt;)(&lt;/span&gt;&lt;span class="nc"&gt;Random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nextInt&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;rdd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;saveAsTextFile&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;hdfs://vagrant-ubuntu-precise-64/user/hduser/random&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br/&gt;
&lt;p&gt;###Problems encountered&lt;/p&gt;
&lt;p&gt;The hostname was not really matching and spark-shell
was throwing an EOFException.&lt;/p&gt;</description></item><item><title>Mental map of big data software</title><link>https://bharathbhushan1.github.io/blog/posts/2014-03-24-big-data-map/</link><pubDate>Mon, 24 Mar 2014 20:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-03-24-big-data-map/</guid><description>&lt;p&gt;I was trying to create a mental map of the various big-data software solutions.
My first attempt is below.&lt;/p&gt;
&lt;p&gt;&lt;img alt="big data map" loading="lazy" src="https://raw.githubusercontent.com/manku-timma/manku-timma.github.io/master/images/bigdata.jpg"&gt;.&lt;/p&gt;
&lt;p&gt;Since there are close connections to virtualization solutions and cloud
computing solutions, I have added those also into the map. It is possible there
are mistakes in the map and I need to update it as I learn more.&lt;/p&gt;
&lt;p&gt;Also played around with &lt;a href="http://www.ibm.com/developerworks/library/wa-introhdfs/index.html"&gt;HDFS&lt;/a&gt; using this &lt;a href="http://www.michael-noll.com/tutorials/running-hadoop-on-ubuntu-linux-single-node-cluster/"&gt;tutorial&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Keeping track of what is happening in Apache Spark</title><link>https://bharathbhushan1.github.io/blog/posts/2014-03-24-knowing-what-is-happening-in-spark/</link><pubDate>Mon, 24 Mar 2014 06:40:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-03-24-knowing-what-is-happening-in-spark/</guid><description>&lt;p&gt;I am trying to follow what is happening in &lt;a href="https://spark.apache.org"&gt;Apache Spark&lt;/a&gt;. Things that need to be done:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Subscribe to &lt;a href="mailto:user@spark.apache.org"&gt;user@spark.apache.org&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Subscribe to &lt;a href="mailto:dev@spark.apache.org"&gt;dev@spark.apache.org&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Follow github notifications for spark. PRs, comments, commits etc are all
sent as notifications.&lt;/li&gt;
&lt;li&gt;Create an account on &lt;a href="https://spark-project.atlassian.net"&gt;Apache Spark Jira&lt;/a&gt;. But I did not find any way to
get email notifications for activity on JIRA. So following the RSS feed of
the &lt;a href="https://spark-project.atlassian.net/activity"&gt;activity stream&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I am also going through this summary &lt;a href="http://ampcamp.berkeley.edu/wp-content/uploads/2012/06/matei-zaharia-part-1-amp-camp-2012-spark-intro.pdf"&gt;presentation&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Basic usage of Apache Spark</title><link>https://bharathbhushan1.github.io/blog/posts/2014-03-23-next-steps-with-spark/</link><pubDate>Sun, 23 Mar 2014 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-03-23-next-steps-with-spark/</guid><description>&lt;p&gt;Played around with &lt;a href="https://spark.apache.org"&gt;Apache Spark&lt;/a&gt; today. Ran the spark-shell and did
some text processing as shown in the quickstart documentation. I tried to run
the examples but that fails complaining that the examples are not built. Trying
to run &lt;code&gt;sbt/sbt assembly&lt;/code&gt; again but there is a SSL certificate error on
repo.maven.apache.org &amp;ndash; there is a domain mismatch (hmm&amp;hellip;). Curl complains
that the security chain is invalid.&lt;/p&gt;
&lt;p&gt;I tried out the master-slave mode of running spark. Feels really cool counting
119 lines of a small text file using 3 workers and taking 2-3 seconds :)&lt;/p&gt;</description></item><item><title>About Apache Spark, jekyll, github pages and rubygems</title><link>https://bharathbhushan1.github.io/blog/posts/2014-03-22-foray-into-spark/</link><pubDate>Sat, 22 Mar 2014 20:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-03-22-foray-into-spark/</guid><description>&lt;p&gt;I tried out &lt;a href="https://spark.apache.org"&gt;Apache Spark&lt;/a&gt; for the first time today. It was a bit of a
roundabout journey. I downloaded &lt;code&gt;spark-0.9.0-incubating-bin-hadoop2.tgz&lt;/code&gt; and
tried &lt;code&gt;sbt/sbt assembly&lt;/code&gt;. java kept failing trying to build the scala compiler.
That is when I realized the binaries are already there since I downloaded a
binary package (ouch). I played around with spark-shell and tried a few
basic things.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 1&lt;/strong&gt;: Increasing the vagrant memory limit from 512MB to 1024MB
allows the scala compiler to be built without overrunning available
memory. I see around 780MB peak ram usage.&lt;/p&gt;</description></item></channel></rss>