当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
张驰课堂:六西格玛测量系统的误差分析与判定
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
View port number occupancy
【杂】pip换国内源教程及国内源地址
OC-NSArray
实例029:反向输出
59:第五章:开发admin管理服务:12:MongoDB的使用场景;(非核心数据,数据量比较大的非核心数据,人脸照片等隐私的小文件;)
新产品立大功 伟世通第二季度营收双增
LeetCode Algorithm 1374. 生成每种字符都是奇数个的字符串
使用hutool做本地缓存的工具类
OC-NSNumber和NSValue一般用来装箱拆箱
MQ带来的一些问题、及解决方案
正则表达式
【机器学习】实验5布置:AAAI会议论文聚类分析
Splunk Field Caculated 计算字段
暑假第五周总结
【CNN回归预测】基于matlab卷积神经网络CNN数据回归预测【含Matlab源码 2003期】
OC-NSNumber and NSValue are generally used for boxing and unboxing
实例028:递归求等差数列
LeetCode 283. 移动零(简单、数组)








