当前位置:网站首页>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.
边栏推荐
- Shutter doctor: Xcode installation is incomplete
- Know MySQL database
- 正则表达式:示例(1)
- Computer graduation design PHP college classroom application management system
- 02. Go language development environment configuration
- Maya hollowed out modeling
- leetcode3、實現 strStr()
- Online reservation system of sports venues based on PHP
- Extracting key information from TrueType font files
- 【clickhouse】ClickHouse Practice in EOI
猜你喜欢

Computer graduation design PHP part-time recruitment management system for College Students

Know MySQL database

使用npm发布自己开发的工具包笔记

2022 PMP project management examination agile knowledge points (8)

Leetcode skimming questions_ Verify palindrome string II

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

TrueType字体文件提取关键信息
![Grabbing and sorting out external articles -- status bar [4]](/img/1e/2d44f36339ac796618cd571aca5556.png)
Grabbing and sorting out external articles -- status bar [4]

SPI communication protocol

National intangible cultural heritage inheritor HD Wang's shadow digital collection of "Four Beauties" made an amazing debut!
随机推荐
FTP server, ssh server (super brief)
Ali test Open face test
Redis如何实现多可用区?
Redis string type
NLP fourth paradigm: overview of prompt [pre train, prompt, predict] [Liu Pengfei]
Maya hollowed out modeling
MySQL index
【Flask】官方教程(Tutorial)-part2:蓝图-视图、模板、静态文件
Flutter Doctor:Xcode 安装不完整
leetcode-两数之和
Concept of storage engine
I like Takeshi Kitano's words very much: although it's hard, I will still choose that kind of hot life
Paddle框架:PaddleNLP概述【飛槳自然語言處理開發庫】
leetcode-2.回文判断
阿里测开面试题
Basic operations of databases and tables ----- primary key constraints
竞赛题 2022-6-26
C web page open WinForm exe
selenium 等待方式
How to improve the level of pinduoduo store? Dianyingtong came to tell you