当前位置:网站首页>spark read local file
spark read local file
2022-08-02 07:50:00 【this is a book】
1 Background
Based on spark development program
The data is placed in a local file in text format
The language case of this article is java
2 steps
2.1 Construction Project
build a spark project based on maven _this is a book blog-CSDN blog
2.2 Code Example
SparkConf conf = new SparkConf().setAppName("demo").setMaster("local[*]");SparkSession sparkSession = SparkSession.builder().config(conf).getOrCreate();JavaSparkContext javaSparkContext = new JavaSparkContext(sparkSession.sparkContext());JavaRDD rdd = javaSparkContext.textFile(INPUT_PATH);rdd.foreach(new VoidFunction() {@Overridepublic void call(String s) throws Exception {System.out.println(s);}}); 3 Notes
If it is placed on a linux server and running on spark, the file path needs to be prefixed with this
file:///data/demo.textThe reason is that spark is generally used in combination with hdms, and a prefix needs to be added to read a local file to indicate that a local file is read
边栏推荐
猜你喜欢

Chain Of Responsibility

PWA 踩坑 - 第一次加载页面后无法获取CacheStorage某些资源

反射课后习题及做题记录

Enterprise training and reproduction guidebook - training and reasoning of the OpenPose model based on Huawei ModelArts platform, realizing the recognition of two behaviors of climbing and climbing ov

深度学习网络模型的改进与调整

FormData upload binary file, object, object array

吃透Chisel语言.31.Chisel进阶之通信状态机(三)——Ready-Valid接口:定义、时序和Chisel中的实现

Agile, DevOps and Embedded Systems Testing

论文阅读 (64):Weakly-supervised Video Anomaly Detection with Robust Temporal Feature Magnitude Learning

Mysql报错2003 解决办法 Can‘t connect to MySQL server on ‘localhost‘ (10061)
随机推荐
ADS通信--倍福PLC和C#TextBox控件实现数据绑定的方法
View port number occupancy
OC-NSString
有趣的网站
实例030:回文数
PWA 踩坑 - 第一次加载页面后无法获取CacheStorage某些资源
Enterprise training and reproduction guidebook - training and reasoning of the OpenPose model based on Huawei ModelArts platform, realizing the recognition of two behaviors of climbing and climbing ov
Xilinx约束学习笔记—— 时序约束
MySQL-FlinkCDC-Hudi enters the lake in real time
apt & apt-get命令
2022年数据泄露平均成本高达435万美元,创历史新高!
MySQL-索引优化和查询优化
【机器学习】课程设计布置:某闯关类手游用户流失预测
Facebook社媒营销的5大技巧,迅速提高独立站转化率!
根据一个字段的内容去更新另一个字段的数据,这样的sql语句该怎么样书写
LeetCode SQL 197. 上升的温度
LeetCode Algorithm 1374. 生成每种字符都是奇数个的字符串
封装class类一次性解决全屏问题
【云原生】如何快速部署Kubernetes
条件构造器~wapper