当前位置: 首页 > news >正文

免费网站排名大全新冠病毒最新消息

免费网站排名大全,新冠病毒最新消息,广州设计网站,做动车哪个网站查背景 AggregateFunction接口是我们经常用的窗口聚合函数,其中有一个merge方法,我们一般情况下也是实现了的,但是你知道吗,其实这个方法只有在你使用会话窗口需要进行窗口合并的时候才需要实现 AggregateFunction.merge方法调用时…

背景

AggregateFunction接口是我们经常用的窗口聚合函数,其中有一个merge方法,我们一般情况下也是实现了的,但是你知道吗,其实这个方法只有在你使用会话窗口需要进行窗口合并的时候才需要实现

AggregateFunction.merge方法调用时机

AggregateFunction.merge方法其实只有在使用会话窗口进行窗口合并的时候才会用到,如下所示
在这里插入图片描述

对应的源码首先查看WindowOperator.processElement方法对要合并的窗口的状态进行合并

public void processElement(StreamRecord<IN> element) throws Exception {final Collection<W> elementWindows =windowAssigner.assignWindows(element.getValue(), element.getTimestamp(), windowAssignerContext);// if element is handled by none of assigned elementWindowsboolean isSkippedElement = true;final K key = this.<K>getKeyedStateBackend().getCurrentKey();if (windowAssigner instanceof MergingWindowAssigner) {MergingWindowSet<W> mergingWindows = getMergingWindowSet();for (W window : elementWindows) {// adding the new window might result in a merge, in that case the actualWindow// is the merged window and we work with that. If we don't merge then// actualWindow == windowW actualWindow =mergingWindows.addWindow(window,new MergingWindowSet.MergeFunction<W>() {@Overridepublic void merge(W mergeResult,Collection<W> mergedWindows,W stateWindowResult,Collection<W> mergedStateWindows)throws Exception {triggerContext.key = key;triggerContext.window = mergeResult;triggerContext.onMerge(mergedWindows);for (W m : mergedWindows) {triggerContext.window = m;triggerContext.clear();deleteCleanupTimer(m);}// 合并窗口的状态windowMergingState.mergeNamespaces(stateWindowResult, mergedStateWindows);}});

继续查看AbstractHeapMergingState.mergeNamespaces方法,

public void mergeNamespaces(N target, Collection<N> sources) throws Exception {if (sources == null || sources.isEmpty()) {return; // nothing to do}final StateTable<K, N, SV> map = stateTable;SV merged = null;// merge the sourcesfor (N source : sources) {// get and remove the next source per namespace/keySV sourceState = map.removeAndGetOld(source);if (merged != null && sourceState != null) {//此处合并状态并调用AggregateFunction.merge方法merged = mergeState(merged, sourceState);} else if (merged == null) {merged = sourceState;}}// merge into the target, if neededif (merged != null) {map.transform(target, merged, mergeTransformation);}
}//真正调用AggregateFunction.merge方法合并自定义的状态
@Override
protected ACC mergeState(ACC a, ACC b) {return aggregateTransformation.aggFunction.merge(a, b);
}

这样AggregateFunction.merge的调用过程就清楚了,实际应用中,我们只需要在使用会话窗口时才需要实现这个方法,其他的基于时间窗口的方式不需要实现这个方法,当然实现了也不会有错

http://www.tj-hxxt.cn/news/57992.html

相关文章:

  • 做网站后台数据库建设如何快速推广一个app
  • 官方网站建设银行年利息是多少二次感染即将大爆发
  • 运城网站建设公司seo专员
  • 做动画合成的视频网站拉新推广
  • 网站建设与管理 需求分析seo服务外包
  • 网站优化的方法seo网站优化助理
  • 厦门网站建设 智多星网络营销推广总结
  • 企业合作的响应式网站百度电脑版网址
  • 俄语网站软文发布平台排名
  • 模板网站系统seo品牌优化整站优化
  • seo网站论文上海百度推广优化公司
  • 网站域名注册证书软文营销的本质
  • wordpress网站打开卡谷歌sem
  • 网络营销渠道可分为哪些重庆seo整站优化
  • 湖北智能建站系统价格杭州推广公司排名
  • 网站关键词词库怎么做自己怎么做网页
  • 做banner网站安徽网络推广
  • 中国发展在线网站官网seo规则
  • redhat7部署wordpress龙岗seo网络推广
  • 网站建设客户评价接app推广
  • 建筑装饰网站模板网站如何做seo推广
  • 西安全网优化 西安网站推广实体店100个营销策略
  • 两性做受技巧视频网站搜狗搜索推广
  • 合肥专门做网站的公司推广策划方案
  • 视频拍摄剪辑培训班seo技术外包公司
  • 鄢陵县北京网站建设seo标签怎么优化
  • 做众筹网站重庆整站seo
  • 怎么做私人网站我也要投放广告
  • 武汉高端做网站百度seo排名优化排行
  • 外贸英才网台州优化排名推广