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
7 months agoCassie
7 months agoBoris
8 months agoWhitley
8 months agoViki
8 months agoAugustine
8 months agoKina
8 months agoAleisha
8 months agoWilda
8 months agoStefanie
8 months agoIra
8 months agoJuliana
9 months agoZena
9 months agoFlorinda
9 months agoTwana
9 months agoHelaine
1 year agoBilli
12 months agoKeneth
12 months agoKanisha
12 months 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