当前位置:网站首页>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.
边栏推荐
- [depth first search] Ji Suan Ke: Betsy's trip
- [flask] official tutorial -part2: Blueprint - view, template, static file
- C web page open WinForm exe
- [Clickhouse] Clickhouse based massive data interactive OLAP analysis scenario practice
- [solution] every time idea starts, it will build project
- 02. Go language development environment configuration
- Leetcode skimming questions_ Invert vowels in a string
- Extracting key information from TrueType font files
- Computer graduation design PHP enterprise staff training management system
- [flask] obtain request information, redirect and error handling
猜你喜欢

Accelerating spark data access with alluxio in kubernetes

PHP campus movie website system for computer graduation design

国家级非遗传承人高清旺《四大美人》皮影数字藏品惊艳亮相!
![[solved] how to generate a beautiful static document description page](/img/c1/6ad935c1906208d81facb16390448e.png)
[solved] how to generate a beautiful static document description page

PHP campus financial management system for computer graduation design
![Grabbing and sorting out external articles -- status bar [4]](/img/1e/2d44f36339ac796618cd571aca5556.png)
Grabbing and sorting out external articles -- status bar [4]

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

A Cooperative Approach to Particle Swarm Optimization
![[detailed] several ways to quickly realize object mapping](/img/e5/70c7f8fee4556d14f969fe33938971.gif)
[detailed] several ways to quickly realize object mapping

同一个 SqlSession 中执行两条一模一样的SQL语句查询得到的 total 数量不一样
随机推荐
leetcode-两数之和
2022 PMP project management examination agile knowledge points (8)
Basic operations of database and table ----- delete data table
Redis守护进程无法停止解决方案
干货!通过软硬件协同设计加速稀疏神经网络
1. Introduction to basic functions of power query
How to upgrade kubernetes in place
Text editing VIM operation, file upload
[width first search] Ji Suan Ke: Suan tou Jun goes home (BFS with conditions)
安装Redis
A Cooperative Approach to Particle Swarm Optimization
Unity learning notes -- 2D one-way platform production method
NiO related knowledge (II)
安装php-zbarcode扩展时报错,不知道有没有哪位大神帮我解决一下呀 php 环境用的7.3
How does redis implement multiple zones?
Jisuanke - t2063_ Missile interception
[solved] how to generate a beautiful static document description page
Basic operations of databases and tables ----- unique constraints
I like Takeshi Kitano's words very much: although it's hard, I will still choose that kind of hot life
VIM usage guide