请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

type mismatch; found

type mismatch;
found : org.apache.flink.streaming.api.windowing.assigners.TumblingProcessingTimeWindows
required: org.apache.flink.streaming.api.windowing.assigners.WindowAssigner[_ >: Int, ?]
Note: Object <: Any (and org.apache.flink.streaming.api.windowing.assigners.TumblingProcessingTimeWindows <: org.apache.flink.streaming.api.windowing.assigners.WindowAssigner[Object,org.apache.flink.streaming.api.windowing.windows.TimeWindow]), but Java-defined class WindowAssigner is invariant in type T.
You may wish to investigate a wildcard type such as _ <: Any. (SLS 3.2.10)
}).windowAll(TumblingProcessingTimeWindows.of(Time.seconds(5)))

package com.hnyd.flink.window

import org.apache.flink.api.common.functions.MapFunction
import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment, createTypeInformation}
import org.apache.flink.streaming.api.windowing.assigners.{TumblingProcessingTimeWindows, WindowAssigner}
import org.apache.flink.streaming.api.windowing.time.Time

object WindowApp {

def main(args: Array[String]): Unit = {
val env: StreamExecutionEnvironment = StreamExecutionEnvironment.createLocalEnvironment()

test01(env)
env.execute("windowapp")

}

def test01(env:StreamExecutionEnvironment): Unit ={
// env.setStreamTimeCharacteristic(TimeCharacteristic.ProcessingTime) //原来的API需要设定,否则会报错
// val source: DataStream[String] = env.socketTextStream(“localhost”, 9527)
// source.map(new MapFunction[String,Int]{
// override def map(value: String): Int = {
// Integer.parseInt(value)
// }
// }).timeWindowAll(Time.seconds(5))
// .sum(0).print()

val source: DataStream[String] = env.socketTextStream("localhost", 9527)
source.map(new MapFunction[String,Int]{
  override def map(value: String): Int = {
    Integer.parseInt(value)
  }
}).windowAll(TumblingProcessingTimeWindows.of(Time.seconds(5),Time.seconds(5)))

}

}

正在回答 回答被采纳积分+3

1回答

Michael_PK 2022-03-18 12:24:49

遇到这种问题,建议使用google搜下

https://issues.apache.org/jira/browse/FLINK-18599 

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号