In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use the MaxBy of Flink". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
MaxBy aggregation: gets the largest record row in a set of data flow operators (unlike max, max is the maximum value that returns a calculated field)
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
MaxBy.java
Import com.flink.examples.DataSource;import org.apache.flink.api.common.typeinfo.Types;import org.apache.flink.api.java.functions.KeySelector;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 maxBy aggregation: get the largest row of records in a set of data flow operators (unlike max, max is the maximum value that returns the calculated field) * / public class MaxBy {/ * * traversal collection Returns the maximum age data record for each gender segment * @ 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) .returns (Types.TUPLE (Types.STRING, Types.STRING,Types.INT)) .keyby ((KeySelector) k-> k.f1) / / scroll by quantity window, every 3 input data streams Calculate once. CountWindow (3) / / Note: the calculation variable is f2.maxBy (2) DataStream.print (); env.execute ("flink MaxBy job");}}
Print the result
4 > (Liu Liu, girl,32) 2 > (Wu Ba, man,30) the content of "how to use MaxBy of Flink" ends here. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.