13 Refer the input and identify the output if the below code is run

0 votes
public static void main(String[] args){

SparkConf conf = new SparkConf().setAppName("org.sparkexample.sampleCode").setMaster("local");

JavaSparkContext sc = new JavaSparkContext(conf);

JavaRDD lines = sc.textFile("C:\\User\\Ritu\\sampledata");

JavaPairRDD lineLengths = lines.map(s -> s.split(";",-1)).filter(s->!s[0].equals("1")).mapToPair(s->new Tuple2(s[0],s[0]+";"+s[1]+";"+s[2]));

JavaPairRDD counts = lineLengths.reduceByKey((a,b)->a+b);

Sytem.out.println(counts.collect());

Input

1;you man; 23

112;me man;23

112;me man;27

112;me man;29

12;suman;23

a)  []

b) [(112,112;you man;23112;you man;27112;you man;29)]

c)  Run time error - A

d)  [(112,112;you man;23112;you man;27112;you man;29),(12,12;suman;23)]
Nov 25, 2020 in Apache Spark by ritu
• 960 points
1,072 views

1 answer to this question.

0 votes

Option c)  Run time error - A

answered Nov 25, 2020 by Gitika
• 65,770 points

Related Questions In Apache Spark

0 votes
1 answer

2)What will be printed when the below code is executed ?

Hi, @Ritu, List(5,100,10) is printed. The take method returns the first n elements in ...READ MORE

answered Nov 23, 2020 in Apache Spark by Gitika
• 65,770 points
774 views
0 votes
1 answer

From the below code. what is the most appropriate next step in ML process?

Hi@ritu, The most appropriate step according to me ...READ MORE

answered Nov 25, 2020 in Apache Spark by MD
• 95,460 points
1,235 views
0 votes
1 answer

What is the output of the following code?

After executing your code, there is an ...READ MORE

answered Nov 25, 2020 in Apache Spark by Gitika
• 65,770 points
953 views
0 votes
0 answers

What is the output of the following code?

What is the output of the following ...READ MORE

Nov 25, 2020 in Apache Spark by Edureka
• 200 points

closed Nov 26, 2020 by MD 775 views
0 votes
1 answer

What is the output of the following code?

rror: expected class or object definition sc.parallelize(Array(1L,("SFO")),(2L,("ORD")),(3L,("DFW")))) ^ one error ...READ MORE

answered Nov 26, 2020 in Apache Spark by Gitika
• 65,770 points
885 views
0 votes
1 answer

What will be printed when the below code is executed ?

Option a) List(5,100,10) The take method returns the first n elements in an ...READ MORE

answered Nov 26, 2020 in Apache Spark by Gitika
• 65,770 points
1,458 views
0 votes
1 answer

What will be printed when the below code is executed?

Option D)  runtime error READ MORE

answered Nov 26, 2020 in Apache Spark by Gitika
• 65,770 points
2,399 views
0 votes
1 answer

Is it possible to run Spark and Mesos along with Hadoop?

Yes, it is possible to run Spark ...READ MORE

answered May 29, 2018 in Apache Spark by Data_Nerd
• 2,390 points
824 views
0 votes
1 answer

How the if-else statement is different for Scala and Java?

Hey, There is one main difference. This statement ...READ MORE

answered Jul 29, 2019 in Apache Spark by Gitika
• 65,770 points
1,038 views
–2 votes
1 answer

What is the difference in Java’s “If..Else” and Scala’s “If..Else”?

Hey, Java’s “If. Else”: In Java, “If. Else” is a statement, ...READ MORE

answered Jul 31, 2019 in Apache Spark by Gitika
• 65,770 points
1,963 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP