当前位置:网站首页>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.
边栏推荐
- Basic operations of databases and tables ----- primary key constraints
- Comments on flowable source code (XXXV) timer activation process definition processor, process instance migration job processor
- 02. Go language development environment configuration
- leetcode3、实现 strStr()
- [flask] official tutorial -part3: blog blueprint, project installability
- SPI communication protocol
- How to set an alias inside a bash shell script so that is it visible from the outside?
- 【Flask】静态文件与模板渲染
- 2022年PMP项目管理考试敏捷知识点(8)
- [Jiudu OJ 09] two points to find student information
猜你喜欢

Basic operations of databases and tables ----- default constraints

Redis string type

A Cooperative Approach to Particle Swarm Optimization

Jisuanke - t2063_ Missile interception

Numpy array index slice
![[solved] how to generate a beautiful static document description page](/img/c1/6ad935c1906208d81facb16390448e.png)
[solved] how to generate a beautiful static document description page
![[depth first search notes] Abstract DFS](/img/d4/0cfb5254b0c0d04b4400b4628637d5.jpg)
[depth first search notes] Abstract DFS

Computer graduation design PHP animation information website

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

selenium 等待方式
随机推荐
Know MySQL database
Apicloud openframe realizes the transfer and return of parameters to the previous page - basic improvement
Computer graduation design PHP animation information website
Leetcode skimming questions_ Invert vowels in a string
500 lines of code to understand the principle of mecached cache client driver
ClickOnce does not support request execution level 'requireAdministrator'
Gbase 8C database upgrade error
Folio. Ink is a free, fast and easy-to-use image sharing tool
MCU lightweight system core
【Flask】官方教程(Tutorial)-part1:项目布局、应用程序设置、定义和访问数据库
Sword finger offer 38 Arrangement of strings
GBase 8c数据库升级报错
PHP campus movie website system for computer graduation design
Basic operations of database and table ----- delete data table
Cadre du Paddle: aperçu du paddlelnp [bibliothèque de développement pour le traitement du langage naturel des rames volantes]
Poj2315 football games
NiO related knowledge (II)
[solution] every time idea starts, it will build project
阿裏測開面試題
[understanding of opportunity-39]: Guiguzi - Chapter 5 flying clamp - warning 2: there are six types of praise. Be careful to enjoy praise as fish enjoy bait.