.process method is not accepting custom process window class

I wrote a own processwindowfunction for the following method in Scala/flink but for some reason, I am getting this error in my IDE:

Type mismatch.
Required: ProcessWindowFunction[(String, String, Int), NotInferredR, String, TimeWindow]
Found: MyProcessWindowFunction

here is the relevant part of my implementation method:

 def question_seven(
                      commitStream: DataStream[Commit]): DataStream[CommitSummary] = {

    val windowedStream = commitStream
      .map { x =>
        (x.url.split("/")(4) + "/" + x.url.split("/")(5), x.commit.committer.name, x.stats.map(_.total).getOrElse(0))
      }
      .keyBy(_._1)
      .window(TumblingEventTimeWindows.of(Time.days(1)))
      .process(new MyProcessWindowFunction) //here is the error occurring
}

Here under my custom window process class:

import org.apache.flink.streaming.api.datastream.DataStream
import org.apache.flink.streaming.api.windowing.windows.TimeWindow
import org.apache.flink.streaming.api.functions.windowing.ProcessWindowFunction
import org.apache.flink.util.Collector
import util.Protocol.CommitSummary

import java.lang
import java.text.SimpleDateFormat
import scala.collection.JavaConverters._

class MyProcessWindowFunction extends ProcessWindowFunction[
  (String, String, Int),
  CommitSummary,
  String,
  TimeWindow
] {


  /**
   * Evaluates the window and outputs none or several elements.
   *
   * @param key      The key for which this window is evaluated.
   * @param context  The context in which the window is being evaluated.
   * @param elements The elements in the window being evaluated.
   * @param out      A collector for emitting elements.
   * @throws Exception The function may throw exceptions to fail the program and trigger recovery.
   */
  override def process(key: String, context: ProcessWindowFunction[(String, String, Int), CommitSummary, String, TimeWindow]#Context, iterable: lang.Iterable[(String, String, Int)], collector: Collector[CommitSummary]): Unit = {
    val elements = iterable.asScala
    val simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy")
    val windowStart = context.window.getStart
    val date = simpleDateFormat.format(windowStart)

    val amountOfCommits = elements.size

    val committerCounts = elements.groupBy(_._2).mapValues(_.size)

    val amountOfCommitters = committerCounts.size

    val totalChanges = elements.map(_._3).sum

    val maxCommits = committerCounts.values.max
    val topCommitters = committerCounts.filter(_._2 == maxCommits).keys.toList.sorted.mkString(",")

    val commitSummary = CommitSummary(key, date, amountOfCommits, amountOfCommitters, totalChanges, topCommitters)
    collector.collect(commitSummary)
  }

}

When i try to change something in this then i get other errors complaining that I don’t implement the original class correctly. I can provide more info if needed. The process class should return a datastream or a windowed datastream as far as i know.

1

I actually found out why the error was occurring. This is due to a wrong import of the ProcessWindowFunction.

I did: org.apache.flink.streaming.api.functions.windowing
But i should have done: org.apache.flink.streaming.api.scala.function

The first one is a Java function, which has different parameters, whereas the second one is a scala function that has other parameters.

Java parameters: [(String, String, Int), NotInferredR, String, TimeWindow]
Scala parameters: [(String, String, Int), CommitSummary, String, TimeWindow]

Commitsummary can be anyclass

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật