开发者社区> 问答> 正文

RichAllWindowFunction的open方法在什么时候被触发

如题

还有, 自定义的RichAllWindowFunction应该怎样使用才能触发open方法.

var filteredstream = inputStream
.flatMap(buildHbaseMsg(_))
.filter(b => b.actType match {

case 0|1|2|3 => true
case _ => false

})
.countWindowAll(2L).apply(new CustomWindowFunction ())'
这样吗?

尝试这样调用, open并没有执行
'stream.apply((window, input, out: Collector[Unit]) => new CustomWindowFunction ().apply(window, input, out))
'

展开
收起
乌野 2018-12-17 15:10:19 3864 0
1 条回答
写回答
取消 提交回答
  • 全局window必须通过触发器设置触发条件来进行触发。
    例如:

    val env = StreamExecutionEnvironment.getExecutionEnvironment
    env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime)
    val source = env.addSource(new SimpleSource)
    
    var triggerTest  = EventTimeTrigger.create()
    
    val window = source
      .keyBy(_._1)
      .window(GlobalWindows.create())
      .trigger(CountTrigger.of(1))
      .apply(new WindowFunctionTest)
      .print().name("GlobalWindows")
    
    env.execute("GlobalWindows")
    2019-07-17 23:22:31
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载