当前位置:网站首页>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.
边栏推荐
- UE4 unreal engine, editor basic application, usage skills (IV)
- Folio. Ink is a free, fast and easy-to-use image sharing tool
- Unity learning notes -- 2D one-way platform production method
- leetcode3、實現 strStr()
- Reasonable and sensible
- 国家级非遗传承人高清旺《四大美人》皮影数字藏品惊艳亮相!
- Using SA token to solve websocket handshake authentication
- leetcode-2. Palindrome judgment
- [depth first search] Ji Suan Ke: Betsy's trip
- I like Takeshi Kitano's words very much: although it's hard, I will still choose that kind of hot life
猜你喜欢
[technology development -28]: overview of information and communication network, new technology forms, high-quality development of information and communication industry
PHP campus financial management system for computer graduation design
Maya hollowed out modeling
How does redis implement multiple zones?
National intangible cultural heritage inheritor HD Wang's shadow digital collection of "Four Beauties" made an amazing debut!
[solution] every time idea starts, it will build project
Leetcode3, implémenter strstr ()
Leetcode3. Implement strstr()
[flask] official tutorial -part1: project layout, application settings, definition and database access
Basic operations of database and table ----- set the fields of the table to be automatically added
随机推荐
[solution] every time idea starts, it will build project
FTP server, ssh server (super brief)
Publish your own toolkit notes using NPM
Executing two identical SQL statements in the same sqlsession will result in different total numbers
剑指 Offer 12. 矩阵中的路径
Redis string type
抓包整理外篇——————状态栏[ 四]
A Cooperative Approach to Particle Swarm Optimization
Visualstudio2019 compilation configuration lastools-v2.0.0 under win10 system
Basic operations of databases and tables ----- default constraints
国家级非遗传承人高清旺《四大美人》皮影数字藏品惊艳亮相!
Virtual machine network, networking settings, interconnection with host computer, network configuration
UE4 unreal engine, editor basic application, usage skills (IV)
[network attack and defense training exercises]
Cookie concept, basic use, principle, details and Chinese transmission
Concept of storage engine
Grabbing and sorting out external articles -- status bar [4]
D22:indeterminate equation (indefinite equation, translation + problem solution)
Bidding promotion process
How to use C to copy files on UNIX- How can I copy a file on Unix using C?