博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Structure Streaming和spark streaming原生API访问HDFS文件数据对比
阅读量:4678 次
发布时间:2019-06-09

本文共 1191 字,大约阅读时间需要 3 分钟。

此文已由作者岳猛授权网易云社区发布。

欢迎访问,了解更多网易技术产品运营经验。

Structure Stream访问方式

code examples

import org.apache.spark.sql.streaming._val df = spark.readStream.text("/home/testhdfs")val ps = df.writeStream.format("console").outputMode(OutputMode.Append).start

结论

basedir = /home/testhdfs

支持:mv file to basedir(/home/testhdfs)
不支持:mv directory to basedir

如果往basedir里面添加文件夹会出现ERROR:

java.lang.AssertionError: assertion failed: Conflicting directory structures detected. Suspicious paths:        hdfs://172.17.1.180:9000/home/testhdfs/data1        hdfs://172.17.1.180:9000/home/testhdfsIf provided paths are partition directories, please set "basePath" in the options of the data source to specify the root directory of the table. If there are multiple root directories, please load them separately and then union them.

spark streaming 访问方式

测试textFile接口使用

import org.apache.spark.streaming._val ssc = StreamingContext.getActiveOrCreate(() => new StreamingContext(sc,                  Seconds(120)))val ds1 = ssc.textFileStream("/home/testhdfs2")ds1.printssc.start

结论

支持:mv file to basedir(/home/testhdfs2)

支持:mv directory to basedir

链接:

更多网易技术、产品、运营经验分享请。

相关文章:

【推荐】 

转载于:https://www.cnblogs.com/zyfd/p/9882496.html

你可能感兴趣的文章
中缀转后缀 java_Java 利用堆栈将中缀表达式转换成后缀
查看>>
java执行sql解析_java执行SQL语句实现查询的通用方法详解
查看>>
java中keepalived开启方式_高可用之KeepAlived(一):基本概念和配置文件分析
查看>>
java中的ejb_JAVA语言中关于EJB技术概论
查看>>
java有date类型吗_关于java中date类型的问题
查看>>
java中svg图片怎么用_svg如何使用
查看>>
java dart 官司_From Java to Dart
查看>>
java ftp 读取excel_从Excel文件读取数据表
查看>>
oracle 有哪些字典表,oracle 常用字典表
查看>>
linux c多进程多线程,linux下的C\C++多进程多线程编程简易例子
查看>>
linux 命令 考试,linux常用命令总结-第一次考试
查看>>
linux动态库编译多重依赖,Linux动态库多重依赖
查看>>
linux网卡缓冲区设置,【Linux】tcp缓冲区大小的默认值、最大值
查看>>
opus编译linux,Linux 下源码编译FFMEG
查看>>
linux 运行real basic,REALbasic 快速入门.pdf
查看>>
linux启动tomcat不停的触发gc,tomcat启动时就频繁gc和full gc
查看>>
linux uart串口驱动,X-017-KERNEL-串口驱动开发之uart driver框架
查看>>
linux 添加串口数量,如何在Linux中添加4个以上的串口设备?
查看>>
关于sqoop导入数据的时候添加--split-by配置项对sqoop的导入速度的影响。
查看>>
nginx配置
查看>>