You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-zh@flink.apache.org by Yichao Yang <10...@qq.com> on 2020/07/09 06:18:19 UTC
回复:DataStream统计uv问题
Hi,
我看了下你统计uv的方法,是不是可以思考转换一下计算uv的方式,开一天的窗口可能不是一个合适的方法,可以参考[1]中的方案。
[1] https://lists.apache.org/thread.html/rbe00ee38e2d07310d4e3c796de86c65205d1f5deecfc1678d9ebbdea%40%3Cuser-zh.flink.apache.org%3E
------------------ 原始邮件 ------------------
发件人: "ゞ野蠻遊戲χ"<zhoujiazhi1985@vip.qq.com>;
发送时间: 2020年7月7日(星期二) 晚上10:32
收件人: "user-zh"<user-zh@flink.apache.org>;
主题: DataStream统计uv问题
大家好!
&nbsp; &nbsp; &nbsp;想问下,现在在用DataStream的api来统计每天的UV,代码如下,有2个使用问题:
&nbsp; &nbsp; &nbsp;1、在使用Tumbling窗口的时候,由于使用窗口跨度是1天(Time.days(1)),只有以一天结束的时候,才能输出一个uv值,
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 这样时间等待太长了,所以加了一个trigger,每来一条都触发一次窗口,不知道这样的用法没有问题。
&nbsp; &nbsp; &nbsp;2、还有想问下在窗口结束后,里面的state状态会自动释放吗?还是要自己手动设置TTL的。
DataStream<UvPer10Min&gt; uvPer10MinDataStream = userBehaviorSource
.windowAll(TumblingProcessingTimeWindows.of(Time.days(1L)))
.trigger(CountTrigger.of(1L))
.evictor(CountEvictor.of(0L, true))
.process(new ProcessAllWindowFunction<UserBehavior, UvPer10Min, TimeWindow&gt;() {
private transient MapState<String, String&gt; userIdState;
private transient ValueState<Long&gt; uvCountState;
&nbsp; &nbsp;
谢谢!
Jiazhi