Spark - QueryExecution

Today I am going to talk about the QueryExecution 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. IncrementalExecution 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.

November 20, 2016 · 1 min · Bharath

g2.2xlarge GPU basics

A Graphics Processing Unit is a specialized processor usually sitting on a special card with its own memory. It does not have interrupts or virtual memory. For example EC2’s g2.2xlarge machine has the following graphics card. 00:03.0 VGA compatible controller: nVidia Corporation GK104GL [GRID K520] (rev a1) GRID K520 belongs to Nvidia’s Tesla card series and has GRID support (which allows GPU sharing). It plugs into a PCI slot on the motherboard. Each such card has 2 GK104GL GPUs, two 4GB RAM units, and 2x1536 CUDA cores. I will explain in detail below. ...

November 12, 2016 · 2 min · Bharath

What is Machine Learning: Part 2

Arthur Samuel described it as: “the field of study that gives computers the ability to learn without being explicitly programmed.” Basically the computer can be taught to do a particular task and once the learning is complete the computer can do that task well on its own. So the programming was not task specific, only the learning process was task specific. Something like public key encryption - the algorithms are public but the key ensures confidentiality and integrity. ...

November 12, 2016 · 2 min · Bharath

Machine Learning Course: Part 1

I just started the online Coursera course for Machine Learning by Andrew Ng. For the past couple of years I waded through the big data world a bit. Now I am trying to understand a bit of machine learning. (Also this page has lot of material). What hit me was the broad scope of machine learning. So it is really exciting and interesting to start on this journey which will hopefully wake me up from my lazy technical hibernation. ...

November 11, 2016 · 2 min · Bharath

What are measures, dimensions and facts

I did a bit of basic reading about measures, dimensions and facts. The most pithy explanation I have gathered is:- facts are tables, they record events, they are verb-like dimensions are tables, they record entities, they are noun-like dimension columns are columns in the fact table and are foreign keys into dimension tables measure columns are columns in the fact table and are things that matter to the business at hand dimensions columns are discrete measure columns are usually continuous This build the foundation for data warehousing concepts. A number of variations on these concepts are also present but this is the basic information necessary to navigate the world of data warehouses.

January 6, 2016 · 1 min · Bharath

Feynman lectures on physics

I would really like to read Feynman’s Lectures on Physics. Once in a while I have started reading it but have never persisted with reading it for any sustained period of time. But better late than never. Today I will try to summarize and think aloud about the first unit in that book: http://www.feynmanlectures.caltech.edu/I_01.html. Of course, having such a great resource available online is a privilege. Physics is a rapidly developing field and has accumulated a tremendous amount of knowledge. Fortunately this mass of knowledge can be condensed into laws. But the laws are hard to understand without context. ...

December 12, 2015 · 2 min · Bharath

How to use spark with anaconda python

The setup is spark 1.5.1 running on yarn (hadoop-2.6.0). # Install anaconda python on all nodes of the cluster. # Below we are installing anaconda's python-2.7 64-bit package. wget https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda2-2.4.1-Linux-x86_64.sh bash Anaconda2-2.4.1-Linux-x86_64.sh -b -f -p /usr/lib/anaconda2 # Run this on all nodes of the cluster and restart the ResourceManager/NodeManager daemons. echo "VIRTUAL_ENV_DISABLE_PROMPT=1 source /usr/lib/anaconda2/bin/activate /usr/lib/anaconda2" >> /usr/lib/hadoop2/etc/hadoop/hadoop-env.sh # Set some env vars and start pyspark. export PYSPARK_PYTHON=/usr/lib/anaconda2/bin/python export PYSPARK_DRIVER_PYTHON=/usr/lib/anaconda2/bin/python /usr/lib/spark/bin/pyspark --master yarn-client --executor-memory 512m --executor-cores 1 --num-executors 2

December 12, 2015 · 1 min · Bharath

How ads are shown

Long time since I wrote a blog post. Just lost in time and work and stuff. I am now back to writing about my learnings in the world of tech. This post is about ads. More specifically about how advertisements are displayed when you visit a website in your browser. In terms of HTTP requests sent from your browser and the chain of interactions that ensue, below is the flow of control and the various entities involved in this transaction. ...

December 11, 2015 · 2 min · Bharath

Bigtable

I am reading Google’s Bigtable paper. Here are some notes. Can handle petabytes of data spread over thousands of machines Clients can dynamically control data format, placement, memory/disk Data model is unique, two-level Large variations in size and serving latency can be handled sparse, distributed, multi-dimensional, sorted map row ranges (called tablets) are the unit of distribution and load balancing tablets are dynamically sized efficiency can be gained by taking advantage of sorting on row keys and locality in a tablet column family is a set of columns column family is the unit of access control and accounting any number of columns but limited number of column families (100s) keep last n versions of data or keep last n seconds of data (garbage collection) API has RowMutation and Scanner as primary abstractions uses GFS, cluster management system, sstable, chubby sstable is a persistent, ordered, immutable map operations for key lookup and key range iteration are supported it is split into 64k blocks and there is a block index at the end of the sstable block index allows accessing any key-value in one disk seek sstable can also be memory mapped chubby is used for bigtable master election store bootstrap location of bigtable data to discover tablet servers finalize tablet server deaths store bigtable schema info (column family info) store acls implementation consists of client library, master server and tablet server METADATA is a special table in bigtable This table is split into multiple tablets Each tablet can be present on different tablet servers The first tablet is special and is called root tablet Root tablet is never split (to keep lookup hierarchy for a tablet to a max of 3) root tablet location is in chubby root tablet tracks all the other tablets of the METADATA table these other tablets of the METADATA table can be split Each row in the METADATA table tracks one user tablet. So each METADATA tablet tracks one set of user tablets. each METADATA table row is hash(table id, end row key) -> location With 1KB per row and 128MB METADATA tablet size, trackable number of tablets is 2^17 * 2^17 = 2^34

July 1, 2014 · 2 min · Bharath

Linux Device Drivers

I started reading LDD3. Here are some notes. A device driver implements mechanisms to support user policies about devices. The important choices to be made by a driver writer are: allow device to be opened multiple times decide how to handle concurrent requests allow sync and async apis Some of the functionality can be in a userland library and some in a userland config program. Not everything needs to be in the kernel driver. ...

June 29, 2014 · 1 min · Bharath