博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
flink1.3 scala实现processfunction的问题
阅读量:6225 次
发布时间:2019-06-21

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

hot3.png

代码

class TimeoutStateFunction extends ProcessFunction[ObjectNode, (String, Long)] {    lazy val state : ListState[CountWithTimestamp] = getRuntimeContext      .getListState(new ListStateDescriptor[CountWithTimestamp]("myState", classOf[CountWithTimestamp]))     override def processElement(value: ObjectNode, ctx: Context, out: Collector[(String, Long)]): Unit = {         //Stuff here     }     override def onTimer(timestamp: Long, ctx: OnTimerContext, out: Collector[(String, Long)]): Unit = {         //More Stuff here     }}

错误:

Error:(8, 7) class TimeoutStateFunction needs to be abstract, since method processElement in class ProcessFunction of type (x$1: com.fasterxml.jackson.databind.node.ObjectNode, x$2: org.apache.flink.streaming.api.functions.ProcessFunction[com.fasterxml.jackson.databind.node.ObjectNode,(String, Long)]#Context, x$3: org.apache.flink.util.Collector[(String, Long)])Unit is not definedclass TimeoutStateFunction extends ProcessFunction[ObjectNode, (String, Long)] {Error:(17, 18) method processElement overrides nothing.Note: the super classes of class TimeoutStateFunction contain the following, non final members named processElement:def processElement(x$1: com.fasterxml.jackson.databind.node.ObjectNode,x$2: org.apache.flink.streaming.api.functions.ProcessFunction[com.fasterxml.jackson.databind.node.ObjectNode,(String, Long)]#Context,x$3: org.apache.flink.util.Collector[(String, Long)]): Unit  override def processElement(value: ObjectNode, ctx: Context, out: Collector[(String, Long)]): Unit = {Error:(36, 16) method onTimer overrides nothing.Note: the super classes of class TimeoutStateFunction contain the following, non final members named onTimer:def onTimer(x$1: Long,x$2: org.apache.flink.streaming.api.functions.ProcessFunction[com.fasterxml.jackson.databind.node.ObjectNode,(String, Long)]#OnTimerContext,x$3: org.apache.flink.util.Collector[(String, Long)]): Unit   override def onTimer(timestamp: Long, ctx: OnTimerContext, out: Collector[(String, Long)]): Unit = {

原因:

Context 和 OnTimerContext 要指明为ProcessFunction内部的

解决方法:

override def processElement(     value: ObjectNode,     ctx: ProcessFunction[ObjectNode, (String, Long)]#Context,     out: Collector[(String, Long)])   : Unit = {     //Stuff here } override def onTimer(     timestamp: Long,     ctx: ProcessFunction[ObjectNode, (String, Long)]#OnTimerContext,     out: Collector[(String, Long)])   : Unit = {     //More Stuff here }

 

转载于:https://my.oschina.net/u/2000675/blog/1799600

你可能感兴趣的文章
GridView 编辑、删除 、分页
查看>>
[洛谷P2742]【模板】二维凸包([USACO5.1]圈奶牛Fencing the Cows)
查看>>
C/C++动态二维数组的内存分配和释放
查看>>
HTC G7 官方ROM卡刷包(国行、台版、港版、印度、亚太版、欧版)
查看>>
jQuery笔记(五)jQuery表单验证
查看>>
编程助手JavaScript学习库-面向对象编程笔记
查看>>
聪明的数据结构和笨拙的逻辑代码
查看>>
php_memcache 缓存 下载-安装-配置-学习
查看>>
Java EE之通过表单上传文件
查看>>
Gnome创建桌面快捷方式
查看>>
机器人会偷走你的饭碗吗——药剂师 vs. 巨型药品包装机
查看>>
C++数据类型范围
查看>>
UVa11401
查看>>
86. Partition List
查看>>
mysql 主从配置
查看>>
记录已被另一个用户锁定处理方法
查看>>
Codeforces 595B - Pasha and Phone
查看>>
Jquery--ajax
查看>>
shell脚本:批量修改文件名
查看>>
详解SimpleXML添加_修改_删除_遍历XML节点属性
查看>>