SQL

SQL

DATABASES

SELF JOIN

SELECT a.ID, b.NAME, a.SALARY
FROM CUSTOMERS a, CUSTOMERS b
WHERE a.SALARY < b.SALARY;

NESTED SUBQUERY

Select * from RESULT where rollnumber in(Select rollnumber from student where courseid=(select courseId from student where rollno=12)

Hadoop Installation

Steps to install and work on hadoop

1. Please download virtual box or vmware on your machine .

2.Then download corresponding vm image from cloudera website

https://ccp.cloudera.com/display/SUPPORT/Cloudera+QuickStart+VM

Please note to download appropriate vm image according to the vm emulator installed on your machine.

You have eclipse installed on the machine along with hadoop configured .Enjoy..

Example screenshot for mac using oracle VM virtualBox Manager.Likewise you can do it on other machines as well.Image

 

Image

Hadoop–key terms glossary

  1. HDFS-Hadoop Distributed File System
  2. YARN-Yet another resource negotiator
  3. MRV1—-MRV2
  4. Block Size –>64Mb to 128mb
  5. Name Node(manages the filesystem namespace) and Datanode
  6. USually User->client->NameNode<->Datanode and we have total abstraction.
  7. Fault Tolerance and Fencing
  8. Disaster recovery
  9. One mechanism is to take backup regularly and the other is to have a secondary NameNode
  10. NameNode consists of the Block mappings to the dataNodes.
  11. DataNodes are the work horses.
  12. We have a edit log file and a filesystem image file which are key resources for backup purposes
  13. HDFS is not suitable when there are large number of small files,when there is requirement of Low latency and when there are multiple writes going on to the data concurrently.(This feature may be available in future but currently it doesn’t support this feature).
  14. We need to have a simple model for file system in order to work and having blocks as primary units is a good idea.
  15. hadoop fsck | -files -blocks
  16. The above command is called as hadoop filesystem check command similar to disc check in windows.

Convert from one base to another base


/**
 * @author Nikhilesh Reddy Chaduvula<ctillu.nikhil@gmail.com>
 * convert from base 10 to any other base
 */
 public class BaseConverter2 {

// Requirement is given a number convert it into any base smaller base or bigger base

/**
 * @param args
 */
 public static void main(String[] args) {

int numberToBeConverted = 123;

int baseToBeConverted = 12;

BaseConverter2 bc2 = new BaseConverter2();

String s = bc2.baseconvert(numberToBeConverted, baseToBeConverted, "");

System.out.println(s);
 }

public String baseconvert(int number, int base, String str) {
 if (number < base) {
 return getAbsolutechar(number) + str;
 }
 else {
 int remainder = number % base;
 number = number / base;
 return baseconvert(number, base, getAbsolutechar(remainder) + str);
 }
 }

private char getAbsolutechar(int number)throws ArrayIndexOutOfBoundsException {
 String str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 return str.charAt(number);
 }

}