当前位置:网站首页>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.
边栏推荐
- This time, thoroughly understand the deep copy
- Get the relevant information of ID card through PHP, get the zodiac, get the constellation, get the age, and get the gender
- Comments on flowable source code (XXXV) timer activation process definition processor, process instance migration job processor
- [flask] response, session and message flashing
- 国家级非遗传承人高清旺《四大美人》皮影数字藏品惊艳亮相!
- 【Flask】官方教程(Tutorial)-part1:项目布局、应用程序设置、定义和访问数据库
- Leetcode3. Implement strstr()
- Jisuanke - t2063_ Missile interception
- Computer graduation design PHP animation information website
- 2 power view
猜你喜欢

【Flask】官方教程(Tutorial)-part1:项目布局、应用程序设置、定义和访问数据库

Accelerating spark data access with alluxio in kubernetes

How to improve the level of pinduoduo store? Dianyingtong came to tell you

Alibaba canal usage details (pit draining version)_ MySQL and ES data synchronization

Computer graduation design PHP college student human resources job recruitment network
![[depth first search] Ji Suan Ke: Betsy's trip](/img/b5/f24eb28cf5fa4dcfe9af14e7187a88.jpg)
[depth first search] Ji Suan Ke: Betsy's trip

C web page open WinForm exe

Computer graduation design PHP campus restaurant online ordering system

Unity learning notes -- 2D one-way platform production method

Leetcode skimming questions_ Invert vowels in a string
随机推荐
Redis daemon cannot stop the solution
Competition question 2022-6-26
Regular expressions: examples (1)
干货!通过软硬件协同设计加速稀疏神经网络
How to improve the level of pinduoduo store? Dianyingtong came to tell you
Derivation of Biot Savart law in College Physics
Leetcode skimming questions_ Invert vowels in a string
leetcode-2. Palindrome judgment
[flask] static file and template rendering
GBase 8c数据库升级报错
Basic operations of database and table ----- set the fields of the table to be automatically added
【Flask】响应、session与Message Flashing
module ‘tensorflow. contrib. data‘ has no attribute ‘dataset
Grabbing and sorting out external articles -- status bar [4]
Selenium element positioning (2)
Flowable source code comments (36) process instance migration status job processor, BPMN history cleanup job processor, external worker task completion job processor
Alibaba canal usage details (pit draining version)_ MySQL and ES data synchronization
【clickhouse】ClickHouse Practice in EOI
Computer graduation design PHP campus restaurant online ordering system
2022 PMP project management examination agile knowledge points (8)