Leave a comment

HBase Tutorial : Part 1

Certain points to define HBase :

  • Column oriented database management system, which runs on top of HDFS
  • Not a relational data store and does not support query language like SQL – this is called NoSQL database
  • Supports a very flexible data model and thus, it is really good for data that cannot be saved in traditional RDBMS with strict structure.
  • Sparse – this means data can be scattered. If we do not have a value for any given column, it will not exist.
  • It consists of a master node that regulates the cluster and region servers to store portions of table and operate on data.
  • Sharding – HBase is a distributed data store where data is distributed via regions. Once the region outgrows a particular size it gets re-splitted automatically. Thus, supporting automatic sharding.

 

When we should choose HBase :

  • We have huge amount of data. We would get performance benefit only when data is scattered among multiple nodes. For a single node data, perhaps, RDBMS would be a better choice.
  • We don’t need typical RDBMS features like typed columns, typical data model, advanced query language etc.
  • We have a good hadoop cluster with number of datanodes.

    Please note that HBase is not a replacement for RDBMS. Therefore, we just can’t replace a typical database with HBase. Also, though HBase can run on a simple laptop (like I am using) , however, to get the real advantage of HBase we need to have a typical Hadoop cluster.

** Since I am also learning HBase currently, the information given here may not be 100% accurate. If so, please let me know and I’ll modify the content.

Advertisements
Leave a comment

Find commong GCD for two numbers using recursion.

This is a simple program. Pasting it below.


public class FindGCD {
    public static void main (String s[]) {
        System.out.println(gcd(48, 24));
    }

    public static int gcd (int x, int y) {
        if (x > y) {
            return findGcd (x, y);
        } else {
            return findGcd (y,x);
        }
    }

    private static int findGcd (int l, int s) {
        if (l % s == 0) {
            return s;
        } else {
            return findGcd (s, l % s);
        }
    }
}

Leave a comment

Non-recursive algorithm to find the pre-order successor of a given node in a BST

Question: Write a non-recursive algorithm to find the pre-order successor of a given node in a BST.

Solution:
Let me tell you the background first. There are basically three kind of traversal for a binary tree. Each traversal is named on the basis of processing of root node. For example in preorder traversal, root will be processed before any other node, in postorder, root will be processed only after all the nodes are processed.
Continue Reading »

Leave a comment

Configure passwordless ssh to localhost

How to configure passwordless ssh to localhost? Read on for steps.
Continue Reading »

Leave a comment

Concept of Java : Difference between ‘==’ and equals

In Java, we compare two values using either ‘==’ or equals. Let’s see the difference between these two in this article.

Before explaining the difference, I would like to explain what happens when we assign one value to another – for example, whey you say i = j where i might be a variable of primitive data type or a reference variable. Basically, the bit representation of the value at right hand side, gets copied to the variable at left hand side. If we say i = 2, the bit representation of 2 will get copied to i. if we say i = j, bit representation of the value stored in j will get copied to i.
Continue Reading »

Leave a comment

Convert a binary search tree to sorted list

Ques: You have given a binary search tree and you need to change this tree to link list that contains nodes in sorted order.

Solution: We all know that smaller values are on left side. So we need to keep left side values at first place for sorted list. To make this happen we will perform a left ->right rotation starting from root. As we will start from root, after each rotation we will check if still there is a left child, if yes we will again perform a rotation and if not we will jump to the right child and perform the same algorithm as we did with root. Let’s consider the example given below:
Continue Reading »

Leave a comment

Sub-array with sum zero

Ques: An array contains negative as well as positive numbers in random order, find the first sub array for which the sum of all the elements is zero.

Solution: First of all we need to think how can we find out if the sum of all the elements in a sub array is zero. Let’s take an example :
      a= {5,4,3,-2,-2,-3,7}
Continue Reading »