This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sqoop list-databases \ | |
| --connect "jdbc:mysql://nn01.itversity.com:3306" \ | |
| --username retail_dba \ | |
| --password itversity | |
| #Make sure there is no directory specified in target-dir | |
| #Also make sure you replace dgadiraju with appropriate user name | |
| #For Cloudera or Hortonworks based VM environments you can change nn01.itversity.com | |
| #to appropriate host names or localhost | |
| sqoop import \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val a = 5 | |
| var res = 1 | |
| for(e <- a to 2 by -1) | |
| res = res * e | |
| println("Factorial of " + a + " is " + res) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val a = 10 | |
| var pre = 0 | |
| var curr = 1 | |
| println(pre) | |
| println(curr) | |
| var res = 0 | |
| for(e <- 2 to a - 1) { | |
| res = pre + curr | |
| println(res) | |
| pre = curr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fact(i: Int) = { | |
| var res = 1 | |
| for(e <- i to 1 by -1) | |
| res = res * e | |
| res | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def factr(i: Int): Int = if(i==1) 1 else i * factr(i-1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fibo(i: Int) = { | |
| var pre = 0 | |
| var curr = 1 | |
| var res = 0 | |
| print(pre + "\t" + curr) | |
| for(e <- 2 to i - 1) { | |
| res = pre + curr | |
| pre = curr | |
| curr = res | |
| print("\t" + res) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fact(i: Int) = { | |
| var res = 1 | |
| for(e <- i to 1 by -1) | |
| res = res * e | |
| res | |
| } | |
| def nCr(n: Int, r: Int) = { | |
| fact(n)/(fact(n-r) * fact(r)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Created by itversity on 07/05/17. | |
| */ | |
| object combination { | |
| def nCr(n: Int, r: Int) = { | |
| def fact(i: Int) = { | |
| var res = 1 | |
| for(e <- i to 1 by -1) | |
| res = res * e | |
| res |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package retail | |
| /** | |
| * Created by itversity on 07/05/17. | |
| */ | |
| class Department( | |
| departmentId: Int, | |
| departmentName: String | |
| ) { | |
| override def toString() = "Department(" + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package retail | |
| /** | |
| * Created by itversity on 08/05/17. | |
| */ | |
| case class Department( | |
| departmentId: Int, | |
| departmentName: String | |
| ) |