在Kafka Streams中,Flink的翻滚/会话窗口联接相当于什么?

时间:2019-08-22 14:26:59

标签: apache-kafka apache-kafka-streams flink-streaming

根据Kafka Streams的documentation,我们只能通过定义下限和上限来应用KStream-to-KStream连接:

KStream<String, String> joined = left.join(right,
    (leftValue, rightValue) -> ... , /* ValueJoiner */
    JoinWindows.of(Duration.ofMinutes(5)),
    Joined.with(
      Serdes.String(), /* key */
      Serdes.Long(),   /* left value */
      Serdes.Double())  /* right value */
  );

这仅连接由连接窗口的长度定义的彼此接近的元素。但是,我正在寻找可以在Flink中完成的两个翻滚窗口:

DataStream<Integer> left = ...
DataStream<Integer> right = ...

left.join(right)
    .where(<LeftKeySelector>)
    .equalTo(<RightKeySelector>)
    .window(TumblingEventTimeWindows.of(Time.milliseconds(2)))
    .apply (new JoinFunction<Integer, Integer, String> (){
        @Override
        public String join(Integer first, Integer second) {
            return first + "," + second;
        }
    });

0 个答案:

没有答案