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

网站php怎么做/山东公司网站推广优化

网站php怎么做,山东公司网站推广优化,长安做英文网站,wordpress linux伪静态Evictors Flink的窗口模型允许除了WindowAssigner和Trigger之外还指定一个可选的Evictor。可以使用evictor(…)方法完成此操作。Evictors可以在触发器触发后&#xff0c;应用Window Function之前或之后从窗口中删除元素。 public interface Evictor<T, W extends Window&g…

Evictors

Flink的窗口模型允许除了WindowAssigner和Trigger之外还指定一个可选的Evictor。可以使用evictor(…)方法完成此操作。Evictors可以在触发器触发后,应用Window Function之前或之后从窗口中删除元素。

public interface Evictor<T, W extends Window> extends Serializable {/*** Optionally evicts elements. Called before windowing function.** @param elements The elements currently in the pane.* @param size The current number of elements in the pane.* @param window The {@link Window}* @param evictorContext The context for the Evictor*/void evictBefore(Iterable<TimestampedValue<T>> elements, int size, W window, EvictorContext evictorContext);/*** Optionally evicts elements. Called after windowing function.** @param elements The elements currently in the pane.* @param size The current number of elements in the pane.* @param window The {@link Window}* @param evictorContext The context for the Evictor*/void evictAfter(Iterable<TimestampedValue<T>> elements, int size, W window, EvictorContext evictorContext);/*** A context object that is given to {@link Evictor} methods.*/interface EvictorContext {/*** Returns the current processing time.*/long getCurrentProcessingTime();/*** Returns the metric group for this {@link Evictor}. This is the same metric* group that would be returned from {@link RuntimeContext#getMetricGroup()} in a user* function.** <p>You must not call methods that create metric objects* (such as {@link MetricGroup#counter(int)} multiple times but instead call once* and store the metric object in a field.*/MetricGroup getMetricGroup();/*** Returns the current watermark time.*/long getCurrentWatermark();}
}

evictBefore()包含要在窗口函数之前应用的剔除逻辑,而evictAfter()包含要在窗口函数之后应用的剔除逻辑。应用窗口功能之前剔除的元素将不会被其处理。

Flink DataStream Window内置了三种剔除器: CountEvictor、DeltaEvictor、TimeEvictor。

  • CountEvictor: 数量剔除器。在Window中保留指定数量的元素,并从窗口头部开始丢弃其余元素。
  • DeltaEvictor: 阈值剔除器。计算Window中最后一个元素与其余每个元素之间的增量,丢弃增量大于或等于阈值的元素。
  • TimeEvictor: 时间剔除器。保留Window中最近一段时间内的元素,并丢弃其余元素。
CountEvictor

1.窗口中数据总条数<=要保留的数据条数(maxCount),不剔除。
2.否则,从Window头部遍历并剔除。

private void evict(Iterable<TimestampedValue<Object>> elements, int size, EvictorContext ctx) {if (size <= maxCount) { //总条数<=要保留的数据条数(maxCount),不剔除return;} else { //否则,遍历剔除int evictedCount = 0;for (Iterator<TimestampedValue<Object>> iterator = elements.iterator(); iterator.hasNext();){iterator.next();evictedCount++;if (evictedCount > size - maxCount) {break;} else {iterator.remove();}}}
}
DeltaEvictor

1.先找到当前窗口的最后一条元素。
2.遍历窗口中的每一条元素。每条元素(A)和最后一条元素(L),依据用户提供DeltaFunction计算出一个Delta。计算出的Delta大于等于设定的阈值,则剔除该元素(A)。

private void evict(Iterable<TimestampedValue<T>> elements, int size, EvictorContext ctx) {// 找到当前窗口的最后一条元素TimestampedValue<T> lastElement = Iterables.getLast(elements);// 遍历每条元素并计算Delta。计算出的Delta大于等于设定的阈值,则剔除该条元素for (Iterator<TimestampedValue<T>> iterator = elements.iterator(); iterator.hasNext();){TimestampedValue<T> element = iterator.next();if (deltaFunction.getDelta(element.getValue(), lastElement.getValue()) >= this.threshold) {iterator.remove();}}
}
TimeEvictor

1.找到当前窗口时间截断点: 当前窗口最大时间点-要保留的时间段。
2.遍历窗口中的每一条元素。某条元素的时间<=截断点,则剔除该条元素。
一句话,即保留Window最近一段时间内的数据。
在这里插入图片描述

private void evict(Iterable<TimestampedValue<Object>> elements, int size, EvictorContext ctx) {if (!hasTimestamp(elements)) {return;}// 当前Window的最大时间戳long currentTime = getMaxTimestamp(elements);// 截断点long evictCutoff = currentTime - windowSize;// 当某条元素的时间戳<=截断点,则剔除该元素for (Iterator<TimestampedValue<Object>> iterator = elements.iterator(); iterator.hasNext(); ) {TimestampedValue<Object> record = iterator.next();if (record.getTimestamp() <= evictCutoff) {iterator.remove();}}
}
案例
public class UserDefineEvictor implements Evictor<String, TimeWindow> {private Boolean isEvictorAfter = false;private String excludeContent = null;public UserDefineEvictor(Boolean isEvictorAfter, String excludeContent) {this.isEvictorAfter = isEvictorAfter;this.excludeContent = excludeContent;}@Overridepublic void evictBefore(Iterable<TimestampedValue<String>> elements, int size, TimeWindow window, EvictorContext evictorContext) {if(!isEvictorAfter){evict(elements,size,window,evictorContext);}}@Overridepublic void evictAfter(Iterable<TimestampedValue<String>> elements, int size, TimeWindow window, EvictorContext evictorContext) {if(isEvictorAfter){evict(elements,size,window,evictorContext);}}private void evict(Iterable<TimestampedValue<String>> elements,int size,TimeWindow window,EvictorContext evictorContext){for(Iterator<TimestampedValue<String>> iterator = elements.iterator();iterator.hasNext();){TimestampedValue<String> element = iterator.next();//将含有相关内容元素删除System.out.println(element.getValue());if(element.getValue().contains(excludeContent)){iterator.remove();}}}
}
object FlinkSlidingCountEvictor {def main(args: Array[String]): Unit = {val env = StreamExecutionEnvironment.getExecutionEnvironmentval text = env.socketTextStream("train",9999)val counts = text.windowAll(SlidingProcessingTimeWindows.of(Time.seconds(4),Time.seconds(2))).evictor(new UserDefineEvictor(false,"error")).apply(new UserDefineSlidingWindowFunction)counts.print()env.execute()}
}
class UserDefineSlidingWindowFunction extends AllWindowFunction[String,String,TimeWindow] {override def apply(window: TimeWindow,input: Iterable[String],out: Collector[String]): Unit = {val sdf = new SimpleDateFormat("HH:mm:ss")var start=sdf.format(window.getStart)var end=sdf.format(window.getEnd)var windowContent=input.toListprintln("window:"+start+"\t"+end+" "+windowContent.mkString(" | "))}
}
http://www.lbrq.cn/news/762643.html

相关文章:

  • 微信赌博链接网站建设/网站流量统计软件
  • 金融类网站源码/网络推广的途径有哪些
  • 浉河网站建设/搜索引擎推广有哪些平台
  • 普陀网站制作/网络推广公司电话
  • 广州建网站兴田德润信任/活动推广方案怎么写
  • 做网站公证需要费用是多少/英雄联盟世界排名
  • 网站整站开发视频教程/代运营公司怎么找客户
  • 网站一个人可以做吗/百度网站的网址
  • 响应式网站的排版/专业seo网络推广
  • 做web网站的步骤/信息流广告案例
  • 高校门户网站开发/网址缩短在线生成器
  • 怎么做网站教程/百度推广营销怎么做
  • 免费设计图片素材网站/深圳网站建设哪家好
  • 网站建设营销公司/sem是什么的缩写
  • 连锁酒店网站方案/网络营销八大职能
  • 微店那样的网站怎么做/seo关键词查询
  • 建站塔山双喜/万网查询
  • 软件开发项目/seo谷歌外贸推广
  • 怎样做打赏网站/关键字c语言
  • 福田做棋牌网站建设找哪家公司好/百度竞价seo排名
  • app要有网站做基础知识/班级优化大师app下载学生版
  • 可以做简历的网站/网络电商推广方案
  • 做微信表情的微信官方网站/浙江seo技术培训
  • 申请网站就是做网站吗/重庆森林电影简介
  • 装修案例欣赏/长沙百度首页优化排名
  • 美工做图哪个网站好/网站怎么做推广
  • 做网站需要懂哪些语言/网站seo推广计划
  • 龙岗网站/app推广联盟平台
  • 万户网站制作/百度sem是什么意思
  • 同企网站建设做网站/网络营销八大工具
  • Java面试宝典:JVM性能优化
  • springboot博客实战笔记02
  • 大数据项目_基于Python+hadopp的城市空气污染数据关联性可视化分析系统源码_基于机器学习的城市空气污染预测与分析系统的设计与实现
  • OS设备UDID查看方法
  • 药房智能盘库系统:基于CV与时间序列预测的库存革命
  • 全球AI安全防护迈入新阶段:F5推出全新AI驱动型应用AI安全解决方案