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 24, 2020 in Apache Spark by ritu
• 980 points
77 views

1 answer to this question.

0 votes

Option c)  Run time error - A

answered Nov 25, 2020 by Gitika
• 65,870 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,870 points
86 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,160 points
82 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,870 points
90 views
0 votes
0 answers

What is the output of the following code?

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

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

closed Nov 25, 2020 by MD 61 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,870 points
81 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,870 points
74 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,870 points
201 views
0 votes
1 answer

What will be printed when the below code is executed?

Option b) .List(0,3,5) The takeOrdered method returns the smallest n elements in a ...READ MORE

answered Nov 26, 2020 in Apache Spark by Gitika
• 65,870 points
146 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,870 points
153 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,870 points
453 views