当前位置:网站首页>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.text
The 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
边栏推荐
- 查看端口号占用
- apt & apt-get命令
- 查看僵尸进程
- WebGPU 导入[2] - 核心概念与重要机制解读
- OC-错误提示
- 2022.07.31(LC_6133_分组的最大数量)
- 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
- OC-error prompt
- 2022夏暑假每日一题(六)
- 【图像去噪】基于matlab双立方插值和稀疏表示图像去噪【含Matlab源码 2009期】
猜你喜欢
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
MySQL-索引优化和查询优化
实例029:反向输出
2022.07.31(LC_6133_分组的最大数量)
深度学习网络模型的改进与调整
【故障诊断分析】基于matlab FFT轴承故障诊断(包络谱)【含Matlab源码 2002期】
Splunk Filed extraction 字段截取
Chain Of Responsibility
MySQL-FlinkCDC-Hudi enters the lake in real time
根据一个字段的内容去更新另一个字段的数据,这样的sql语句该怎么样书写
随机推荐
【机器学习】实验6布置:基于集成学习的Amazon用户评论质量预测
MySQL-锁机制
Splunk Field Caculated Calculated Field
MySQL-索引优化和查询优化
regular expression
【机器学习】实验2布置:基于回归分析的大学综合得分预测
The best interests of buying and selling stocks with handling fees [What is missing in the definition of DP status?]
论文阅读 (64):Weakly-supervised Video Anomaly Detection with Robust Temporal Feature Magnitude Learning
暑假第五周总结
_2_顺序表
初探形式化方法基本原理
【机器学习】实验4布置:AAAI会议论文聚类分析
【故障诊断分析】基于matlab FFT轴承故障诊断(包络谱)【含Matlab源码 2002期】
企业实训复现指导手册——基于华为ModelArts平台的OpenPose模型的训练和推理、基于关键点数据实现对攀爬和翻越护栏两种行为的识别、并完成在图片中只标注发生行为的人
59:第五章:开发admin管理服务:12:MongoDB的使用场景;(非核心数据,数据量比较大的非核心数据,人脸照片等隐私的小文件;)
主流定时任务解决方案全横评
入门opencv,欢笑快乐每一天
【CNN回归预测】基于matlab卷积神经网络CNN数据回归预测【含Matlab源码 2003期】
正则表达式
SQL server 2014 怎么一次性导出多个查询结果?