CARVIEW |
Select Language
HTTP/2 200
date: Sun, 12 Oct 2025 00:30:57 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=687af70222b5cfe1dc8b9755ec82637064ac1a068e1f4351f09e26cc411d1afca%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22sIfASUgkVbB8oLCszw1rrCQa1o5TpnHg%22%3B%7D; HttpOnly; Path=/
cf-ray: 98d27dd5bf95b9d7-BLR
import org.apache.spark.{SparkConf, SparkContext}object GradeAnalysis { d - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.apache.spark.{SparkConf, SparkContext}
- object GradeAnalysis {
- def main(args: Array[String]): Unit = {
- val conf = new SparkConf().setAppName("Grade Analysis").setMaster("local")
- val sc = new SparkContext(conf)
- // 读取成绩文件
- val hadoopGrades = sc.textFile("grade/Hadoop.txt")
- val sparkGrades = sc.textFile("grade/Spark.txt")
- // 解析文件内容
- val hadoopScores = hadoopGrades.map(line => {
- val parts = line.split(" ")
- (parts(0), parts(1).toInt)
- })
- val sparkScores = sparkGrades.map(line => {
- val parts = line.split(" ")
- (parts(0), parts(1).toInt)
- })
- // 合并两个RDD
- val allScores = hadoopScores.union(sparkScores)
- // 计算每名学生的总成绩和次数
- val studentScores = allScores.map {
- case (student, score) => (student, (score, 1))
- }
- val totalScores = studentScores.reduceByKey {
- case ((score1, count1), (score2, count2)) => (score1 + score2, count1 + count2)
- }
- // 计算平均成绩
- val averageScores = totalScores.map {
- case (student, (totalScore, count)) => (student, totalScore.toDouble / count)
- }
- // 输出每名学生的平均成绩
- println("Average Scores:")
- averageScores.collect().foreach {
- case (student, avgScore) => println(s"$student: $avgScore")
- }
- sc.stop()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 3 sec ago | 0.25 KB
-
📝 Crypto Swap Glitch ✅ Working
JavaScript | 4 sec ago | 0.24 KB
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 5 sec ago | 0.25 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ E
JavaScript | 12 sec ago | 0.25 KB
-
📝 EASY MONEY GUIDE ✅ Working
JavaScript | 13 sec ago | 0.24 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ S
JavaScript | 14 sec ago | 0.25 KB
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ 3
JavaScript | 21 sec ago | 0.25 KB
-
📌 ChangeNOW Exploit
JavaScript | 22 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand