4-31Data Sinks
发布日期:2021-07-01 02:23:20
浏览次数:3
分类:技术文章
本文共 1529 字,大约阅读时间需要 5 分钟。
Data sinks consume DataSets and are used to store or return them. Data sink operations are described using an . Flink comes with a variety of built-in output formats that are encapsulated behind operations on the DataSet:
writeAsText()
/TextOutputFormat
- Writes elements line-wise as Strings. The Strings are obtained by calling the toString() method of each element.writeAsCsv(...)
/CsvOutputFormat
- Writes tuples as comma-separated value files. Row and field delimiters are configurable. The value for each field comes from the toString() method of the objects.print()
/printToErr()
- Prints the toString() value of each element on the standard out / standard error stream.write()
/FileOutputFormat
- Method and base class for custom file outputs. Supports custom object-to-bytes conversion.output()
/OutputFormat
- Most generic output method, for data sinks that are not file based (such as storing the result in a database).
A DataSet can be input to multiple operations. Programs can write or print a data set and at the same time run additional transformations on them.
object DataSetSinkApp { def main(args: Array[String]): Unit = { val env = ExecutionEnvironment.getExecutionEnvironment import org.apache.flink.api.scala._ val data = 1.to(10) val text = env.fromCollection(data) val filePath="file:///F://data/" //此处设置并行度,如果并行度为1,那么输出的就是一个文件而不是一个文件夹。此处并行度为2,那么就会生成一个data文件夹,文件夹内有两个文件,1和2 text.writeAsText(filePath,WriteMode.OVERWRITE).setParallelism(2) env.execute("DataSetSinkApp") }}
转载地址:https://mapengsen.blog.csdn.net/article/details/108876023 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
不错!
[***.144.177.141]2024年05月04日 18时56分45秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Mysql 1071报错解决
2019-05-02
操作系统(5)
2019-05-02
操作系统(6)
2019-05-02
操作系统(7)
2019-05-02
eclipse将Java项目配置为maven项目
2019-05-02
操作系统(8)
2019-05-02
操作系统(9)
2019-05-02
Android Studio重装
2019-05-02
Android的最小权限原则
2019-05-02
Android四大组件
2019-05-02
操作系统(11)
2019-05-02
数据库复习(2)
2019-05-02
数据库复习(3)
2019-05-02
数据库复习(4)
2019-05-02
C# TextBox输入密码显示星号(*)
2019-05-02
C#如何将文件资源添加到resource下
2019-05-02
Android活动的生命周期
2019-05-02
阿里Java首席架构师都在看的“MyBatis源码解析文档”你看过吗?
2019-05-02