当前位置:网站首页>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
边栏推荐
猜你喜欢

“蔚来杯“2022牛客暑期多校训练营4,签到题NDKHL

新产品立大功 伟世通第二季度营收双增

敏捷、DevOps和嵌入式系统测试

责任链模式(Chain Of Responsibility)

概率论与数理统计

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上传二进制文件、对象、对象数组

海缆探测仪TSS350(二)

【故障诊断分析】基于matlab FFT轴承故障诊断(包络谱)【含Matlab源码 2002期】

Splunk Field Caculated 计算字段
随机推荐
深度学习网络模型的改进与调整
【CV】OpenVINO安装教程
LeetCode 2360. The longest cycle in a graph
神经元网络
MySQL-多版本并发控制
OC-Category
SimpleChannelInboundHandler使用总结
【机器学习】实验2布置:基于回归分析的大学综合得分预测
Go implements distributed locks
Neural network
spark读取文件夹数据
mysql操作入门(四)-----数据排序(升序、降序、多字段排序)
WebGPU 导入[2] - 核心概念与重要机制解读
倍福使用AdsRemote组件实现和C#的ADS通讯
apt & apt-get命令
获取间隔的日期列表工具类
MySQL-锁机制
【云原生】如何快速部署Kubernetes
Modify apt-get source to domestic mirror source
mysql 注入