当前位置:网站首页>Spark runs wordcount (case 2)
Spark runs wordcount (case 2)
2022-06-25 11:29:00 【zhangvalue】
Spark function WordCount( Case 2 )
Specific details refer to Spark function WordCount( Case a ):
And preliminary preparations :
import org.apache.spark.{SparkConf, SparkContext}
/**
* Count the number of characters
*/
object WorkCount {
def main(args: Array[String]) {
if (args.length < 1) {
System.err.println("Usage: <file>")
System.exit(1)
}
val conf = new SparkConf()
val sc = new SparkContext(conf)
//SparkContext It is to submit the code to the cluster or local channel , We write Spark Code , Whether you want to run a local or cluster, you must have SparkContext Example .
val line = sc.textFile(args(0))
// Save the read content to line Variable , Actually line It's a MappedRDD,Spark Code for , It's all based on RDD Operation of the ;
line.flatMap(_.split("")).map((_, 1)).reduceByKey(_+_).collect.foreach(println)
sc.stop
}
}
#!/bin/bash
cd $SPARK_HOME/bin
spark-submit \
--master spark://localhost:7077 \
--class WorkCount \
--name WorkCount \
--executor-memory 2048M \
--driver-memory 3096M \
/Users/zhangsf/bigdata/myjar/wordcount.jar \
hdfs://localhost:9000/zhangvalue/input/poet.txt
边栏推荐
- Niuke.com: Candy distribution
- Bayes
- Use of three-level linkage plug-ins selected by provinces and cities
- What are the functions of arm64 assembly that need attention?
- 牛客网:主持人调度
- 金仓数据库 KingbaseES 插件ftutilx
- Comparator(用于Arrays.sort)
- Shen Ying, China Academy of communications and communications: font open source protocol -- Introduction to ofl v1.1 and analysis of key points of compliance
- Course paper + code and executable EXE file of library information management system based on C language
- 金仓数据库 KingbaseES 插件dbms_session
猜你喜欢
Spark history server performance improvement (I) -- Application List
Ladder Side-Tuning:预训练模型的“过墙梯”
中國信通院沈瀅:字體開源協議——OFL V1.1介紹及合規要點分析
数据库系列:MySQL索引优化总结(综合版)
Leetcode 1249. Remove invalid brackets (awesome, finally made)
一个数学难题,难倒两位数学家
Niuke.com: host scheduling
An interesting logic SRC mining
A difficult mathematical problem baffles two mathematicians
Niuke.com: Candy distribution
随机推荐
Use of three-level linkage plug-ins selected by provinces and cities
Jincang database kingbasees plug-in identity_ pwdexp
SQL injection vulnerability (bypass)
10.1. Oracle constraint deferred, not deferred, initially deferred and initially deferred
子类A继承父类B, A a = new A(); 则父类B构造函数、父类B静态代码块、父类B非静态代码块、子类A构造函数、子类A静态代码块、子类A非静态代码块 执行的先后顺序是?
Kingbasees plug-in DBMS of Jincang database_ UTILITY
基于C语言的图书信息管理系统 课程论文+代码及可执行exe文件
PHP如何提取字符串中的图片地址
Spark Tuning common configuration parameters
GaussDB 如何统计用户sql的响应时间
金仓数据库 KingbaseES 插件dbms_session
CMU提出NLP新范式—重构预训练,高考英语交出134高分
Redis6笔记02 配置文件,发布和订阅,新数据类型,Jedis操作
How gaussdb counts the response time of user SQL
Big Endian 和 Little Endian
Coscon'22 lecturer solicitation order
SystemVerilog(十三)-枚举数据类型
Compilation of learning from Wang Shuang (1)
ARM64特有一些的汇编指令
Jincang database kingbasees plug-in force_ view