当前位置:网站首页>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

边栏推荐
- 记一次有趣的逻辑SRC挖掘
- Jincang database kingbasees plug-in force_ view
- 金仓数据库 KingbaseES 插件DBMS_UTILITY
- Design and implementation of university laboratory goods management information system based on SSH
- Comparable的使用(用于Arrays.sort)
- Spannable and editable, spannablestring and spannablestring
- Detailed explanation of Spark's support source code for Yan priority
- 一个数学难题,难倒两位数学家
- try-catch-finally
- Use of three-level linkage plug-ins selected by provinces and cities
猜你喜欢

Double buffer transparent encryption and decryption driven course paper + project source code based on minifilter framework

Jincang KFS data cascade scenario deployment

牛客网:主持人调度

Shichuang Energy sprint Technology Innovation Board: le chiffre d'affaires annuel prévu de 1,1 milliard de RMB est de 0,7 milliard de RMB, en baisse de 36%

SQL注入漏洞(类型篇)

ZABBIX distributed system monitoring

FPGA displays characters and pictures based on VGA

记一次给OpenHarmony提交代码的过程

中國信通院沈瀅:字體開源協議——OFL V1.1介紹及合規要點分析

Ladder Side-Tuning:预训练模型的“过墙梯”
随机推荐
Vulnérabilité à l'injection SQL (contournement)
Coscon'22 lecturer solicitation order
Arrays.asList()
An interesting logic SRC mining
Daily 3 questions (2) - find out the lucky numbers in the array
Database Series: MySQL index optimization summary (comprehensive version)
Hangzhou / Beijing neitui Ali Dharma academy recruits academic interns in visual generation (talent plan)
仿真与烧录程序有哪几种方式?(包含常用工具与使用方式)
Kingbasees plug-in ftutilx of Jincang database
贝叶斯
Introduction to JVM principle
SystemVerilog(十三)-枚举数据类型
金仓KFS数据级联场景部署
Big Endian 和 Little Endian
Spark history server and event log details
Golden sun education listed in the U.S.: a small cap medium cap stock with a market value of USD 360million
At 16:00 today, Mr. sunxiaoming, a researcher of the Institute of computing, Chinese Academy of Sciences, took you into the quantum world
ARM64特有一些的汇编指令
Causes and solutions of over fitting
Kingbasees plug-in DBMS of Jincang database_ session
https://zhangvalue.blog.csdn.net/article/details/122501292