可以使用Flink的Filter函数来实现过滤出包含有page字段的数据。具体实现如下:

DataStream<MyData> myData = env.readTextFile("path/to/file")
    .map(new MyDataMapFunction())
    .filter(new FilterFunction<MyData>() {
        @Override
        public boolean filter(MyData value) {
            return value.getPage() != null;
        }
    });

其中,MyDataMapFunction是一个自定义的MapFunction,用来将读取的文本数据转换成MyData对象。在filter函数中,判断MyData对象的page字段是否为null,如果不为null,则保留该数据,否则过滤掉该数据。最终得到的DataStream中只包含有page字段的数据。

flink读取数据后过滤出包含有page字段的数据

原文地址: https://www.cveoy.top/t/topic/fD1d 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录