当前位置:网站首页>RDD creation method of spark
RDD creation method of spark
2022-07-06 02:04:00 【Diligent ls】
stay Spark Created in RDD There are three ways to create : Create... From the collection RDD、 Create... From external storage RDD、 From the other RDD establish .
Creation time environment dependency
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.12</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
<build>
<finalName>SparkCoreTest</finalName>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.6</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>1. Create... From collection
object createrdd {
def main(args: Array[String]): Unit = {
val conf: SparkConf = new SparkConf()
.setAppName("SparkCoreTest")
.setMaster("local[*]")
val sc: SparkContext = new SparkContext(conf)
// Use parallelize() establish rdd
//val rdd: RDD[Int] = sc.parallelize(Array(1,2,3,4,5,6))
// rdd.collect().foreach(println)
// Use makeRDD() establish rdd
val rdd1: RDD[Int] = sc.makeRDD(Array(1,2,3,4,5,6))
rdd1.collect().foreach(println)
sc.stop()
}
}notes :makeRDD Not exactly equal to parallelize, In one of the refactoring methods ,makeRDD Added location information .
2. Create from a dataset of an external storage system
object crearedd2 {
def main(args: Array[String]): Unit = {
val conf: SparkConf = new SparkConf()
.setAppName("WC")
.setMaster("local[*]")
val sc: SparkContext = new SparkContext(conf)
val value: RDD[String] = sc.textFile("input")
value.foreach(println)
sc.stop()
}
}3. From the other RDD establish
Mainly through a RDD After the calculation , And create new RDD.
边栏推荐
- 阿里测开面试题
- selenium 元素定位(2)
- Get the relevant information of ID card through PHP, get the zodiac, get the constellation, get the age, and get the gender
- Luo Gu P1170 Bugs Bunny and Hunter
- Executing two identical SQL statements in the same sqlsession will result in different total numbers
- 【Flask】官方教程(Tutorial)-part3:blog蓝图、项目可安装化
- Using SA token to solve websocket handshake authentication
- Flowable source code comments (36) process instance migration status job processor, BPMN history cleanup job processor, external worker task completion job processor
- 正则表达式:示例(1)
- Cadre du Paddle: aperçu du paddlelnp [bibliothèque de développement pour le traitement du langage naturel des rames volantes]
猜你喜欢

Blue Bridge Cup embedded_ STM32_ New project file_ Explain in detail

500 lines of code to understand the principle of mecached cache client driver

How to upgrade kubernetes in place

Social networking website for college students based on computer graduation design PHP

2022年PMP项目管理考试敏捷知识点(8)

Redis-列表

National intangible cultural heritage inheritor HD Wang's shadow digital collection of "Four Beauties" made an amazing debut!

Extracting key information from TrueType font files

NLP第四范式:Prompt概述【Pre-train,Prompt(提示),Predict】【刘鹏飞】

Computer graduation design PHP animation information website
随机推荐
正则表达式:示例(1)
leetcode-2.回文判断
Win10 add file extension
Tensorflow customize the whole training process
[solution] add multiple directories in different parts of the same word document
[solved] how to generate a beautiful static document description page
Leetcode sum of two numbers
同一个 SqlSession 中执行两条一模一样的SQL语句查询得到的 total 数量不一样
ClickOnce does not support request execution level 'requireAdministrator'
NLP第四范式:Prompt概述【Pre-train,Prompt(提示),Predict】【刘鹏飞】
Open source | Ctrip ticket BDD UI testing framework flybirds
How to set an alias inside a bash shell script so that is it visible from the outside?
[ssrf-01] principle and utilization examples of server-side Request Forgery vulnerability
MySQL index
Thinking about the best practice of dynamics 365 development collaboration
500 lines of code to understand the principle of mecached cache client driver
Xshell 7 Student Edition
Dynamics 365 开发协作最佳实践思考
FTP server, ssh server (super brief)
安装php-zbarcode扩展时报错,不知道有没有哪位大神帮我解决一下呀 php 环境用的7.3