当前位置:网站首页>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.
边栏推荐
- 通过PHP 获取身份证相关信息 获取生肖,获取星座,获取年龄,获取性别
- 干货!通过软硬件协同设计加速稀疏神经网络
- 02. Go language development environment configuration
- [solved] how to generate a beautiful static document description page
- Accelerating spark data access with alluxio in kubernetes
- Win10 add file extension
- [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.
- SQL statement
- How to use C to copy files on UNIX- How can I copy a file on Unix using C?
- Get the relevant information of ID card through PHP, get the zodiac, get the constellation, get the age, and get the gender
猜你喜欢

Blue Bridge Cup embedded_ STM32 learning_ Key_ Explain in detail

Basic operations of databases and tables ----- non empty constraints

2 power view

Jisuanke - t2063_ Missile interception

Virtual machine network, networking settings, interconnection with host computer, network configuration

A basic lintcode MySQL database problem

Campus second-hand transaction based on wechat applet

Accelerating spark data access with alluxio in kubernetes

Force buckle 1020 Number of enclaves

02. Go language development environment configuration
随机推荐
Xshell 7 Student Edition
It's wrong to install PHP zbarcode extension. I don't know if any God can help me solve it. 7.3 for PHP environment
This time, thoroughly understand the deep copy
Grabbing and sorting out external articles -- status bar [4]
500 lines of code to understand the principle of mecached cache client driver
Alibaba canal usage details (pit draining version)_ MySQL and ES data synchronization
使用npm发布自己开发的工具包笔记
ClickOnce does not support request execution level 'requireAdministrator'
[ssrf-01] principle and utilization examples of server-side Request Forgery vulnerability
Regular expressions: examples (1)
2 power view
Redis key operation
剑指 Offer 38. 字符串的排列
Text editing VIM operation, file upload
NLP fourth paradigm: overview of prompt [pre train, prompt, predict] [Liu Pengfei]
[detailed] several ways to quickly realize object mapping
【Flask】官方教程(Tutorial)-part2:蓝图-视图、模板、静态文件
Flowable source code comments (36) process instance migration status job processor, BPMN history cleanup job processor, external worker task completion job processor
【clickhouse】ClickHouse Practice in EOI
C web page open WinForm exe