In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use Filter in Flink, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Filter operator: filters the data stream and returns only the data that is true
Sample environment
Java.version: 1.8.xflink.version: 1.11.1
Sample data source (project code cloud download)
Building Development Environment and data of Flink system example
Fliter.java
Import com.flink.examples.DataSource;import org.apache.flink.api.common.functions.FilterFunction;import org.apache.flink.api.java.tuple.Tuple3;import org.apache.flink.streaming.api.datastream.DataStream;import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;import java.util.List / * * @ Description Filter operator: filter the data stream, return only true data * / public class Filter {/ * traversal collection, print only male records * @ param args * @ throws Exception * / public static void main (String [] args) throws Exception {final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment (); List tuple3List = DataSource.getTuple3ToList () DataStream dataStream = env.fromCollection (tuple3List) .filter (new FilterFunction () {@ Override public boolean filter (Tuple3 tuple3) throws Exception {/ / gender (1 male, 2 female) return tuple3.f1.equals ("man");}}); dataStream.print (); env.execute ("flink Filter job");}}
Print the result
4 > (Wu Ba, man,30) 3 > (Zhang San, man,20) 1 > (Wang Wu, man,29) these are all the contents of this article "how to use Filter in Flink". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.