<?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>Posts on Bharath's Blog</title><link>https://bharathbhushan1.github.io/blog/posts/</link><description>Recent content in Posts on Bharath's Blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sat, 15 Aug 2026 09:00:00 +0530</lastBuildDate><atom:link href="https://bharathbhushan1.github.io/blog/posts/index.xml" rel="self" type="application/rss+xml"/><item><title>Model Distillation</title><link>https://bharathbhushan1.github.io/blog/posts/2026-08-15-model-distillation/</link><pubDate>Sat, 15 Aug 2026 09:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-08-15-model-distillation/</guid><description>&lt;p&gt;Model distillation is a model training/fine-tuning process where a smaller
student model is trained from a teacher model. The evolution of distillation
goes from model compression to knowledge/behaviour transfer to transfer
of reasoning abilities. The student could have better generalization depending
on how the distillation was done. So you end up with a smaller, faster,
cheaper model with better generalization while needing fewer training samples
during training and you can use a higher learning rate.&lt;/p&gt;</description></item><item><title>Vision Language Models</title><link>https://bharathbhushan1.github.io/blog/posts/2026-08-13-vision-language-models/</link><pubDate>Thu, 13 Aug 2026 09:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-08-13-vision-language-models/</guid><description>&lt;p&gt;Vision Language Models are a class of large multimodal neural networks.
They take images and text as input and generate text as output. The typical
tasks involve jointly reasoning over both images and text to generate
useful results.&lt;/p&gt;
&lt;p&gt;The joint reasoning is interesting. Basically visual semantic concepts and
textual semantic concepts (and speech and video) are mapped to the same
embedding/latent space. Then the model processes the embeddings. The joint
training has the advantage that there is genuine grounding of visual concepts
in text and vice-versa. In practice a &amp;ldquo;modality gap&amp;rdquo; persists even after joint
training — embeddings of different modalities cluster in distinct regions of the
shared space rather than fully overlapping — but the gap is far smaller than
between independently trained encoders. Parameters are shared across modalities,
reducing model size. The caveats are careful data mixing during training: a good
mixture of images, text and image+text, staged training, basically all to avoid
catastrophic forgetting.&lt;/p&gt;</description></item><item><title>World Models</title><link>https://bharathbhushan1.github.io/blog/posts/2026-08-12-world-models/</link><pubDate>Wed, 12 Aug 2026 09:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-08-12-world-models/</guid><description>&lt;p&gt;This short note is based on an article by Dr. Fei-Fei Li (see References).&lt;/p&gt;
&lt;p&gt;World models allow you to view, generate, interact with, reason about
and manipulate virtual worlds. I think spatial intelligence is an
important component of human intelligence and will likely become part
of artificial intelligence too, over time.&lt;/p&gt;
&lt;p&gt;LLMs only deal with text. VLMs deal with images. There are models to
generate images and short videos. But we need so much more to claim
spatial intelligence.&lt;/p&gt;</description></item><item><title>Reasoning Models</title><link>https://bharathbhushan1.github.io/blog/posts/2026-07-05-reasoning-models/</link><pubDate>Sun, 05 Jul 2026 17:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-07-05-reasoning-models/</guid><description>&lt;p&gt;&lt;img alt="Reasoning models mindmap" loading="lazy" src="https://bharathbhushan1.github.io/blog/images/reasoning-models.svg"&gt;&lt;/p&gt;
&lt;p&gt;Source: &lt;a href="https://www.ibm.com/think/topics/reasoning-model"&gt;What is a reasoning model?&lt;/a&gt; (IBM)&lt;/p&gt;
&lt;p&gt;I was reading the above article and made a simple mindmap of the material. It is a huge
topic which I plan to read more about, but this is just a start.&lt;/p&gt;
&lt;p&gt;It is hard to believe that just a prompt for chain-of-thought could unlock reasoning
behaviours in a pre-trained model. But that seems to underpin all the developments
in reasoning LLMs, at least the popular ones. Of course, search-based and majority-based
approaches exist too.&lt;/p&gt;</description></item><item><title>Image Generation Models</title><link>https://bharathbhushan1.github.io/blog/posts/2026-07-03-image-generation-models/</link><pubDate>Fri, 03 Jul 2026 19:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-07-03-image-generation-models/</guid><description>&lt;p&gt;&lt;img alt="Latent diffusion inference (SD 1.5)" loading="lazy" src="https://bharathbhushan1.github.io/blog/images/latent_diffusion_inference_sd15.svg"&gt;&lt;/p&gt;
&lt;p&gt;I saw the &lt;a href="https://blog.google/innovation-and-ai/models-and-research/gemini-models/gemini-omni-flash-nano-banana-2-lite/"&gt;launch announcement&lt;/a&gt;
of Google&amp;rsquo;s Nano Banana 2, and this piqued my interest
in image generation models. These are models that take a textual prompt, and with a
few optional reference images, generate a new image. The main criteria are cost of
generation, speed of generation, prompt adherence, consistency of the characters in
the image, and style manipulation ability.&lt;/p&gt;
&lt;p&gt;The most popular type of image generation model is a latent diffusion model based on
a Diffusion Transformer (DiT) for noise prediction. Earlier, a U-Net was used for
noise prediction instead.&lt;/p&gt;</description></item><item><title>Claude Code in Action</title><link>https://bharathbhushan1.github.io/blog/posts/2026-07-03-claude-code-in-action/</link><pubDate>Fri, 03 Jul 2026 09:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-07-03-claude-code-in-action/</guid><description>&lt;p&gt;I took Anthropic&amp;rsquo;s &lt;a href="https://anthropic.skilljar.com/claude-code-in-action"&gt;Claude Code in Action&lt;/a&gt;
course. I just wanted to get a comprehensive view of the features. I learnt a
few nice things.&lt;/p&gt;
&lt;p&gt;The fact that tools are the main conceptual breakthrough for most of the
advancements of LLMs became apparent. The composability and versatility of
tools contributes to a lot of the problem solving abilities of LLM based
agents.&lt;/p&gt;
&lt;p&gt;Context management is very important. You should know how to manipulate
and maintain the context in order to get Claude code to work well.&lt;/p&gt;</description></item><item><title>India's Datacenter Build-Out, Mapped</title><link>https://bharathbhushan1.github.io/blog/posts/2026-07-03-india-datacenters/</link><pubDate>Fri, 03 Jul 2026 08:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-07-03-india-datacenters/</guid><description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; This entire post — the map, the analysis, and the text — was
AI-generated. Figures are directional and may contain errors; verify against
primary sources before relying on them.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img alt="Major data-centre projects across India" loading="lazy" src="https://bharathbhushan1.github.io/blog/images/india-datacenters.png"&gt;&lt;/p&gt;
&lt;p&gt;India&amp;rsquo;s datacenter story has shifted from a Mumbai-dominated colocation market
into a nationwide, AI-driven hyperscale race. Operational IT-load sat at roughly
&lt;strong&gt;1.4 GW&lt;/strong&gt; in Q2 2025, with about the same again under construction and capacity
expected to double within two years. More than &lt;strong&gt;$32 billion&lt;/strong&gt; of investment has
been announced in the last two years alone.&lt;/p&gt;</description></item><item><title>A Native macOS Pomodoro Timer</title><link>https://bharathbhushan1.github.io/blog/posts/2026-07-02-pomodoro-app/</link><pubDate>Thu, 02 Jul 2026 09:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-07-02-pomodoro-app/</guid><description>&lt;p&gt;Wanted a Pomodoro timer that lives on my desktop instead of a browser tab, so I
had Claude help me build one in SwiftUI. The code lives in
&lt;a href="https://github.com/bharathbhushan1/ai-learning/tree/main/pomodoro"&gt;&lt;code&gt;pomodoro&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s a small always-on-top window with a circular progress ring, cycling
through focus / short break / long break (a long break every N focus sessions,
configurable). Each focus session can be named with a note, and completed
sessions land in a local history panel you can view, edit, or delete. A macOS
notification and sound fire when a session ends.&lt;/p&gt;</description></item><item><title>Qwen-AgentWorld: A Language World Model for Agents</title><link>https://bharathbhushan1.github.io/blog/posts/2026-06-30-qwen-agentworld/</link><pubDate>Tue, 30 Jun 2026 08:30:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-06-30-qwen-agentworld/</guid><description>&lt;p&gt;The Qwen team &lt;a href="https://qwen.ai/blog?id=qwen-agentworld"&gt;released&lt;/a&gt; Qwen-AgentWorld
on 2026-06-24. I came to know more about language world models via this post. It is
also related to &lt;a href="https://bharathbhushan1.github.io/blog/posts/2026-06-24-ai-agents/"&gt;agents&lt;/a&gt;, and
&lt;a href="https://bharathbhushan1.github.io/blog/posts/2026-06-13-offline-rl/"&gt;offline RL&lt;/a&gt;. This post is a short summary
of my understanding.&lt;/p&gt;
&lt;h2 id="context"&gt;Context&lt;/h2&gt;
&lt;p&gt;To train an agent with RL, you need an environment in which it can learn by trying
out various actions and observing the result. But real environments are slow and
sometimes irreversible.&lt;/p&gt;
&lt;p&gt;A &lt;strong&gt;language world model&lt;/strong&gt; predicts the new state of the environment given
(current-state, agent-action). Interestingly, the observation is emitted as XML/HTML
allow even GUI environments to be modelled by a text-only LLM.&lt;/p&gt;</description></item><item><title>A Tiny Q-learning Example in Python</title><link>https://bharathbhushan1.github.io/blog/posts/2026-06-29-simple-q-learning/</link><pubDate>Mon, 29 Jun 2026 08:30:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-06-29-simple-q-learning/</guid><description>&lt;p&gt;I wanted to get a better sense of the temporal-difference update rule. So took some help
from Claude and wrote a small Q-learning program. Just uses the python stdlib.
The code lives in &lt;a href="https://github.com/bharathbhushan1/ai-learning/tree/main/q-learning"&gt;&lt;code&gt;q-learning&lt;/code&gt;&lt;/a&gt;,
managed with &lt;a href="https://docs.astral.sh/uv/"&gt;uv&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img alt="A 1D line of six cells, 0 through 5; the agent starts at cell 0 and the learned policy points right at every step toward the goal at cell 5, with Q-values discounted back from the goal" loading="lazy" src="https://bharathbhushan1.github.io/blog/images/q-learning.svg"&gt;&lt;/p&gt;</description></item><item><title>A Tiny Agent, v2: Python and the Sarvam API</title><link>https://bharathbhushan1.github.io/blog/posts/2026-06-28-tiny-agent-v2-sarvam/</link><pubDate>Sun, 28 Jun 2026 18:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-06-28-tiny-agent-v2-sarvam/</guid><description>&lt;p&gt;After the Go &lt;a href="https://bharathbhushan1.github.io/blog/posts/2026-06-28-building-a-tiny-agent/"&gt;tiny coding agent&lt;/a&gt;,
I rewrote the same thing in Python, this time pointed at the
&lt;a href="https://www.sarvam.ai/"&gt;Sarvam&lt;/a&gt; API instead of Gemini. Sarvam is an Indian
company which is trying to work Indian Sovereign. The models are strong on Indian
languages, which made it interesting to target. The code lives in
&lt;a href="https://github.com/bharathbhushan1/ai-learning/tree/main/test-agent-v2"&gt;&lt;code&gt;test-agent-v2&lt;/code&gt;&lt;/a&gt;,
managed with &lt;a href="https://docs.astral.sh/uv/"&gt;uv&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Functionally it is the same agent: a stdin-driven loop, the same three file
tools (&lt;code&gt;read_file&lt;/code&gt;, &lt;code&gt;list_files&lt;/code&gt;, &lt;code&gt;edit_file&lt;/code&gt;), the same Sudarshana ☸️ agent. I had typed
out most of the v1 agent by hand with as little AI help as possible. I just wanted to
get into the weeds of the mechanics, ser-deser, order of various operations, different
data structures needed etc. This time I felt confident I could relate to the different
parts of the agent. So I just asked Claude to rewrite it in python.&lt;/p&gt;</description></item><item><title>Building a Tiny Coding Agent in Go</title><link>https://bharathbhushan1.github.io/blog/posts/2026-06-28-building-a-tiny-agent/</link><pubDate>Sun, 28 Jun 2026 09:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-06-28-building-a-tiny-agent/</guid><description>&lt;p&gt;I built a small CLI coding agent in Go, following Thorsten Ball&amp;rsquo;s
&lt;a href="https://ampcode.com/notes/how-to-build-an-agent"&gt;How to Build an Agent&lt;/a&gt;. It
runs against the free tier of Gemini (&lt;code&gt;gemini-2.5-flash-lite&lt;/code&gt;), so the whole
thing costs nothing to play with. The code lives in
&lt;a href="https://github.com/bharathbhushan1/ai-learning/tree/main/test-agent"&gt;&lt;code&gt;test-agent&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;Agent&lt;/em&gt; abstraction has a method to get user input, an api key to call the
LLM and a list of tools. The Agentic loop gets textual user input, sends it
to the LLM, and displays the output back to the user.&lt;/p&gt;</description></item><item><title>AI Agents</title><link>https://bharathbhushan1.github.io/blog/posts/2026-06-24-ai-agents/</link><pubDate>Wed, 24 Jun 2026 09:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-06-24-ai-agents/</guid><description>&lt;p&gt;&lt;img alt="AI Agents" loading="lazy" src="https://bharathbhushan1.github.io/blog/images/ai-agents.svg"&gt;&lt;/p&gt;
&lt;p&gt;This is the architecture of a typical AI Agent. There is a user operating the agent in order to get his/her task done. There is some local state which the agent can read and write. The agent itself has the following components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The control loop or the agentic loop allows the user to interact with agent. It also orchestrates the complete user interaction flow. Along with this it also handles compaction behaviour, hooks, etc.&lt;/li&gt;
&lt;li&gt;The system prompt, other prompts and skills comprise the instructions and code needed for the agent to work.&lt;/li&gt;
&lt;li&gt;Together the above two sets of components can be called the &amp;ldquo;harness&amp;rdquo;.&lt;/li&gt;
&lt;li&gt;Code sandbox allows execution of code generated by the LLM. Tools allow various kinds of processing. MCP server and client allow connecting to various sources of data.&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>The Bitter Lesson</title><link>https://bharathbhushan1.github.io/blog/posts/2026-06-17-bitter-lesson/</link><pubDate>Wed, 17 Jun 2026 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-06-17-bitter-lesson/</guid><description>&lt;p&gt;This post is a short summary of Rich Sutton&amp;rsquo;s &lt;a href="http://www.incompleteideas.net/IncIdeas/BitterLesson.html"&gt;Bitter Lesson&lt;/a&gt; essay.&lt;/p&gt;
&lt;h3 id="context"&gt;Context&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Cost of computation reduces exponentially with time.&lt;/li&gt;
&lt;li&gt;&amp;ldquo;Brute force&amp;rdquo; approaches which use compute win over human-aided or human-like problem solving over a medium/long time horizon.&lt;/li&gt;
&lt;li&gt;Search is one such computation technique. This helped in Deep Blue winning chess.&lt;/li&gt;
&lt;li&gt;Learning is another. Learning with self-play is yet another. This helped in AlphaGo winning in Go.&lt;/li&gt;
&lt;li&gt;A Hidden Markov model which models sequential processes is yet another computation technique. This helped in speech recognition.&lt;/li&gt;
&lt;li&gt;Deep learning for speech recognition is another step in this direction of using computation instead of human-modeled features.&lt;/li&gt;
&lt;li&gt;Convolutional Neural networks solved image recognition and other vision problems.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="bitter-lesson"&gt;Bitter Lesson&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;The bitter lesson is that building systems based on our understanding of
human knowledge and specifics of problem solving does not work in the long
run. AI researchers build knowledge into their agents and this helps in the
short term. In the long term, progress plateaus and even slows down. A
breakthrough happens by using search/learning along with scaled compute.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="learnings"&gt;Learnings&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Learning 1: General methods like &lt;code&gt;search&lt;/code&gt; and &lt;code&gt;learning&lt;/code&gt; are very powerful and highly scalable with compute.&lt;/li&gt;
&lt;li&gt;Learning 2: The world is very complex. The content of our minds reflects this
extreme complexity. But the mental processes and meta-methods that we use to
capture and represent this arbitrary complexity should we built into AI
systems. We want AI agents to use our discovering process and not need the
knowledge we have discovered.&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Offline Reinforcement Learning</title><link>https://bharathbhushan1.github.io/blog/posts/2026-06-13-offline-rl/</link><pubDate>Sat, 13 Jun 2026 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-06-13-offline-rl/</guid><description>&lt;p&gt;A really nice insight about offline RL algorithms is that off-policy (but online)
algorithms can also be used for offline RL use cases. Structurally they have the same
inputs and same kind of outputs. But there is a fatal flaw.&lt;/p&gt;
&lt;p&gt;For out-of-distribution (OOD) actions, the estimated Q value for off-policy algorithms
can never be corrected. These actions are never present in the dataset and can never
really be learnt from. So there is catastrophic overestimation for OOD actions.&lt;/p&gt;</description></item><item><title>India's 63rd GM - Girish Koushik</title><link>https://bharathbhushan1.github.io/blog/posts/2019-06-25-india-63-gm/</link><pubDate>Tue, 25 Jun 2019 06:08:34 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-06-25-india-63-gm/</guid><description>&lt;p&gt;Girish Koushik became Karnataka&amp;rsquo;s 3rd and India&amp;rsquo;s &lt;a href="https://chessbase.in/news/Girih-Koushik-becomes-Indias-63rd-GM"&gt;63rd
GM&lt;/a&gt;.
He just finished his B.E. in E&amp;amp;C and gained 56 ELO
points and the remaining 2 GM norms in a month. Amazing !&lt;/p&gt;
&lt;p&gt;The graph below shows the enormous progress made by India in chess.
&lt;img alt="India GM graph" loading="lazy" src="https://chessbase.in/images/Graph"&gt;
Source: &lt;a href="https://chessbase.in/news/The-rise-of-chess-in-India"&gt;Chessbase India&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Increase in disposable income of the middle and lower middle classes seems to
be correlated with India&amp;rsquo;s sports boom. This also showcases the aspirations of
Indians after a millenium of foreign rule.&lt;/p&gt;</description></item><item><title>fast.ai course</title><link>https://bharathbhushan1.github.io/blog/posts/2019-06-16-fast-ai/</link><pubDate>Sun, 16 Jun 2019 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-06-16-fast-ai/</guid><description>&lt;p&gt;I have started working on the &lt;a href="https://course.fast.ai"&gt;fast.ai course&lt;/a&gt;. This is the Practical Deep Learning for Coders, v3 course. Strangely the 7 lessons made this course more approachable than others on Coursera/Stanford. Jeremy Howard, the creator of the course, is a brilliant guy and it shows in the way the course is presented. Lots of intuition and tuning knowledge has been embedded in the fast.ai library with the various default hyperparameter values being carefully chosen after a lot of experimentation.&lt;/p&gt;</description></item><item><title>Random stuff</title><link>https://bharathbhushan1.github.io/blog/posts/2019-05-03-random-stuff/</link><pubDate>Fri, 03 May 2019 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-05-03-random-stuff/</guid><description>&lt;ul&gt;
&lt;li&gt;A new paper &lt;a href="https://twitter.com/DeepMindAI/status/1123979484485570566"&gt;Reinforcement Learning, Fast and Slow&lt;/a&gt; from DeepMind reviews recent techniques and improvements in deep Reinforcement Learning. This paper talks about eposodic-RL, meta-RL and its combination.&lt;/li&gt;
&lt;li&gt;A &lt;a href="https://www.nature.com/articles/s41586-019-1119-1"&gt;paper&lt;/a&gt; on technology that can translate neural activity into speech. Mind-blowing.&lt;/li&gt;
&lt;li&gt;Style transfer is such an interesting topic. The seminal &lt;a href="https://arxiv.org/abs/1508.06576"&gt;paper&lt;/a&gt; on this is from the &lt;a href="http://bethgelab.org"&gt;Bethge Lab&lt;/a&gt; and is titled &lt;em&gt;A Neural Algorithm of Artistic Style&lt;/em&gt;. A summary article is &lt;a href="https://towardsdatascience.com/towards-fast-neural-style-transfer-191012b86284"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Decision Trees</title><link>https://bharathbhushan1.github.io/blog/posts/2019-04-22-decision-trees/</link><pubDate>Mon, 22 Apr 2019 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-04-22-decision-trees/</guid><description>&lt;p&gt;This is a short post on decision trees based on my reading of Chapter 6 of &lt;a href="https://www.amazon.in/Hands-Machine-Learning-Scikit-Learn-TensorFlow/dp/1491962291"&gt;Hands–On Machine Learning with Scikit–Learn and TensorFlow &lt;/a&gt;. I am just listing out some interesting points. The book is really good; so please refer to it.&lt;/p&gt;
&lt;h3 id="basics"&gt;Basics&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Decision trees do not require much data preparation (feature scaling, centering etc).&lt;/li&gt;
&lt;li&gt;Gini score indicates impurity of a decision tree node (do all training examples belong to a single class or not)&lt;/li&gt;
&lt;li&gt;CART algorithm to produce a decision tree produces binary trees. ID3 produces trees whose nodes can have more than 2 children.&lt;/li&gt;
&lt;li&gt;Decision trees are white box models because it is easy to see why the decisions were made. Neural networks / Random forests are black box because of the lack of interpretability.&lt;/li&gt;
&lt;li&gt;Decision trees are very easy to apply manually.&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Playing with LSTM</title><link>https://bharathbhushan1.github.io/blog/posts/2019-04-20-playing-with-lstm/</link><pubDate>Sat, 20 Apr 2019 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-04-20-playing-with-lstm/</guid><description>&lt;p&gt;I was trying to learn the basics of LSTM and found this &lt;a href="https://pytorch.org/tutorials/beginner/nlp/sequence_models_tutorial.html"&gt;pytorch tutorial&lt;/a&gt;. Starting from there I tried out the parts-of-speech tagger with minor modifications.&lt;/p&gt;
&lt;h3 id="1-import-the-necessary-libraries"&gt;1. Import the necessary libraries&lt;/h3&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import numpy as np
torch.manual_seed(1)
&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>Summary of a blog post by Kyunghyun Cho</title><link>https://bharathbhushan1.github.io/blog/posts/2019-04-19-summary-of-blog-post/</link><pubDate>Fri, 19 Apr 2019 20:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-04-19-summary-of-blog-post/</guid><description>&lt;p&gt;&lt;a href="https://twitter.com/kchonyc"&gt;Kyunghyun Cho&lt;/a&gt; had written (in 2015) a &lt;a href="https://sites.google.com/site/deepernn/home/blog/briefsummaryofthepaneldiscussionatdlworkshopicml2015"&gt;blog post&lt;/a&gt; titled &lt;em&gt;Brief Summary of the Panel Discussion at DL Workshop @ICML 2015&lt;/em&gt;. I found the post interesting and below is a quick summary.&lt;/p&gt;
&lt;p&gt;The panelists talked about the following topics as the future of deep learning.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Deep learning for NLP&lt;/li&gt;
&lt;li&gt;Unsupervised learning&lt;/li&gt;
&lt;li&gt;Medical image analysis&lt;/li&gt;
&lt;li&gt;Drug discovery&lt;/li&gt;
&lt;li&gt;Q&amp;amp;A systems&lt;/li&gt;
&lt;li&gt;Sequential decision making&lt;/li&gt;
&lt;li&gt;DL for Non-cognitive tasks&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Also there was some content about AI hype, General AI, academia vs industry etc.&lt;/p&gt;</description></item><item><title>Video summary: Adaptive Communication Strategies in Local-Update SGD</title><link>https://bharathbhushan1.github.io/blog/posts/2019-04-19-video-summary-adaptive-communication/</link><pubDate>Fri, 19 Apr 2019 12:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-04-19-video-summary-adaptive-communication/</guid><description>&lt;p&gt;This is a summary of the video &lt;a href="https://youtu.be/RTGb-sbK19s"&gt;Adaptive Communication Strategies in Local-Update SGD&lt;/a&gt; from &lt;a href="https://www.sysml.cc"&gt;SysML 2019&lt;/a&gt; conference.&lt;/p&gt;
&lt;p&gt;Datasets as well as ML models are becoming larger. So SGD on a single machine is slow. Generally we need to optimise &lt;em&gt;Error Convergence&lt;/em&gt; (actual training progress per iteration). But in a distributed setting we also need to optimise &lt;em&gt;System Throughput&lt;/em&gt; (iterations per unit of wall-clock time). Ideally we need to focus on both (actually the product of the two, which is training progress per unit of wall-clock time).&lt;/p&gt;</description></item><item><title>Paper summary: Document Expansion by Query Prediction</title><link>https://bharathbhushan1.github.io/blog/posts/2019-04-19-paper-summary-document-expansion/</link><pubDate>Fri, 19 Apr 2019 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-04-19-paper-summary-document-expansion/</guid><description>&lt;p&gt;This is a short summary of the paper &lt;a href="https://arxiv.org/abs/1904.08375"&gt;Document Expansion by Query Prediction&lt;/a&gt; by Rodrigo Nogueira, Wei Yang, Jimmy Lin, and Kyunghyun Cho.&lt;/p&gt;
&lt;p&gt;When a search engine wants to find a document, it uses its index. The costly parts of the ranking algorithm are usually implemented as re-rankers which take the top-n search results and then reorder them (or re-rank them).&lt;/p&gt;
&lt;p&gt;This paper has a doc2query ML model which takes a document and comes up with queries which are well answered by the document. Then the query is attached to the document as metadata.&lt;/p&gt;</description></item><item><title>Alternatives to SGD</title><link>https://bharathbhushan1.github.io/blog/posts/2019-04-19-alternatives-to-sgd/</link><pubDate>Tue, 05 Mar 2019 20:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-04-19-alternatives-to-sgd/</guid><description>&lt;p&gt;&lt;img alt="SGD" loading="lazy" src="https://sebastianraschka.com/images/faq/closed-form-vs-gd/ball.png"&gt;&lt;/p&gt;
&lt;p&gt;Mini-batch SGD has been the mainstay of algorithms to optimise the cost function in neural networks. But there are multiple alternatives.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Hessian optimization&lt;/li&gt;
&lt;li&gt;Momentum based techniques&lt;/li&gt;
&lt;li&gt;BFGS and its variants&lt;/li&gt;
&lt;li&gt;Nesterov&amp;rsquo;s accelerated gradient&lt;/li&gt;
&lt;li&gt;&amp;hellip;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Chess Tablebases</title><link>https://bharathbhushan1.github.io/blog/posts/2019-03-05-chess-tablebases/</link><pubDate>Tue, 05 Mar 2019 20:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-03-05-chess-tablebases/</guid><description>&lt;p&gt;I was reading a bit about chess tablebases today. Interesting concept of
storing all positions and their results so that there is no need to compute
anything in endgames.&lt;/p&gt;</description></item><item><title>GPU: CUDA architecture</title><link>https://bharathbhushan1.github.io/blog/posts/2017-11-02-cuda-architecture/</link><pubDate>Thu, 02 Nov 2017 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2017-11-02-cuda-architecture/</guid><description>&lt;p&gt;CUDA is Nvidia’s initiative to define a programming model and hardware architecture which aims to allow GPUs to be unified with CPUs for compute. There are various aspects of CUDA and we will try to gain an appreciation for it in this article.&lt;/p&gt;
&lt;p&gt;An application which wants to use GPU for some general purpose compute has to define a kernel function (C interface). This kernel function is run on lots of data elements in parallel. Each GPU can run different kernels, possibly from different applications. One kernel submitted to the GPU runs as a grid. Each grid consists of many thread blocks. Each thread block consists of many threads.&lt;/p&gt;</description></item><item><title>GPU: Nvidia architectures</title><link>https://bharathbhushan1.github.io/blog/posts/2017-11-01-gpu-nvidia-architectures/</link><pubDate>Wed, 01 Nov 2017 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2017-11-01-gpu-nvidia-architectures/</guid><description>&lt;p&gt;GPU microarchitectures: Tesla -&amp;gt; Fermi -&amp;gt; Kepler -&amp;gt; Maxwell -&amp;gt; Pascal -&amp;gt; Volta&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;AWS P3 uses Tesla V100 cards — Volta microarchitecture.&lt;/li&gt;
&lt;li&gt;AWS G3 uses Tesla M60 cards — Maxwell microarchitecure.&lt;/li&gt;
&lt;li&gt;AWS G2 uses Tesla GRID K520 cards — Kepler microarchitecture.&lt;/li&gt;
&lt;li&gt;AWS P2 uses Tesla K80 cards (GK210 GPU) — Kepler microarchitecture.&lt;/li&gt;
&lt;li&gt;AWS CG1 uses Tesla M2050 cards — Fermi microarchitecture.&lt;/li&gt;
&lt;li&gt;GCE provides K80 and P100.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A tensorcore is a logic circuit which allows 16x16 matrix multiplication followed by addition as a primitive. This speeds up the inner loops of deep learning programs.&lt;/p&gt;</description></item><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>Tensorflow — Simple Transformations</title><link>https://bharathbhushan1.github.io/blog/posts/2016-11-23-tensorflow-simple-transformations/</link><pubDate>Wed, 23 Nov 2016 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2016-11-23-tensorflow-simple-transformations/</guid><description>&lt;p&gt;I am trying out stuff from &lt;a href="http://learningtensorflow.com/lesson3/"&gt;http://learningtensorflow.com/lesson3/&lt;/a&gt; which talks about simple image transformations using tensorflow. I am trying this out in zeppelin + pyspark.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;sh&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;wget&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;learningtensorflow&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;MarshOrchid&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;jpg&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;readlink&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="n"&gt;MarshOrchid&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;jpg&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&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="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;pyspark&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;np&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;StringIO&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;matplotlib&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;matplotlib&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Agg&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# turn off interactive charting so this works for server side SVG rendering&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;matplotlib&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;matplotlib.image&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;mpimg&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&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;img&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;StringIO&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StringIO&lt;/span&gt;&lt;span class="p"&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;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;savefig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;svg&amp;#39;&lt;/span&gt;&lt;span class="p"&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;img&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;seek&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;%html &amp;lt;div style=&amp;#39;width:600px&amp;#39;&amp;gt;&amp;#34;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;&amp;lt;/div&amp;gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&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="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;pyspark&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clf&lt;/span&gt;&lt;span class="p"&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;filename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="n"&gt;MarshOrchid&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;jpg&lt;/span&gt;&lt;span class="err"&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;image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mpimg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;imread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&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;tf&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reset_default_graph&lt;/span&gt;&lt;span class="p"&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;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tf&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Variable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="p"&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;init&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tf&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;initialize_all_variables&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;tf&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;sess&lt;/span&gt;&lt;span class="p"&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;rotate1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tf&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transpose&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;perm&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&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;sess&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;init&lt;/span&gt;&lt;span class="p"&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;result1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sess&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rotate1&lt;/span&gt;&lt;span class="p"&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;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;121&lt;/span&gt;&lt;span class="p"&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;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;imshow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&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;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;122&lt;/span&gt;&lt;span class="p"&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;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;imshow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result1&lt;/span&gt;&lt;span class="p"&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;show&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Tensorflow — Order of fetches</title><link>https://bharathbhushan1.github.io/blog/posts/2016-11-21-tensorflow-order-of-fetches/</link><pubDate>Mon, 21 Nov 2016 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2016-11-21-tensorflow-order-of-fetches/</guid><description>&lt;p&gt;I am playing with Tensorflow and found this interesting effect. The following code fragment gives different results each time you run it.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;tf.reset_default_graph()
state = tf.Variable(2.0, name=”state”)
one = tf.constant(1.0, name=”one”)
update = tf.assign(state, tf.add(state, one))
init = tf.initialize_all_variables()
with tf.Session(config=config) as sess:
sess.run(init)
result = sess.run([update, state])
print(result)
result = sess.run([update, state])
print(result)
[3.0, 2.0]
[4.0, 3.0]
[3.0, 2.0]
[4.0, 4.0]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It looks like the order of fetches in Tensorflow is not fixed. For tensors, they might be evaluated after the ops or before the ops. Depending on the actual order the fetch result will be different.&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>g2.2xlarge GPU basics</title><link>https://bharathbhushan1.github.io/blog/posts/2016-11-12-g2-2xlarge-gpu-basics/</link><pubDate>Sat, 12 Nov 2016 12:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2016-11-12-g2-2xlarge-gpu-basics/</guid><description>&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;For example EC2&amp;rsquo;s g2.2xlarge machine has the following graphics card.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;00:03.0 VGA compatible controller: nVidia Corporation GK104GL [GRID K520] (rev a1)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href="https://www.techpowerup.com/gpudb/2312/grid-k520"&gt;GRID K520&lt;/a&gt; belongs to Nvidia&amp;rsquo;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.&lt;/p&gt;</description></item><item><title>What is Machine Learning: Part 2</title><link>https://bharathbhushan1.github.io/blog/posts/2016-11-12-what-is-machine-learning-part-2/</link><pubDate>Sat, 12 Nov 2016 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2016-11-12-what-is-machine-learning-part-2/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Arthur Samuel described it as: &amp;ldquo;the field of study that gives computers the ability to learn without being explicitly programmed.&amp;rdquo;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;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.&lt;/p&gt;</description></item><item><title>Machine Learning Course: Part 1</title><link>https://bharathbhushan1.github.io/blog/posts/2016-11-11-machine-learning-course-part-1/</link><pubDate>Fri, 11 Nov 2016 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2016-11-11-machine-learning-course-part-1/</guid><description>&lt;p&gt;I just started the online Coursera course for &lt;a href="https://www.coursera.org/learn/machine-learning/lecture/RKFpn/welcome"&gt;Machine Learning&lt;/a&gt; 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 &lt;a href="http://cs229.stanford.edu/materials.html"&gt;page&lt;/a&gt; has lot of material).&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;</description></item><item><title>What are measures, dimensions and facts</title><link>https://bharathbhushan1.github.io/blog/posts/2016-01-06-warehouse/</link><pubDate>Wed, 06 Jan 2016 19:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2016-01-06-warehouse/</guid><description>&lt;p&gt;I did a bit of basic reading about measures, dimensions and facts. The most pithy explanation I have gathered is:-&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;facts are tables, they record events, they are verb-like&lt;/li&gt;
&lt;li&gt;dimensions are tables, they record entities, they are noun-like&lt;/li&gt;
&lt;li&gt;dimension columns are columns in the fact table and are foreign keys into dimension tables&lt;/li&gt;
&lt;li&gt;measure columns are columns in the fact table and are things that matter to the business at hand&lt;/li&gt;
&lt;li&gt;dimensions columns are discrete&lt;/li&gt;
&lt;li&gt;measure columns are usually continuous&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;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.&lt;/p&gt;</description></item><item><title>Feynman lectures on physics</title><link>https://bharathbhushan1.github.io/blog/posts/2015-12-12-feynman-0001/</link><pubDate>Sat, 12 Dec 2015 13:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2015-12-12-feynman-0001/</guid><description>&lt;p&gt;I would really like to read Feynman&amp;rsquo;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.&lt;/p&gt;
&lt;p&gt;Today I will try to summarize and think aloud about the first unit in that
book: &lt;a href="http://www.feynmanlectures.caltech.edu/I_01.html"&gt;http://www.feynmanlectures.caltech.edu/I_01.html&lt;/a&gt;. Of course, having such
a great resource available online is a privilege.&lt;/p&gt;
&lt;p&gt;Physics is a rapidly developing field and has accumulated a tremendous amount
of knowledge. Fortunately this mass of knowledge can be condensed into &lt;em&gt;laws&lt;/em&gt;. But the
laws are hard to understand without context.&lt;/p&gt;</description></item><item><title>How to use spark with anaconda python</title><link>https://bharathbhushan1.github.io/blog/posts/2015-12-12-spark-anaconda/</link><pubDate>Sat, 12 Dec 2015 08:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2015-12-12-spark-anaconda/</guid><description>&lt;p&gt;The setup is spark 1.5.1 running on yarn (hadoop-2.6.0).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Install anaconda python on all nodes of the cluster.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Below we are installing anaconda&amp;#39;s python-2.7 64-bit package.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wget https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda2-2.4.1-Linux-x86_64.sh
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bash Anaconda2-2.4.1-Linux-x86_64.sh -b -f -p /usr/lib/anaconda2
&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="c1"&gt;# Run this on all nodes of the cluster and restart the ResourceManager/NodeManager daemons.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;VIRTUAL_ENV_DISABLE_PROMPT=1 source /usr/lib/anaconda2/bin/activate /usr/lib/anaconda2&amp;#34;&lt;/span&gt; &amp;gt;&amp;gt; /usr/lib/hadoop2/etc/hadoop/hadoop-env.sh
&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="c1"&gt;# Set some env vars and start pyspark.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;PYSPARK_PYTHON&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/lib/anaconda2/bin/python
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;PYSPARK_DRIVER_PYTHON&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/lib/anaconda2/bin/python
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/lib/spark/bin/pyspark --master yarn-client --executor-memory 512m --executor-cores &lt;span class="m"&gt;1&lt;/span&gt; --num-executors &lt;span class="m"&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>How ads are shown</title><link>https://bharathbhushan1.github.io/blog/posts/2015-12-11-ads/</link><pubDate>Fri, 11 Dec 2015 20:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2015-12-11-ads/</guid><description>&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;</description></item><item><title>Bigtable</title><link>https://bharathbhushan1.github.io/blog/posts/2014-07-01-bigtable/</link><pubDate>Tue, 01 Jul 2014 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-07-01-bigtable/</guid><description>&lt;p&gt;I am reading Google&amp;rsquo;s &lt;a href="http://research.google.com/archive/bigtable-osdi06.pdf"&gt;Bigtable&lt;/a&gt; paper. Here are some notes.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Can handle petabytes of data spread over thousands of machines&lt;/li&gt;
&lt;li&gt;Clients can dynamically control data format, placement, memory/disk&lt;/li&gt;
&lt;li&gt;Data model is unique, two-level&lt;/li&gt;
&lt;li&gt;Large variations in size and serving latency can be handled&lt;/li&gt;
&lt;li&gt;sparse, distributed, multi-dimensional, sorted map&lt;/li&gt;
&lt;li&gt;row ranges (called tablets) are the unit of distribution and load balancing&lt;/li&gt;
&lt;li&gt;tablets are dynamically sized&lt;/li&gt;
&lt;li&gt;efficiency can be gained by taking advantage of sorting on row keys and
locality in a tablet&lt;/li&gt;
&lt;li&gt;column family is a set of columns&lt;/li&gt;
&lt;li&gt;column family is the unit of access control and accounting&lt;/li&gt;
&lt;li&gt;any number of columns but limited number of column families (100s)&lt;/li&gt;
&lt;li&gt;keep last n versions of data or keep last n seconds of data (garbage
collection)&lt;/li&gt;
&lt;li&gt;API has RowMutation and Scanner as primary abstractions&lt;/li&gt;
&lt;li&gt;uses GFS, cluster management system, sstable, chubby&lt;/li&gt;
&lt;li&gt;sstable is a persistent, ordered, immutable map&lt;/li&gt;
&lt;li&gt;operations for key lookup and key range iteration are supported&lt;/li&gt;
&lt;li&gt;it is split into 64k blocks and there is a block index at the end of the
sstable&lt;/li&gt;
&lt;li&gt;block index allows accessing any key-value in one disk seek&lt;/li&gt;
&lt;li&gt;sstable can also be memory mapped&lt;/li&gt;
&lt;li&gt;chubby is used for&lt;/li&gt;
&lt;li&gt;bigtable master election&lt;/li&gt;
&lt;li&gt;store bootstrap location of bigtable data&lt;/li&gt;
&lt;li&gt;to discover tablet servers&lt;/li&gt;
&lt;li&gt;finalize tablet server deaths&lt;/li&gt;
&lt;li&gt;store bigtable schema info (column family info)&lt;/li&gt;
&lt;li&gt;store acls&lt;/li&gt;
&lt;li&gt;implementation consists of client library, master server and tablet server&lt;/li&gt;
&lt;li&gt;METADATA is a special table in bigtable&lt;/li&gt;
&lt;li&gt;This table is split into multiple tablets&lt;/li&gt;
&lt;li&gt;Each tablet can be present on different tablet servers&lt;/li&gt;
&lt;li&gt;The first tablet is special and is called &lt;em&gt;root tablet&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Root tablet is never split (to keep lookup hierarchy for a tablet to
a max of 3)&lt;/li&gt;
&lt;li&gt;root tablet location is in chubby&lt;/li&gt;
&lt;li&gt;root tablet tracks all the other tablets of the METADATA table&lt;/li&gt;
&lt;li&gt;these other tablets of the METADATA table can be split&lt;/li&gt;
&lt;li&gt;Each row in the METADATA table tracks one user tablet. So each
METADATA tablet tracks one set of user tablets.&lt;/li&gt;
&lt;li&gt;each METADATA table row is hash(table id, end row key) -&amp;gt; location&lt;/li&gt;
&lt;li&gt;With 1KB per row and 128MB METADATA tablet size, trackable number of
tablets is 2^17 * 2^17 = 2^34&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Linux Device Drivers</title><link>https://bharathbhushan1.github.io/blog/posts/2014-06-29-ldd-chapter-1/</link><pubDate>Sun, 29 Jun 2014 16:50:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-06-29-ldd-chapter-1/</guid><description>&lt;p&gt;I started reading &lt;a href="http://lwn.net/Kernel/LDD3/"&gt;LDD3&lt;/a&gt;. Here are some notes.&lt;/p&gt;
&lt;p&gt;A device driver implements mechanisms to support user policies about devices.
The important choices to be made by a driver writer are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;allow device to be opened multiple times&lt;/li&gt;
&lt;li&gt;decide how to handle concurrent requests&lt;/li&gt;
&lt;li&gt;allow sync and async apis&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;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.&lt;/p&gt;</description></item><item><title>Learning cryptography</title><link>https://bharathbhushan1.github.io/blog/posts/2014-05-01-go-crypto/</link><pubDate>Thu, 01 May 2014 01:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-05-01-go-crypto/</guid><description>&lt;p&gt;I have started &lt;a href="https://github.com/manku-timma/go-crypto"&gt;learning&lt;/a&gt; cryptography using Go language.&lt;/p&gt;</description></item><item><title>Above the fold optimizations in Google Pagespeed</title><link>https://bharathbhushan1.github.io/blog/posts/2014-04-25-google-pagespeed-above-the-fold/</link><pubDate>Fri, 25 Apr 2014 20:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-04-25-google-pagespeed-above-the-fold/</guid><description>&lt;p&gt;For Above-the-fold optimizations of Google pagespeed, there are a few relevant documents which I need to dig into and find out relevant ones.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/apache/incubator-pagespeed-mod/wiki/Design-Doc:-Below-the-Fold-Beaconing-for-Split-HTML"&gt;Below the fold beaconing for Split HTML&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/apache/incubator-pagespeed-mod/wiki/Design-Doc:-Beaconing-dependent-optimizations-and-downstream-caching"&gt;Beaconing dependent optimizations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/apache/incubator-pagespeed-mod/wiki/Design-Doc:-Split-HTML-Rewriter"&gt;Split HTML rewriter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/apache/incubator-pagespeed-mod/wiki/Design-Doc:-Detecting-and-Fixing-Reflows"&gt;Detecting and fixing reflows&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Great design docs for mod_pagespeed are &lt;a href="https://github.com/apache/incubator-pagespeed-mod/wiki/Design-Documents"&gt;here&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Odds and Ends</title><link>https://bharathbhushan1.github.io/blog/posts/2014-04-24-odds-ends/</link><pubDate>Thu, 24 Apr 2014 14:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-04-24-odds-ends/</guid><description>&lt;p&gt;Really busy with stuff. Not much exploration. Used EC2 for the first time.
Amazing. The number of AMIs, the storage and security flexibility, the ease of
use are all awesome. I have also been playing around with redis; has an
awesome tutorial. Reminds me of etcd in some of the basic operations.
Played around with nginx and its configuration. Almost every useful module
is not provided by default. You just end up compiling anyways. Started reading
about HyperLogLog.&lt;/p&gt;</description></item><item><title>Playing with CoreOS etcd</title><link>https://bharathbhushan1.github.io/blog/posts/2014-04-18-etcd/</link><pubDate>Fri, 18 Apr 2014 14:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-04-18-etcd/</guid><description>&lt;p&gt;Just for my reference, this is how I setup &lt;a href="https://github.com/coreos/etcd"&gt;etcd&lt;/a&gt; on my ubuntu 12.04.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&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;$ curl &lt;span class="s1"&gt;&amp;#39;http://go.googlecode.com/files/go1.2.1.linux-amd64.tar.gz&amp;#39;&lt;/span&gt; &amp;gt; go1.2.1.linux-amd64.tar.gz
&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;$ tar zxvf go1.2.1.linux-amd64.tar.gz
&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;$ tail -3 ~/.bashrc
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GOROOT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;~/go
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GOBIN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;~/go/bin
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;:~/go/bin
&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;$ go version
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;go version go1.2.1 linux/amd64
&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;$ git clone https://github.com/coreos/etcd
&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="nb"&gt;cd&lt;/span&gt; etcd
&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;$ ./build
&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="c1"&gt;# Blink your eyes and the build is done. :)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Golang is too good. Other than Apache Mesos,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# etcd is the only piece of software which has&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# a dead-easy setup process.&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;$ ./bin/etcd
&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;$ curl -L http://127.0.0.1:4001/v2/keys/mykey
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;errorCode&amp;#34;&lt;/span&gt;:100,&lt;span class="s2"&gt;&amp;#34;message&amp;#34;&lt;/span&gt;:&lt;span class="s2"&gt;&amp;#34;Key not found&amp;#34;&lt;/span&gt;,&lt;span class="s2"&gt;&amp;#34;cause&amp;#34;&lt;/span&gt;:&lt;span class="s2"&gt;&amp;#34;/mykey&amp;#34;&lt;/span&gt;,&lt;span class="s2"&gt;&amp;#34;index&amp;#34;&lt;/span&gt;:1&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&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ curl -L http://127.0.0.1:4001/v2/keys/mykey -XPUT -d &lt;span class="nv"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;this is awesome&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;action&amp;#34;&lt;/span&gt;:&lt;span class="s2"&gt;&amp;#34;set&amp;#34;&lt;/span&gt;,&lt;span class="s2"&gt;&amp;#34;node&amp;#34;&lt;/span&gt;:&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;key&amp;#34;&lt;/span&gt;:&lt;span class="s2"&gt;&amp;#34;/mykey&amp;#34;&lt;/span&gt;,&lt;span class="s2"&gt;&amp;#34;value&amp;#34;&lt;/span&gt;:&lt;span class="s2"&gt;&amp;#34;this is awesome&amp;#34;&lt;/span&gt;,&lt;span class="s2"&gt;&amp;#34;modifiedIndex&amp;#34;&lt;/span&gt;:2, &lt;span class="s2"&gt;&amp;#34;createdIndex&amp;#34;&lt;/span&gt;:2&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&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ curl -L http://127.0.0.1:4001/v2/keys/mykey
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;action&amp;#34;&lt;/span&gt;:&lt;span class="s2"&gt;&amp;#34;get&amp;#34;&lt;/span&gt;,&lt;span class="s2"&gt;&amp;#34;node&amp;#34;&lt;/span&gt;:&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;key&amp;#34;&lt;/span&gt;:&lt;span class="s2"&gt;&amp;#34;/mykey&amp;#34;&lt;/span&gt;,&lt;span class="s2"&gt;&amp;#34;value&amp;#34;&lt;/span&gt;:&lt;span class="s2"&gt;&amp;#34;this is awesome&amp;#34;&lt;/span&gt;,&lt;span class="s2"&gt;&amp;#34;modifiedIndex&amp;#34;&lt;/span&gt;:2,&lt;span class="s2"&gt;&amp;#34;createdIndex&amp;#34;&lt;/span&gt;:2&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&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ httperf --hog --server&lt;span class="o"&gt;=&lt;/span&gt;127.0.0.1 --port&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;4002&lt;/span&gt; --uri&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;/v2/keys/foo?value=test&amp;#34;&lt;/span&gt; --method&lt;span class="o"&gt;=&lt;/span&gt;PUT --num-conn&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;500&lt;/span&gt; --num-call&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;500&lt;/span&gt; --rate&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;100&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="c1"&gt;# The above load test produces 3100 updates per second.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The full api is explained &lt;a href="https://github.com/coreos/etcd/blob/master/Documentation/api.md"&gt;here&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Playing with Apache Hive</title><link>https://bharathbhushan1.github.io/blog/posts/2014-04-12-hive/</link><pubDate>Sat, 12 Apr 2014 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-04-12-hive/</guid><description>&lt;p&gt;Just for my reference, this is how I setup &lt;a href="https://cwiki.apache.org/confluence/display/Hive/GettingStarted"&gt;Apache Hive&lt;/a&gt; on my ubuntu
12.04.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&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;bash&amp;gt; tar zxvf hive-0.11.0-bin.tar.gz
&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;bash&amp;gt; &lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;HADOOP_HOME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/hduser/hadoop/
&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;bash&amp;gt; &lt;span class="nv"&gt;$HADOOP_HOME&lt;/span&gt;/bin/hadoop fs -mkdir /tmp
&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;bash&amp;gt; &lt;span class="nv"&gt;$HADOOP_HOME&lt;/span&gt;/bin/hadoop fs -mkdir /user/hive/warehouse
&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;bash&amp;gt; &lt;span class="nv"&gt;$HADOOP_HOME&lt;/span&gt;/bin/hadoop fs -chmod g+w /tmp
&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;bash&amp;gt; &lt;span class="nv"&gt;$HADOOP_HOME&lt;/span&gt;/bin/hadoop fs -chmod g+w /user/hive/warehouse
&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="c1"&gt;# Somehow I could not run without using sudo. It kept&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# throwing some permission denied exception which I&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# could not fix in a short time.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bash&amp;gt; sudo &lt;span class="nv"&gt;HADOOP_HOME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/hduser/hadoop ./bin/hive
&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;hive&amp;gt; create table test&lt;span class="o"&gt;(&lt;/span&gt;id int, msg string&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;OK
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Time taken: 0.383 seconds
&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;hive&amp;gt; show tables&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;OK
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Time taken: 0.061 seconds, Fetched: &lt;span class="m"&gt;1&lt;/span&gt; row&lt;span class="o"&gt;(&lt;/span&gt;s&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&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hive&amp;gt; describe test&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;OK
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;id int None
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msg string None
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Time taken: 0.35 seconds, Fetched: &lt;span class="m"&gt;2&lt;/span&gt; row&lt;span class="o"&gt;(&lt;/span&gt;s&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Playing with MongoDB</title><link>https://bharathbhushan1.github.io/blog/posts/2014-04-10-mongo/</link><pubDate>Thu, 10 Apr 2014 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-04-10-mongo/</guid><description>&lt;p&gt;Just for my reference, this is how I setup &lt;a href="http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/"&gt;mongodb&lt;/a&gt; on my ubuntu
12.04.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&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;bash&amp;gt; sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
&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;bash$ &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; sudo tee /etc/apt/sources.list.d/mongodb.list
&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;bash&amp;gt; sudo apt-get update
&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;bash&amp;gt; sudo apt-get install mongodb-org
&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;bash&amp;gt; ls -lh /var/lib/mongodb
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;total 81M
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;drwxr-xr-x &lt;span class="m"&gt;2&lt;/span&gt; mongodb nogroup 4.0K Apr &lt;span class="m"&gt;10&lt;/span&gt; 02:36 _tmp
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;drwxr-xr-x &lt;span class="m"&gt;2&lt;/span&gt; mongodb nogroup 4.0K Apr &lt;span class="m"&gt;10&lt;/span&gt; 02:36 journal
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rw------- &lt;span class="m"&gt;1&lt;/span&gt; mongodb nogroup 64M Apr &lt;span class="m"&gt;10&lt;/span&gt; 02:36 local.0
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rw------- &lt;span class="m"&gt;1&lt;/span&gt; mongodb nogroup 16M Apr &lt;span class="m"&gt;10&lt;/span&gt; 02:36 local.ns
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rwxr-xr-x &lt;span class="m"&gt;1&lt;/span&gt; mongodb nogroup &lt;span class="m"&gt;5&lt;/span&gt; Apr &lt;span class="m"&gt;10&lt;/span&gt; 02:36 mongod.lock
&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;bash&amp;gt; ls -lh /var/log/mongodb
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;total 4.0K
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rw-r--r-- &lt;span class="m"&gt;1&lt;/span&gt; mongodb nogroup 2.3K Apr &lt;span class="m"&gt;10&lt;/span&gt; 02:37 mongod.log
&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;bash&amp;gt; ps aux &lt;span class="p"&gt;|&lt;/span&gt; grep mongod
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mongodb &lt;span class="m"&gt;3106&lt;/span&gt; 2.1 1.4 &lt;span class="m"&gt;357416&lt;/span&gt; &lt;span class="m"&gt;37048&lt;/span&gt; ? Ssl 02:36 0:04 /usr/bin/mongod --config /etc/mongod.conf
&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="c1"&gt;# Start mongo shell&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt; use mydb
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;switched to db mydb
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; name : &lt;span class="s2"&gt;&amp;#34;manku-timma&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;name&amp;#34;&lt;/span&gt; : &lt;span class="s2"&gt;&amp;#34;manku-timma&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;&amp;gt; &lt;span class="nv"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; age : &lt;span class="m"&gt;45&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;age&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;45&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;&amp;gt; mydb.testData.insert&lt;span class="o"&gt;(&lt;/span&gt;a&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2014-04-10T02:46:07.610+0000 ReferenceError: mydb is not defined
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt; db.testData.insert&lt;span class="o"&gt;(&lt;/span&gt;a&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WriteResult&lt;span class="o"&gt;({&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;nInserted&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;1&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;&amp;gt; db.testData.insert&lt;span class="o"&gt;(&lt;/span&gt;b&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WriteResult&lt;span class="o"&gt;({&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;nInserted&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;1&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;&amp;gt; show collections
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;system.indexes
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;testData
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt; db.testData.find&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;53460605f93ad23879b22181&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;name&amp;#34;&lt;/span&gt; : &lt;span class="s2"&gt;&amp;#34;manku-timma&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;53460608f93ad23879b22182&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;age&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;45&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;&amp;gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;var &lt;span class="nv"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 1&lt;span class="p"&gt;;&lt;/span&gt; i &amp;lt;&lt;span class="o"&gt;=&lt;/span&gt; 25&lt;span class="p"&gt;;&lt;/span&gt; i++&lt;span class="o"&gt;)&lt;/span&gt; db.testData.insert&lt;span class="o"&gt;({&lt;/span&gt; x : i &lt;span class="o"&gt;})&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WriteResult&lt;span class="o"&gt;({&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;nInserted&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;1&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;&amp;gt; db.testData.find&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;53460605f93ad23879b22181&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;name&amp;#34;&lt;/span&gt; : &lt;span class="s2"&gt;&amp;#34;manku-timma&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;53460608f93ad23879b22182&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;age&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;45&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22183&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;1&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22184&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;2&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22185&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;3&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22186&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;4&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22187&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;5&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22188&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;6&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22189&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;7&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b2218a&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;8&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b2218b&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;9&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b2218c&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;10&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b2218d&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;11&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b2218e&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;12&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b2218f&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;13&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22190&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;14&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22191&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;15&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22192&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;16&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22193&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;17&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22194&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;18&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;Type &lt;span class="s2"&gt;&amp;#34;it&amp;#34;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; more
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt; it
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22195&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;19&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22196&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;20&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22197&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;21&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22198&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;22&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b22199&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;23&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b2219a&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;24&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="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : ObjectId&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;5346073af93ad23879b2219b&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;&amp;#34;x&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;25&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;&amp;gt; it
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;no cursor
&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;bash&amp;gt; mongostat
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;connected to: 127.0.0.1
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;insert query update delete getmore &lt;span class="nb"&gt;command&lt;/span&gt; flushes mapped vsize res faults locked db idx miss % qr&lt;span class="p"&gt;|&lt;/span&gt;qw ar&lt;span class="p"&gt;|&lt;/span&gt;aw netIn netOut conn &lt;span class="nb"&gt;time&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; *0 *0 *0 *0 &lt;span class="m"&gt;0&lt;/span&gt; 1&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; 160m 511m 37m &lt;span class="m"&gt;0&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="c1"&gt;# For a simple document insertion, I see about 2800&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# inserts per second. Also about 500KBps of data flow.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Delete is instantaneous for very large number of&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# rows.&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;&amp;gt; db.runCommand&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="o"&gt;{&lt;/span&gt; delete: &lt;span class="s2"&gt;&amp;#34;testData&amp;#34;&lt;/span&gt;, deletes: &lt;span class="o"&gt;[{&lt;/span&gt;q:&lt;span class="o"&gt;{}&lt;/span&gt;, limit:0&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="o"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;ok&amp;#34;&lt;/span&gt; : 1, &lt;span class="s2"&gt;&amp;#34;n&amp;#34;&lt;/span&gt; : &lt;span class="m"&gt;409843&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;</description></item><item><title>Playing with HBase (part 2)</title><link>https://bharathbhushan1.github.io/blog/posts/2014-04-07-playing-with-hbase-2/</link><pubDate>Mon, 07 Apr 2014 20:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-04-07-playing-with-hbase-2/</guid><description>&lt;p&gt;I used &lt;a href="http://pig.apache.org/docs/r0.9.1/basic.html"&gt;Pig&lt;/a&gt; to load data into hbase.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&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="c1"&gt;# Download and extract pig&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="c1"&gt;# Download population data of India&amp;#39;s villages from http://www.censusindia.gov.in/2011census/A-3_Vill/A-3%20MDDS_Release.xls&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="c1"&gt;# Use Libreoffice to convert the .xls to a .csv&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="c1"&gt;# Create a table called villages with a column family called population in HBase&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hbase&amp;gt; create &lt;span class="s1"&gt;&amp;#39;villages&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;population&amp;#39;&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;bash&amp;gt; &lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;PIG_CLASSPATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$PIG_&lt;/span&gt;/home/vagrant/hbase-0.94.18/hbase-0.94.18.jar:/home/vagrant/hbase-0.94.18/lib/*:pig-0.12.0-withouthadoop.jar:/home/hduser/hadoop/lib/*:&lt;span class="nv"&gt;$PIG_CLASSPATH&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="c1"&gt;# Load the csv file in Pig&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;grunt&amp;gt; &lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; load &lt;span class="s1"&gt;&amp;#39;file:///vagrant/village-population.csv&amp;#39;&lt;/span&gt; using PigStorage&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;,&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&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="c1"&gt;# Compute (Name of village, Level of village in hierarchy)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;grunt&amp;gt; &lt;span class="nv"&gt;B&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; foreach A generate &lt;span class="nv"&gt;$4&lt;/span&gt;, &lt;span class="nv"&gt;$3&lt;/span&gt;&lt;span class="p"&gt;;&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="c1"&gt;# Clean up data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;grunt&amp;gt; &lt;span class="nv"&gt;C&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; filter B &lt;span class="nv"&gt;$0&lt;/span&gt; !&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;#39;&lt;/span&gt; and &lt;span class="nv"&gt;$1&lt;/span&gt; !&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&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="c1"&gt;# Save to HBase using name of the village as key and the level as value into population:level column&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;grunt&amp;gt; store C into &lt;span class="s1"&gt;&amp;#39;hbase://villages&amp;#39;&lt;/span&gt; using org.apache.pig.backend.hadoop.hbase.HBaseStorage&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;population:level&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&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="c1"&gt;# Compute (Name of village, Number of persons in village)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;grunt&amp;gt; &lt;span class="nv"&gt;B&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; foreach A generate &lt;span class="nv"&gt;$4&lt;/span&gt;, &lt;span class="nv"&gt;$6&lt;/span&gt;&lt;span class="p"&gt;;&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="c1"&gt;# Clean up data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;grunt&amp;gt; &lt;span class="nv"&gt;C&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; filter B BY &lt;span class="nv"&gt;$0&lt;/span&gt; !&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;#39;&lt;/span&gt; and &lt;span class="nv"&gt;$1&lt;/span&gt; !&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&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="c1"&gt;# Save to HBase using name of village as key and the number of persons as the value into population:persons column&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;grunt&amp;gt; store C into &lt;span class="s1"&gt;&amp;#39;hbase://villages&amp;#39;&lt;/span&gt; using org.apache.pig.backend.hadoop.hbase.HBaseStorage&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;population:persons&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&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="c1"&gt;# Get all the data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hbase&amp;gt; scan &lt;span class="s1"&gt;&amp;#39;villages&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ROW COLUMN+CELL
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s1"&gt;&amp;#39;N&amp;#39;&lt;/span&gt; Thingdawl &lt;span class="nv"&gt;column&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;population:level, &lt;span class="nv"&gt;timestamp&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1396879365983,
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nv"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;SUB-DISTRICT
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s1"&gt;&amp;#39;N&amp;#39;&lt;/span&gt; Thingdawl &lt;span class="nv"&gt;column&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;population:persons, &lt;span class="nv"&gt;timestamp&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;139687960225&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 8, &lt;span class="nv"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;12108&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&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; Zunheboto Sadar &lt;span class="nv"&gt;column&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;population:level, &lt;span class="nv"&gt;timestamp&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1396879365963,
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nv"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;SUB-DISTRICT
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Zunheboto Sadar &lt;span class="nv"&gt;column&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;population:persons, &lt;span class="nv"&gt;timestamp&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;139687960225&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 6, &lt;span class="nv"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;13344&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="c1"&gt;# Get all states, districts, sub-districts which&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# have a rural population of 10000 exactly :)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hbase&amp;gt; import org.apache.hadoop.hbase.filter.CompareFilter
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hbase&amp;gt; import org.apache.hadoop.hbase.filter.SingleColumnValueFilter
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hbase&amp;gt; import org.apache.hadoop.hbase.filter.SubstringComparator
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hbase&amp;gt; import org.apache.hadoop.hbase.util.Bytes
&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="c1"&gt;# EQUAL works. But any other kind of numeric&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# compare does not work.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hbase&amp;gt; scan &lt;span class="s1"&gt;&amp;#39;villages&amp;#39;&lt;/span&gt;, &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;LIMIT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&amp;gt; 10, &lt;span class="nv"&gt;FILTER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&amp;gt; SingleColumnValueFilter.new&lt;span class="o"&gt;(&lt;/span&gt;Bytes.toBytes&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;population&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, Bytes.toBytes&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;persons&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, CompareFilter::CompareOp.valueOf&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;EQUAL&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, Bytes.toBytes&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;10000&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;, &lt;span class="nv"&gt;COLUMNS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&amp;gt; &lt;span class="s1"&gt;&amp;#39;population:persons&amp;#39;&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;p&gt;I tried a simple numeric comparison and fought
long and hard to get it right but it seems nigh
impossible for today. My brain is also shutting
down. Documentation seems really sparse. This
&lt;a href="http://stackoverflow.com/questions/11013197/how-to-scan-table-for-a-column-having-particular-value-in-hbase"&gt;link&lt;/a&gt; was the one ray of hope in the
dark expanse of the internet. In terms of filters
hbase is probably really immature and
documentation is worse. Getting a few values
can&amp;rsquo;t be this hard. A SQL layer on top of hbase
seems necessary. The hbase shell syntax is too
much of a pain and is too idiosyncratic.&lt;/p&gt;</description></item><item><title>Playing with HBase</title><link>https://bharathbhushan1.github.io/blog/posts/2014-04-07-playing-with-hbase/</link><pubDate>Mon, 07 Apr 2014 14:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-04-07-playing-with-hbase/</guid><description>&lt;p&gt;Below are the steps I followed to get HBase up and running.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&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="c1"&gt;# Download and extract hbase-0.94.18 into /home/vagrant/hbase-0.94.18&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="c1"&gt;# Edit hbase-0.94.18/conf/hbase-site.xml to save data in /home/vagrant/hbase&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;configuration&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;property&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;name&amp;gt;hbase.rootdir&amp;lt;/name&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;value&amp;gt;/home/vagrant/hbase/hbase&amp;lt;/value&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;/property&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;property&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;name&amp;gt;hbase.zookeeper.property.dataDir&amp;lt;/name&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;value&amp;gt;/home/vagrant/hbase/zookeeper&amp;lt;/value&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;/property&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;/configuration&amp;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="c1"&gt;# Edit hadoop-metrics.properties for monitoring with ganglia&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dfs.class&lt;span class="o"&gt;=&lt;/span&gt;org.apache.hadoop.metrics.ganglia.GangliaContext31
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dfs.period&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dfs.servers&lt;span class="o"&gt;=&lt;/span&gt;239.2.11.71:8649
&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;mapred.class&lt;span class="o"&gt;=&lt;/span&gt;org.apache.hadoop.metrics.ganglia.GangliaContext31
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mapred.period&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mapred.servers&lt;span class="o"&gt;=&lt;/span&gt;239.2.11.71:8649
&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;jvm.class&lt;span class="o"&gt;=&lt;/span&gt;org.apache.hadoop.metrics.ganglia.GangliaContext31
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;jvm.period&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;jvm.servers&lt;span class="o"&gt;=&lt;/span&gt;239.2.11.71:8649
&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;rpc.class&lt;span class="o"&gt;=&lt;/span&gt;org.apache.hadoop.metrics.ganglia.GangliaContext31
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpc.period&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpc.servers&lt;span class="o"&gt;=&lt;/span&gt;239.2.11.71:8649
&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="c1"&gt;# Add a column and some data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hbase&amp;gt; create &lt;span class="s1"&gt;&amp;#39;test&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;columnfamily&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hbase&amp;gt; put &lt;span class="s1"&gt;&amp;#39;test&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;rowkey1&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;columnfamily:column1&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;value1&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hbase&amp;gt; put &lt;span class="s1"&gt;&amp;#39;test&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;rowkey1&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;columnfamily:column2&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;value2&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hbase&amp;gt; put &lt;span class="s1"&gt;&amp;#39;test&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;rowkey2&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;columnfamily:column1&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;value3&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hbase&amp;gt; put &lt;span class="s1"&gt;&amp;#39;test&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;rowkey2&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;columnfamily:column2&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;value4&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hbase&amp;gt; scan &lt;span class="s1"&gt;&amp;#39;test&amp;#39;&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="c1"&gt;# Try out HBase-on-HDFS. HDFS is running locally listening on IP 10.0.2.15&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;configuration&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;property&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;name&amp;gt;hbase.rootdir&amp;lt;/name&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;value&amp;gt;hdfs://10.0.2.15/user/hduser/hbase/hbase&amp;lt;/value&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;/property&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;property&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;name&amp;gt;hbase.zookeeper.property.dataDir&amp;lt;/name&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;value&amp;gt;hdfs://10.0.2.15/user/hduser/hbase/zookeeper&amp;lt;/value&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;/property&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;/configuration&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Some Interprocess communication patterns</title><link>https://bharathbhushan1.github.io/blog/posts/2014-04-07-ipc-patterns/</link><pubDate>Mon, 07 Apr 2014 12:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-04-07-ipc-patterns/</guid><description>&lt;p&gt;IPC patterns quick reference (from this &lt;a href="http://www.cs.unm.edu/~crowley/osbook/begin.html"&gt;book&lt;/a&gt;):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Mutual exclusion (2 process, n process)&lt;/li&gt;
&lt;li&gt;Critical section (2 process, n process)&lt;/li&gt;
&lt;li&gt;Signaling (2 process, n process)&lt;/li&gt;
&lt;li&gt;Rendezvous (2 process, n process)&lt;/li&gt;
&lt;li&gt;Producer/Consumer&lt;/li&gt;
&lt;li&gt;Server/Client&lt;/li&gt;
&lt;li&gt;Database update/read&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The fundamental means of communication between processes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Message passing&lt;/li&gt;
&lt;li&gt;Shared memory&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Setting up Ganglia</title><link>https://bharathbhushan1.github.io/blog/posts/2014-04-07-setting-up-ganglia/</link><pubDate>Mon, 07 Apr 2014 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-04-07-setting-up-ganglia/</guid><description>&lt;p&gt;Just for my reference, this is how I setup &lt;a href="http://sourceforge.net/apps/trac/ganglia/wiki/ganglia_quick_start"&gt;ganglia&lt;/a&gt; on my ubuntu
12.04.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&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="c1"&gt;# Install relevant packages&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ sudo apt-get install ganglia-monitor gmetad ganglia-webfrontend
&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="c1"&gt;# Edit /etc/ganglia/gmond.conf by setting the cluster attribute as below&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cluster &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="nv"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;local-cluster&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nv"&gt;owner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;manku-timma&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nv"&gt;latlong&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;world&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nv"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;http://127.0.0.1:9001/ganglia&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&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&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# List statistics being monitored&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ telnet localhost &lt;span class="m"&gt;8649&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="c1"&gt;# Modification to /etc/apache2/sites-available/default&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Alias /ganglia/ &lt;span class="s2"&gt;&amp;#34;/usr/share/ganglia-webfrontend/&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;Directory &lt;span class="s2"&gt;&amp;#34;/usr/share/ganglia-webfrontend/&amp;#34;&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; AllowOverride None
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Order allow,deny
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Allow from all
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;/Directory&amp;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="c1"&gt;# Restart apache after config change&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ sudo service apache2 restart
&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="c1"&gt;# List statistics being stored&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ telnet localhost &lt;span class="m"&gt;8651&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="c1"&gt;# Location of stored statistics&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ ls /var/lib/ganglia/rrds/unspecified/__SummaryInfo__
&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="c1"&gt;# In a browser access http://localhost/ganglia to view graphs.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To &lt;a href="http://wiki.apache.org/hadoop/GangliaMetrics"&gt;configure&lt;/a&gt; &lt;a href="http://hbase.apache.org/book/quickstart.html"&gt;hbase&lt;/a&gt; to report metrics:&lt;/p&gt;</description></item><item><title>Understanding Write Ahead Logging</title><link>https://bharathbhushan1.github.io/blog/posts/2014-04-06-understanding-wal/</link><pubDate>Sun, 06 Apr 2014 12:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-04-06-understanding-wal/</guid><description>&lt;p&gt;I am trying to understand WAL (Write Ahead Logging) from the perspective of
sqlite3, HBase etc. Below is a summary of my understanding. Refer to these
links for more information: &lt;a href="https://www.sqlite.org/wal.html"&gt;sqlite3&lt;/a&gt;, &lt;a href="http://www.postgresql.org/docs/current/static/wal.html"&gt;postgresql&lt;/a&gt;,
&lt;a href="http://www.devintersection.com/updates/Randal-SQL-Logging.pdf"&gt;sqlserver&lt;/a&gt;, &lt;a href="http://blog.cloudera.com/blog/2012/06/hbase-write-path/"&gt;hbase&lt;/a&gt;, &lt;a href="http://research.google.com/archive/bigtable.html"&gt;bigtable&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;###General stuff&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What is WAL&lt;/li&gt;
&lt;li&gt;Write new content of a write at end of a WAL file instead overwriting
content in the actual database file&lt;/li&gt;
&lt;li&gt;Advantages of WAL&lt;/li&gt;
&lt;li&gt;Writes and reads are faster&lt;/li&gt;
&lt;li&gt;Writes and reads can be concurrent (for a given data file)&lt;/li&gt;
&lt;li&gt;More sequential disk I/O&lt;/li&gt;
&lt;li&gt;Fewer &lt;code&gt;fsync()&lt;/code&gt; calls&lt;/li&gt;
&lt;li&gt;Allows crash recovery&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;###Sqlite3&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 on Apache Mesos (continued)</title><link>https://bharathbhushan1.github.io/blog/posts/2014-03-31-mesos-continued/</link><pubDate>Mon, 31 Mar 2014 06:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-03-31-mesos-continued/</guid><description>&lt;p&gt;Continuing my failed &lt;a href="http://manku-timma.github.io/2014/03/28/running-mesos.html"&gt;attempt&lt;/a&gt; to run spark on mesos.
&lt;a href="https://twitter.com/pacoid"&gt;@pacoid&lt;/a&gt; pointed me to a nice &lt;a href="http://mesosphere.io/learn/run-spark-on-mesos/"&gt;tutorial&lt;/a&gt; for this. Rest
of this post is just documentation of my efforts. To spare you the pain
of reading through all of this &amp;ndash; it ends well.&lt;/p&gt;
&lt;p&gt;As of now I just want to run mesos properly. The test failures were due to the
/vagrant directory usage. Basically I had synced the mesos source tree into
/vagrant, which is shared between the host OS-X and the guest
ubuntu-in-vagrant. It turns out that &lt;code&gt;mmap(... MAP_SHARED ...)&lt;/code&gt; throws &lt;code&gt;EINVAL&lt;/code&gt;
when the file being mmaped is in /vagrant. This was causing leveldb&amp;rsquo;s MANIFEST
file write to fail. This in turn caused all the mesos registrar tests and
leveldb state tests to fail. So just moving the source tree from /vagrant to
/home/vagrant solved the problem and allowed me to do a clean &lt;code&gt;make check&lt;/code&gt;. :)&lt;/p&gt;</description></item><item><title>Understanding Dremel</title><link>https://bharathbhushan1.github.io/blog/posts/2014-03-29-dremel/</link><pubDate>Sat, 29 Mar 2014 12:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-03-29-dremel/</guid><description>&lt;p&gt;I am reading Google&amp;rsquo;s interesting paper on the &lt;a href="http://research.google.com/pubs/pub36632.html"&gt;dremel&lt;/a&gt; system.
Below is a digest.&lt;/p&gt;
&lt;p&gt;Dremel is an scalable, interactive adhoc query system for analysis of
read-only nested data.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;directly deals with nested data&lt;/li&gt;
&lt;li&gt;operates on commodity clusters&lt;/li&gt;
&lt;li&gt;uses serving tree like web search&lt;/li&gt;
&lt;li&gt;unlike pig/hive executes query natively without using MR&lt;/li&gt;
&lt;li&gt;uses columnar representation&lt;/li&gt;
&lt;li&gt;only relevant columns need to be read&lt;/li&gt;
&lt;li&gt;each column is better compressed&lt;/li&gt;
&lt;li&gt;this results in cpu, memory, iops, disk savings&lt;/li&gt;
&lt;li&gt;data model is same as that for protocol buffers&lt;/li&gt;
&lt;li&gt;new columnar representation for nested records&lt;/li&gt;
&lt;li&gt;fast record assembly algorithm using FSM and definition/repetition levels&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Understanding Millwheel</title><link>https://bharathbhushan1.github.io/blog/posts/2014-03-29-millwheel/</link><pubDate>Sat, 29 Mar 2014 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-03-29-millwheel/</guid><description>&lt;p&gt;I am reading Google&amp;rsquo;s interesting paper on the &lt;a href="http://research.google.com/pubs/pub41378.html"&gt;millwheel&lt;/a&gt; system.
Below is a digest.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;One time input to the system: computation graph, application code for nodes&lt;/li&gt;
&lt;li&gt;Ongoing stuff handled by the system: persistent state, streaming input&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The programming model provides:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;short term persistent storage&lt;/li&gt;
&lt;li&gt;long term persistent storage&lt;/li&gt;
&lt;li&gt;low watermark timestamp&lt;/li&gt;
&lt;li&gt;logical time&lt;/li&gt;
&lt;li&gt;out-of-order record processing&lt;/li&gt;
&lt;li&gt;exactly-once semantics for record processing.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The persistent store is per-key per computation. So if there are 4 nodes in the
computation DAG, there will be 4 &amp;ldquo;tables&amp;rdquo; with rows keyed on the key in the
input record. Timers are based on low watermarks. The unique id which is used
for ensuring exactly once semantics is assigned by the system and not by the
user (not in the input). In a strong production, output data, state, timers &amp;ndash;
all are snapshotted in a single per-key per-computation atomic write. In a weak
production, output data is sent forth optimistically assuming the receiver can
ACK it quickly. A write sequencer is assigned to a lexicographic key interval
of each computation. A sequencer ensures that older pending writes dont
overwrite results of newer writes. Also the low watermarks are persisted for
data consistency.&lt;/p&gt;</description></item><item><title>Running Apache Spark on Apache Mesos</title><link>https://bharathbhushan1.github.io/blog/posts/2014-03-28-running-mesos/</link><pubDate>Fri, 28 Mar 2014 20:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2014-03-28-running-mesos/</guid><description>&lt;p&gt;I am trying to run Apache Spark on Apache Mesos. I am following &lt;a href="https://spark.apache.org/docs/latest/running-on-mesos.html"&gt;this&lt;/a&gt;
tutorial. One problem I hit when trying to save the spark distribution on
HDFS is:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;put: org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot create
/user/hduser/spark-1.0.0-SNAPSHOT-hadoop_1.0.4-bin.tar.gz. Name node is in safe
mode.
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This was solved with:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;bin/hadoop dfsadmin -safemode leave
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;While trying to build mesos I hit the following error:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;vagrant:/vagrant/mesos/build$ sudo apt-get install python-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run &amp;#39;apt-get -f install&amp;#39; to correct these:
The following packages have unmet dependencies:
python-dev : Depends: python2.7-dev (&amp;gt;= 2.7.3) but it is not going to be instal
led
scala : Depends: libjansi-java but it is not going to be installed
E: Unmet dependencies. Try &amp;#39;apt-get -f install&amp;#39; with no packages (or specify a s
olution).
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I was facing this error while doing different apt-get operations and I did not
care too much till now. Now I was stumped. So finally ran &lt;code&gt;apt-get -f install&lt;/code&gt;
without any arguments. Then I could proceed with installing python-dev. Then
I proceeded with building mesos. Build went fine. &lt;code&gt;make check&lt;/code&gt; failed with
the following error:&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>