Skip to content

Instantly share code, notes, and snippets.

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 \
val a = 5
var res = 1
for(e <- a to 2 by -1)
res = res * e
println("Factorial of " + a + " is " + res)
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
def fact(i: Int) = {
var res = 1
for(e <- i to 1 by -1)
res = res * e
res
}
def factr(i: Int): Int = if(i==1) 1 else i * factr(i-1)
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)
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))
}
/**
* 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
package retail
/**
* Created by itversity on 07/05/17.
*/
class Department(
departmentId: Int,
departmentName: String
) {
override def toString() = "Department(" +
package retail
/**
* Created by itversity on 08/05/17.
*/
case class Department(
departmentId: Int,
departmentName: String
)