Huawei H13-723_V2.0 Exam - Topic 1 Question 17 Discussion
There are the following business scenarios: User online log files have been stored inHDFSabove, the log file content format the formula is: each online record has three fields, namely name, gender, and online time, and the fields are separated by ",";It is required to print out all female netizens who spend more than two hours online. Which of the following code snippets can achieveThe above business scenario? (multiple choice)
A) sc.textFile('/data/file/path'').map(.split(',')).map(p=>FemaleInfo(p
(O),p(1),p(2).trim.toInt)).toDF.registerTemp Table('FemaleinfoTable'')sqlContext.sql
('select name,sum(stay Time)as stay Time from FemaleInfoTable where gender=
female'group by name'').filter('stay Time >=120'').collect).foreach(printin) and C) val text=sc.textFile('/data/fle/path')
val data=text.filter(_.contains('female'))
Val fermaleData:RDD(String,Int) =data.map{line=>val t=line.split(',')
(t(0),t(2).toInt)
}.reduceByKey(_+_)
Val result=femaleData.filter(line=>line.2>120)
Rusult.collect.map(x=>x._1 + ',' + x._2).foreach(println) and D) val text=sc.textFile('/data/fle/path'')
val data=text.filter(_.contains('female''))
Val fermaleData:RDD(String,Int) =data.map(line=>val t=line.split(',')
(t(0),t(2).toInt)
}
Val result=femaleData.filter(line=>line.2>120)
Rusult.collect.map(x=>x._1 +','+ x._2).foreach(println)
B) sc.textFile('/data/file/path').map(.split(',')).map(p=>FemaleInfo
(p(O),p(1),p(2).trim.toInt)).toDF.registerTemp Table('Female infoTable')
sqlContext.sq(l 'select name, sum(stay Time)as stay Time from FemaleInfoTable where
gender=female).filter(''stay Time >=120'').collect).foreach(printin)
Arlette
9 months agoCassie
9 months agoBoris
9 months agoWhitley
9 months agoViki
9 months agoAugustine
10 months agoKina
10 months agoAleisha
10 months agoWilda
10 months agoStefanie
10 months agoIra
10 months agoJuliana
10 months agoZena
10 months agoFlorinda
10 months agoTwana
10 months agoHelaine
1 year agoBilli
1 year agoKeneth
1 year agoKanisha
1 year agoTimothy
1 year agoGlendora
1 year agoGlendora
1 year agoSabrina
1 year agoMica
1 year agoJohnna
1 year agoTy
1 year agoLashaunda
1 year agoAlysa
1 year agoMitsue
1 year agoTasia
1 year agoMicah
1 year agoCharlette
1 year ago