Apache flink Join



在apache flink中,我有2个tuple8<>说出来。4(tuple4(在8个事件元组中作为关键。我想执行两个流之间存在的记录的相关性,作为此步骤的一步,我使用JOIN Operator加入了2个流。根据语义,我应该获得包含内部连接记录的输出流。但是,我没有获得任何输出或匹配。ENV的时序特性设置为事件时间戳记,元组的第一个元素是时间戳记,我将其提取,并使用分配

将其标记为时间戳
DataStream<String> input = env.readTextFile("/tmp/logScrape/out/raw-input.out");
DataStream<Tuple8<Long, Integer, String, Integer, String, Integer, Integer, String>> inFiltered =
                input.flatMap(new Splitter())
                        .filter(new InFilter())
                        .assignTimestampsAndWatermarks(new BoundedOutOfOrdernessTimestampExtractor<Tuple8<Long, Integer, String, Integer, String, Integer, Integer, String>>(Time.seconds(10)) {
                            @Override
                            public long extractTimestamp(Tuple8<Long, Integer, String, Integer, String, Integer, Integer, String> record) {
                                return record.f0;
                            }
                        });
        DataStream<Tuple8<Long, Integer, String, Integer, String, Integer, Integer, String>> exitFiltered =
                input.flatMap(new Splitter())
                        .filter(new ExitFilter())
                        .assignTimestampsAndWatermarks(new BoundedOutOfOrdernessTimestampExtractor<Tuple8<Long, Integer, String, Integer, String, Integer, Integer, String>>(Time.seconds(10)) {
                            @Override
                            public long extractTimestamp(Tuple8<Long, Integer, String, Integer, String, Integer, Integer, String> record) {
                                return record.f0;
                            }
                        });
inFiltered.join(exitFiltered)
                .where(new TupleKeySelector())
                .equalTo(new TupleKeySelector())
                .window(TumblingEventTimeWindows.of(Time.milliseconds(1000000)))
                .apply(new StreamJoinner())
                .writeAsText("/tmp/logScrape/out/output");
 public static class TupleKeySelector implements KeySelector<
          Tuple8<Long, Integer, String, Integer, String, Integer, Integer, String>, 
          Tuple4<String, Integer, String, Integer>> {
        @Override
        public Tuple4<String, Integer, String, Integer> getKey(Tuple8<Long, Integer, String, Integer, String, Integer, Integer, String> value) {
            return new Tuple4<>(value.f2, value.f3, value.f4, value.f5);
        }
    }

这是我为inFiltered流提供的输出记录

(1519254461076381189,1234,program1,11,program2,20,27,in)
(1519254462071697685,1234,program1,11,program2,20,27,in)
(1519254463067014246,1234,program1,11,program2,20,27,in)

这是我为exitFiltered流提供的输出记录

(1519254458167640292,6789,program1,11,program2,20,27,out)
(1519254460158076301,6789,program1,11,program2,20,27,out)
(1519254461153294238,6789,program1,11,program2,20,27,out)
(1519254462148512207,6789,program1,11,program2,20,27,out)
(1519254463143730191,6789,program1,11,program2,20,27,out)

问题:

  • 这里有什么我缺少的,以便我应该开始看到加入结果?
  • 有什么办法可以在处理过程中调试代码?我不确定我的情况是否是问题的关键选择器或窗口是否正确进行。

您的窗口为1,000,000ms,对吗?从查看您的两个过滤流的时间戳(第一个字段,对吗?(,我看不到任何发生在同一1m毫秒中的情况。

相关内容

  • 没有找到相关文章

最新更新